Skip to content

Commit

Permalink
Merge pull request #85 from ndsev/release/2025.1.0
Browse files Browse the repository at this point in the history
Release 2025.1.0
  • Loading branch information
Waguramu authored Jan 24, 2025
2 parents 0109f9f + b1274d6 commit 756f1d6
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
. ./venv/bin/activate
ctest --preset conan-release -C Release --verbose --no-tests=error
- name: Deploy
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: mapget-py${{ matrix.python-version }}-ubuntu-latest
path: build/Release/bin/wheel/*.whl
Expand All @@ -65,7 +65,7 @@ jobs:
env:
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
-DMAPGET_BUILD_EXAMPLES=YES
cmake --build --preset conan-release
- name: Deploy
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: mapget-py${{ matrix.python-version }}-${{ matrix.os }}
path: build/**/bin/wheel/*.whl
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
env:
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: Run sccache-cache
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file
- name: Publish Coverage HTML
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Test Coverage
path: coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Fetch
# Use official download-artifact action once fixed:
# https://github.com/actions/download-artifact/issues/3
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v6
with:
workflow: cmake.yaml
name: mapget-py${{ matrix.python-version }}-${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy(SET CMP0117 NEW)

project(mapget CXX)

set(MAPGET_VERSION 2024.5.0)
set(MAPGET_VERSION 2025.1.0)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
13 changes: 13 additions & 0 deletions libs/model/include/mapget/model/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ class Geometry final : public simfil::MandatoryDerivedModelNodeBase<TileFeatureL
*/
[[nodiscard]] std::vector<Point> pointsFromLengthBound(double start, std::optional<double> end) const;

/**
* Return percentage position point on the entire combined line geometries.
* @param geoms vector of line geometries to determine the position on their entire length.
* @param lengths vector of each geomtery length.
* @param numBits number of bits to store the percentage value.
* @param position percentage position on the geometries.
*/
[[nodiscard]] static Point percentagePositionFromGeometries(
std::vector<model_ptr<Geometry>> const& geoms,
std::vector<double> const& lengths,
uint32_t numBits,
double position);

/**
* Turn the points and type from this geometry into a self-contained
* struct which can be passed around.
Expand Down
7 changes: 7 additions & 0 deletions libs/model/include/mapget/model/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ class TileLayer
[[nodiscard]] nlohmann::json info() const;
void setInfo(std::string const& k, nlohmann::json const& v);

/**
* Getter and setter for this tile's copyright information.
*/
[[nodiscard]] std::optional<std::string> legalInfo() const;
void setLegalInfo(const std::string& legalInfoString);

/** Serialization */
virtual void write(std::ostream& outputStream);
virtual nlohmann::json toJson() const;
Expand All @@ -183,6 +189,7 @@ class TileLayer
std::chrono::time_point<std::chrono::system_clock> timestamp_;
std::optional<std::chrono::milliseconds> ttl_;
nlohmann::json info_;
std::optional<std::string> legalInfo_; // Copyright-related information
};

}
4 changes: 2 additions & 2 deletions libs/model/src/featurelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct TileFeatureLayer::Impl {
/**
* Indexing of features by their id hash. The hash-feature pairs are kept
* in a vector, which is kept in a sorted state. This allows finding a
* feature by it's id in O(log(n)) time.
* feature by its id in O(log(n)) time.
*/
struct FeatureAddrWithIdHash
{
Expand Down Expand Up @@ -780,7 +780,7 @@ nlohmann::json TileFeatureLayer::toJson() const
features.push_back(f->toJson());
return nlohmann::json::object({
{"type", "FeatureCollection"},
{"features", features},
{"features", features}
});
}

Expand Down
26 changes: 24 additions & 2 deletions libs/model/src/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#include "simfil/model/nodes.h"
#include "simfil/model/string-pool.h"
#include "sourcedatareference.h"
#include "sourceinfo.h"
#include "stringpool.h"
#include "validity.h"
#include "pointnode.h"

#include <cassert>
#include <cstdint>
#include <numeric>
#include <stdexcept>
#include <string_view>
#include <variant>
Expand Down Expand Up @@ -433,6 +432,29 @@ std::vector<Point> Geometry::pointsFromLengthBound(double start, std::optional<d
return result;
}

Point Geometry::percentagePositionFromGeometries(std::vector<model_ptr<Geometry>> const& geoms,
std::vector<double> const& lengths, uint32_t numBits, double position)
{
double totalLength = std::accumulate(lengths.begin(), lengths.end(), 0.0);
auto maxPos = static_cast<double>((1 << numBits) - 1);
auto percentagePosition = (position / maxPos) * totalLength;
Point positionPoint;
for (size_t i = 0; i < lengths.size(); i++) {
if (lengths[i] < percentagePosition) {
percentagePosition -= lengths[i];
}
else {
auto points = geoms[i]->pointsFromLengthBound(percentagePosition, std::nullopt);
if (points.empty()) {
break;
}
positionPoint = points[0];
break;
}
}
return positionPoint;
}

/** ModelNode impls. for PolygonNode */

PolygonNode::PolygonNode(ModelConstPtr pool, ModelNodeAddress const& a)
Expand Down
21 changes: 21 additions & 0 deletions libs/model/src/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ TileLayer::TileLayer(
error_ = ""; // Tell the optional that it has a value.
s.text1b(*error_, std::numeric_limits<uint32_t>::max());
}

bool hasLegalInfo = false;
s.value1b(hasLegalInfo);
if (hasLegalInfo) {
legalInfo_ = ""; // Tell the optional that it has a value.
s.text1b(*legalInfo_, std::numeric_limits<uint32_t>::max());
}
}

