Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2024.5.0 #80

Merged
merged 31 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8595e3c
Add validity header
Waguramu Oct 23, 2024
09fd14e
* Refactored VertexNode to PointNode across model files.
Waguramu Oct 28, 2024
def72e5
* Refactor VertexBufferNode to PointBufferNode across model files for…
Waguramu Oct 29, 2024
262b27b
Implement TileFeatureLayer aspects of Validity/ValidityCollection/Val…
Waguramu Oct 29, 2024
457907b
Added ValidityCollections to Attribute and Relation and implemented c…
Waguramu Oct 29, 2024
07cbb6c
* Add geographicDistanceTo method to Point for calculating distances …
Waguramu Oct 29, 2024
efc51c3
Add geometry name and implement Validity::computeGeometry.
Waguramu Oct 30, 2024
9b8c442
Start work on Validity test case.
Waguramu Oct 30, 2024
f3b3fee
Apply renaming of shared_model_ptr.
josephbirkner Oct 31, 2024
04840ed
Fix use-after-move for TileFeatureLayer.
josephbirkner Oct 31, 2024
4348adf
Fix test cases.
josephbirkner Oct 31, 2024
8e4085f
Fix tests and improve APIs. Renamed ValidityCollection to MultiValidi…
josephbirkner Oct 31, 2024
8ebf9f1
Introduce SelfContainedGeometry type to simplify interface.
josephbirkner Nov 11, 2024
8ec68ac
Fix setters to accept null validity
Waguramu Nov 15, 2024
977ec58
Fix broken SourceDataReferenceItem::iterate
josephbirkner Nov 15, 2024
d5ca242
Use unordered_map
Waguramu Nov 18, 2024
42cb8d5
glm: FetchContent uses same version as conan recipe (fixes also volat…
MisterGC Nov 20, 2024
cf1b610
deps: Use simfil which comes with a fix for compiler confusion on som…
MisterGC Dec 2, 2024
ec9c7e4
Fix non-const reference
Waguramu Dec 9, 2024
d73799e
Fix simfil reference
Waguramu Dec 9, 2024
de1e081
Bump simfil to 0.3.4, mapget to 2024.5.0, fix test compile errors.
josephbirkner Dec 10, 2024
ff9faa3
Add some docs for validities.
josephbirkner Dec 10, 2024
3e68c4e
Catch null geometry collection.
josephbirkner Dec 10, 2024
08ee045
Expose length and line boundary methods via Geometry
Waguramu Dec 11, 2024
b436824
Add direct featureId to validity
Waguramu Dec 11, 2024
cdd05dc
Allow public access to ColumnId
Waguramu Dec 11, 2024
323d500
config: Avoid race with loader/watcher thread in apps that use mapget.
MisterGC Dec 16, 2024
73410c4
Merge pull request #81 from ndsev/config-loading-race
josephbirkner Dec 17, 2024
ae743ff
Fix usage of attribute API in Python sample.
josephbirkner Dec 17, 2024
8a0a06f
Fix DataSource config and FeatureLayer toJSON test
Waguramu Dec 18, 2024
a26420f
Fix GeometryCollection test in Construct GeometryCollection and GeoJS…
Waguramu Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (MAPGET_CONAN)
else()
FetchContent_Declare(glm
GIT_REPOSITORY "https://github.com/g-truc/glm.git"
GIT_TAG "0.9.9.8"
GIT_TAG "1.0.1"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(glm)

Expand Down Expand Up @@ -111,7 +111,7 @@ else()
set(SIMFIL_SHARED NO CACHE BOOL "Simfil as static library")
FetchContent_Declare(simfil
GIT_REPOSITORY "https://github.com/Klebert-Engineering/simfil.git"
GIT_TAG "v0.3.3"
GIT_TAG "fix-compiler-confusion"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(simfil)
endif()
Expand Down
2 changes: 1 addition & 1 deletion libs/http-service/src/http-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace mapget

struct HttpClient::Impl {
httplib::Client client_;
std::map<std::string, DataSourceInfo> sources_;
std::unordered_map<std::string, DataSourceInfo> sources_;
std::shared_ptr<TileLayerStream::StringPoolCache> stringPoolProvider_;

Impl(std::string const& host, uint16_t port) : client_(host, port)
Expand Down
8 changes: 4 additions & 4 deletions libs/http-service/src/http-service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ std::string stringToHash(const std::string& input)
*/
nlohmann::json yamlToJson(
const YAML::Node& yamlNode,
std::map<std::string, std::string>* maskedSecretMap = nullptr,
std::unordered_map<std::string, std::string>* maskedSecretMap = nullptr,
const bool mask = false)
{
if (yamlNode.IsScalar()) {
Expand Down Expand Up @@ -103,7 +103,7 @@ nlohmann::json yamlToJson(
* Recursively convert a JSON object to a YAML node,
* with special handling for sensitive fields.
*/
YAML::Node jsonToYaml(const nlohmann::json& json, std::map<std::string, std::string> const& maskedSecretMap)
YAML::Node jsonToYaml(const nlohmann::json& json, std::unordered_map<std::string, std::string> const& maskedSecretMap)
{
YAML::Node node;
if (json.is_object()) {
Expand Down Expand Up @@ -221,7 +221,7 @@ struct HttpService::Impl
};

mutable std::mutex clientRequestMapMutex_;
mutable std::map<std::string, std::shared_ptr<HttpTilesRequestState>> requestStatePerClientId_;
mutable std::unordered_map<std::string, std::shared_ptr<HttpTilesRequestState>> requestStatePerClientId_;

void abortRequestsForClientId(std::string clientId, std::shared_ptr<HttpTilesRequestState> newState = nullptr) const
{
Expand Down Expand Up @@ -591,7 +591,7 @@ struct HttpService::Impl

// Load the YAML, parse the secrets.
auto yamlConfig = YAML::Load(configFile);
std::map<std::string, std::string> maskedSecrets;
std::unordered_map<std::string, std::string> maskedSecrets;
yamlToJson(yamlConfig, &maskedSecrets);

// Create YAML nodes for from JSON nodes.
Expand Down
7 changes: 6 additions & 1 deletion libs/model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ add_library(mapget-model STATIC
include/mapget/model/featureid.h
include/mapget/model/stream.h
include/mapget/model/relation.h
include/mapget/model/point.h
include/mapget/model/pointnode.h
include/mapget/model/geometry.h
include/mapget/model/simfil-geometry.h
include/mapget/model/sourcedata.h
include/mapget/model/sourcedatalayer.h
include/mapget/model/sourceinfo.h
include/mapget/model/sourcedatareference.h
include/mapget/model/validity.h

src/stringpool.cpp
src/layer.cpp
Expand All @@ -32,11 +35,13 @@ add_library(mapget-model STATIC
src/stream.cpp
src/geometry.cpp
src/point.cpp
src/pointnode.cpp
src/simfil-geometry.cpp
src/simfilutil.h
src/sourcedata.cpp
src/sourcedatalayer.cpp
src/sourcedatareference.cpp)
src/sourcedatareference.cpp
src/validity.cpp)

target_include_directories(mapget-model
PUBLIC
Expand Down
42 changes: 12 additions & 30 deletions libs/model/include/mapget/model/attr.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include "featureid.h"
#include "geometry.h"
#include "sourcedatareference.h"
#include "validity.h"

namespace mapget
{
Expand All @@ -10,38 +11,21 @@ class Geometry;

/**
* Represents a feature attribute which belongs to an
* AttributeLayer, and may have typed `direction` and
* `validity` fields in addition to other arbitrary object fields.
* AttributeLayer, and may have reference several
* `Validity` objects in addition to other arbitrary object fields.
*/
class Attribute : public simfil::ProceduralObject<2, Attribute>
class Attribute : public simfil::ProceduralObject<2, Attribute, TileFeatureLayer>
{
friend class TileFeatureLayer;
template<typename> friend struct simfil::shared_model_ptr;
template<typename> friend struct simfil::model_ptr;

public:
/**
* Attribute direction values - may be used as flags.
*/
enum Direction : uint8_t {
Empty = 0x0, // No set direction
Positive = 0x1, // Positive (digitization) direction
Negative = 0x2, // Negative (against digitization) direction
Both = 0x3, // Both positive and negative direction
None = 0x4, // Not in any direction
};

/**
* Attribute direction accessors.
*/
[[nodiscard]] Direction direction() const;
void setDirection(Direction const& v);

/**
* Attribute validity accessors.
*/
[[nodiscard]] bool hasValidity() const;
[[nodiscard]] model_ptr<Geometry> validity() const;
void setValidity(model_ptr<Geometry> const& validityGeom);
[[nodiscard]] model_ptr<MultiValidity> validity();
[[nodiscard]] model_ptr<MultiValidity> validityOrNull() const;
void setValidity(const model_ptr<MultiValidity>& validities) const;

/**
* Read-only attribute name accessor.
Expand All @@ -58,23 +42,21 @@ class Attribute : public simfil::ProceduralObject<2, Attribute>
/**
* Source data related accessors.
*/
model_ptr<SourceDataReferenceCollection> sourceDataReferences() const;
[[nodiscard]] model_ptr<SourceDataReferenceCollection> sourceDataReferences() const;
void setSourceDataReferences(simfil::ModelNode::Ptr const& node);

protected:

/** Actual per-attribute data that is stored in the model's attributes-column. */
struct Data {
Direction direction_ = Empty;
simfil::ModelNodeAddress validity_;
simfil::ModelNodeAddress validities_;
simfil::ArrayIndex fields_ = -1;
simfil::StringId name_ = 0;
simfil::ModelNodeAddress sourceDataRefs_;

template<typename S>
void serialize(S& s) {
s.value1b(direction_);
s.object(validity_);
s.object(validities_);
s.value4b(fields_);
s.value2b(name_);
s.object(sourceDataRefs_);
Expand Down
6 changes: 4 additions & 2 deletions libs/model/include/mapget/model/attrlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ class AttributeLayerList;
* Represents a collection of Attributes which are semantically related.
* For example, all feature attributes which refer to road rules, such
* as speed limits, might belong to the same attribute layer.
* TODO: Convert to use BaseObject
*/
class AttributeLayer : public simfil::Object
{
friend class TileFeatureLayer;
friend class bitsery::Access;
template<typename> friend struct simfil::shared_model_ptr;
template<typename> friend struct simfil::model_ptr;

public:
/**
Expand Down Expand Up @@ -47,13 +48,14 @@ class AttributeLayer : public simfil::Object
/**
* Collection of attribute layers - this is merely a typed dict which
* stores (layer-name, layer) pairs.
* TODO: Convert to use BaseObject
*/
class AttributeLayerList : public simfil::Object
{
friend class TileFeatureLayer;
friend class bitsery::Access;
friend class Feature;
template<typename> friend struct simfil::shared_model_ptr;
template<typename> friend struct simfil::model_ptr;

public:
/**
Expand Down
15 changes: 7 additions & 8 deletions libs/model/include/mapget/model/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Feature : public simfil::MandatoryDerivedModelNodeBase<TileFeatureLayer>
friend class bitsery::Access;
friend class TileFeatureLayer;
friend class BoundFeature;
template<typename> friend struct simfil::shared_model_ptr;
template<typename> friend struct simfil::model_ptr;

public:
/** Get the name of this feature's type. */
Expand All @@ -69,22 +69,22 @@ class Feature : public simfil::MandatoryDerivedModelNodeBase<TileFeatureLayer>
* GeometryCollection if the feature does not have one yet.
*/
model_ptr<GeometryCollection> geom();
[[nodiscard]] model_ptr<GeometryCollection> geom() const;
[[nodiscard]] model_ptr<Geometry> firstGeometry() const;
[[nodiscard]] model_ptr<GeometryCollection> geomOrNull() const;
[[nodiscard]] SelfContainedGeometry firstGeometry() const;

/**
* Get this feature's Attribute layers. The non-const version adds a
* AttributeLayerList if the feature does not have one yet.
*/
model_ptr<AttributeLayerList> attributeLayers();
[[nodiscard]] model_ptr<AttributeLayerList> attributeLayers() const;
[[nodiscard]] model_ptr<AttributeLayerList> attributeLayersOrNull() const;

/**
* Get this feature's un-layered attributes.The non-const version adds a
* generic attribute storage if the feature does not have one yet.
*/
model_ptr<Object> attributes();
[[nodiscard]] model_ptr<Object> attributes() const;
[[nodiscard]] model_ptr<Object> attributesOrNull() const;

/** Add a point to the feature. */
void addPoint(Point const& p);
Expand Down Expand Up @@ -170,9 +170,10 @@ class Feature : public simfil::MandatoryDerivedModelNodeBase<TileFeatureLayer>
* Relation list if the feature does not have one yet.
* Note: This accessor is private, to ensure that the relations
* array really only ever contains relations.
* TODO: Change relations to use a RelationCollection derived from BaseArray
*/
[[nodiscard]] model_ptr<Array> relations();
[[nodiscard]] model_ptr<Array> relations() const;
[[nodiscard]] model_ptr<Array> relationsOrNull() const;

/**
* Feature Data
Expand Down Expand Up @@ -209,8 +210,6 @@ class Feature : public simfil::MandatoryDerivedModelNodeBase<TileFeatureLayer>
sfl::small_vector<std::pair<simfil::StringId, simfil::ModelNode::Ptr>, 32> fields_;
void updateFields();

nlohmann::json toJsonPrivate(simfil::ModelNode const&);

struct FeaturePropertyView : public simfil::MandatoryDerivedModelNodeBase<TileFeatureLayer>
{
[[nodiscard]] simfil::ValueType type() const override;
Expand Down
4 changes: 2 additions & 2 deletions libs/model/include/mapget/model/featureid.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TileFeatureLayer;
using FeatureLayerConstPtr = std::shared_ptr<TileFeatureLayer const>;

template<typename T>
using model_ptr = simfil::shared_model_ptr<T>;
using model_ptr = simfil::model_ptr<T>;

using Object = simfil::Object;
using Array = simfil::Array;
Expand All @@ -24,7 +24,7 @@ class FeatureId : public simfil::MandatoryDerivedModelNodeBase<TileFeatureLayer>
friend class Feature;
friend class Relation;
friend class bitsery::Access;
template<typename> friend struct simfil::shared_model_ptr;
template<typename> friend struct simfil::model_ptr;

public:
/** Convert the FeatureId to a string like `<type-id>.<part-value-0>...<part-value-n>` */
Expand Down
27 changes: 23 additions & 4 deletions libs/model/include/mapget/model/featurelayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "relation.h"
#include "geometry.h"
#include "sourcedatareference.h"
#include "pointnode.h"

namespace mapget
{
Expand All @@ -32,14 +33,15 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool
friend class AttributeLayerList;
friend class Geometry;
friend class GeometryCollection;
friend class VertexNode;
friend class VertexBufferNode;
friend class PointNode;
friend class PointBufferNode;
friend class PolygonNode;
friend class MeshNode;
friend class MeshTriangleCollectionNode;
friend class LinearRingNode;
friend class SourceDataReferenceCollection;
friend class SourceDataReferenceItem;
friend class Validity;

public:
/**
Expand Down Expand Up @@ -118,6 +120,7 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool
model_ptr<Relation> newRelation(
std::string_view const& name,
model_ptr<FeatureId> const& target);

/**
* Create a new named attribute, which may be inserted into an attribute layer.
*/
Expand Down Expand Up @@ -148,6 +151,16 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool
*/
model_ptr<SourceDataReferenceCollection> newSourceDataReferenceCollection(std::span<QualifiedSourceDataReference> list);

/**
* Create a new validity.
*/
model_ptr<Validity> newValidity();

/**
* Create a new validity collection.
*/
model_ptr<MultiValidity> newValidityCollection(size_t initialCapacity = 1);

/**
* Return type for begin() and end() methods to support range-based
* for-loops to iterate over all features in a TileFeatureLayer.
Expand Down Expand Up @@ -248,8 +261,8 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool
model_ptr<Feature> resolveFeature(simfil::ModelNode const& n) const;
model_ptr<FeatureId> resolveFeatureId(simfil::ModelNode const& n) const;
model_ptr<Relation> resolveRelation(simfil::ModelNode const& n) const;
model_ptr<VertexNode> resolvePoints(simfil::ModelNode const& n) const;
model_ptr<VertexBufferNode> resolvePointBuffers(simfil::ModelNode const& n) const;
model_ptr<PointNode> resolvePoint(const simfil::ModelNode& n) const;
model_ptr<PointBufferNode> resolvePointBuffer(const simfil::ModelNode& n) const;
model_ptr<Geometry> resolveGeometry(simfil::ModelNode const& n) const;
model_ptr<GeometryCollection> resolveGeometryCollection(simfil::ModelNode const& n) const;
model_ptr<MeshNode> resolveMesh(simfil::ModelNode const& n) const;
Expand All @@ -259,6 +272,9 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool
model_ptr<LinearRingNode> resolveLinearRing(simfil::ModelNode const& n) const;
model_ptr<SourceDataReferenceCollection> resolveSourceDataReferenceCollection(simfil::ModelNode const& n) const;
model_ptr<SourceDataReferenceItem> resolveSourceDataReferenceItem(simfil::ModelNode const& n) const;
model_ptr<PointNode> resolveValidityPoint(const simfil::ModelNode& n) const;
model_ptr<Validity> resolveValidity(simfil::ModelNode const& n) const;
model_ptr<MultiValidity> resolveValidityCollection(simfil::ModelNode const& n) const;

protected:
/**
Expand All @@ -284,6 +300,9 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool
LinearRing,
SourceDataReferenceCollections,
SourceDataReferences,
Validities,
ValidityPoints,
ValidityCollections,
}; };

/** Get the primary id composition for the given feature type. */
Expand Down
Loading
Loading