TileId TileLayer::tileId() const {
Expand Down Expand Up @@ -171,6 +178,11 @@ nlohmann::json TileLayer::info() const {
return info_;
}

std::optional<std::string> TileLayer::legalInfo() const
{
return legalInfo_;
}

void TileLayer::setTileId(const TileId& id) {
tileId_ = id;
}
Expand Down Expand Up @@ -207,6 +219,11 @@ void TileLayer::setInfo(std::string const& k, nlohmann::json const& v) {
info_[k] = v;
}

void TileLayer::setLegalInfo(const std::string& legalInfoString)
{
legalInfo_ = legalInfoString;
}

void TileLayer::write(std::ostream& outputStream)
{
using namespace std::chrono;
Expand All @@ -226,6 +243,10 @@ void TileLayer::write(std::ostream& outputStream)
s.value1b(error_.has_value());
if (error_)
s.text1b(*error_, std::numeric_limits<uint32_t>::max());
s.value1b(legalInfo_.has_value());
if (legalInfo_.has_value()) {
s.text1b(legalInfo_.value(), std::numeric_limits<uint32_t>::max());
}
}

MapTileKey TileLayer::id() const
Expand Down
12 changes: 6 additions & 6 deletions libs/model/src/validity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ model_ptr<FeatureId> Validity::featureId() const
if (!data_->featureAddress_) {
return {};
}
return model().resolveFeatureId(*ModelNode::Ptr::make(model_, data_->featureAddress_));
return model().resolveFeatureId(*Ptr::make(model_, data_->featureAddress_));
}

void Validity::setFeatureId(model_ptr<FeatureId> feature)
void Validity::setFeatureId(model_ptr<FeatureId> featureId)
{
if (!feature) {
if (!featureId) {
data_->featureAddress_ = {};
return;
}
data_->featureAddress_ = feature->addr();
data_->featureAddress_ = featureId->addr();
}

Validity::Validity(Validity::Data* data,
Expand Down Expand Up @@ -254,7 +254,7 @@ SelfContainedGeometry Validity::computeGeometry(
if (feature) {
geometryCollection = feature->geomOrNull();
} else {
mapget::log().warn("Could not find feature by its ID {}", featureId()->toString());
log().warn("Could not find feature by its ID {}", featureId()->toString());
}
}

Expand Down Expand Up @@ -312,7 +312,7 @@ SelfContainedGeometry Validity::computeGeometry(
return {points, points.size() > 1 ? GeomType::Line : GeomType::Points};
}

// Handle BufferOffset (a range of the goemetry bound by two indices).
// Handle BufferOffset (a range of the geometry bound by two indices).
if (offsetType == BufferOffset) {
auto startPointIndex = static_cast<uint32_t>(startPoint.x);
if (startPointIndex >= geometry->numPoints()) {
Expand Down

0 comments on commit 756f1d6

Please sign in to comment.