Skip to content

Commit

Permalink
Add some docs for validities.
Browse files Browse the repository at this point in the history
  • Loading branch information
josephbirkner committed Dec 10, 2024
1 parent de1e081 commit ff9faa3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,21 @@ of a *Feature* in *mapget* is based on GeoJSON:
id: "<type-id>.<part-value-0>...<part-value-n>",
typeId: "<type-id>",
"<part-name-n>": "<part-value-n>",
"geometry": { /* GeoJSON geometry object */ },
"geometry": { /* GeoJSON geometry object with additional `name` field. */ },
"properties": {
"layers": {
"<attr-layer-name>": {
"<attr-name>": {
/* attr-fields ... */,
"direction": "<attr-direction>",
"validity": { /* attr-validity-geometry */ }
"validity": [{
direction: "<Optional validity direction along the feature>",
geometryName: { /* Optional reference to a specific feature geometry by name. */ },
geometry: { /* Optional nested GeoJSON geometry object. */ },
start: { /* Optional WGS84 point or scalar depending on type, indicating range. */ },
end: { /* Optional WGS84 point or scalar depending on type, indicating range. */ },
point: { /* Optional WGS84 point or scalar depending on type, indicating single position. */ },
offsetType: "GeoPosOffset|BufferOffset|RelativeLengthOffset|MetricLengthOffset",
}]
}
},
// Additional attribute layers
Expand All @@ -133,8 +140,8 @@ of a *Feature* in *mapget* is based on GeoJSON:
{
"name": "<relation-name>",
"target": "<target-feature-id>",
"targetValidity": { /* geometry */ },
"sourceValidity": { /* geometry */ }
"targetValidity": [{ /* optional target validity-geom-description. see above for fields. */ }],
"sourceValidity": [{ /* optional source validity-geom-description. see above for fields. */ }]
}
// Additional relations
]
Expand All @@ -146,7 +153,7 @@ This structure provides a clear, hierarchical representation of a *Feature*, whe
- **`typeId`**: Indicates the feature type.
- **`id`**: A composite identifier based on the `typeId` and additional `part-values`.
- **`geometry`**: Encodes the spatial data of the feature in a format compliant with GeoJSON, but extended to support 3D geometries.
- **`properties`**: Contains feature attributes, organized into layers.
- **`properties`**: Contains both basic and layered feature attributes.
- **`relations`**: Defines relationships between this feature and others, including the spatial validity of these relationships.

### Feature ID Schemes
Expand Down
Binary file modified docs/components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/cpp/http-datasource/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MyRemoteDataSource
// Add an attribute layer
auto attrLayer = feature1->attributeLayers()->newLayer("cheese");
auto attr = attrLayer->newAttribute("mozzarella");
attr->setDirection(Attribute::Direction::Positive);
attr->validity()->newDirection(Validity::Direction::Positive);
attr->addField("smell", "neutral");

// Set some additional info on the tile
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/local-datasource/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MyLocalDataSource : public mapget::DataSource
// Add an attribute layer
auto attrLayer = feature1->attributeLayers()->newLayer("cheese");
auto attr = attrLayer->newAttribute("mozzarella");
attr->setDirection(Attribute::Direction::Positive);
attr->validity()->newDirection(Validity::Direction::Positive);
attr->addField("smell", "neutral");
}

Expand Down
1 change: 1 addition & 0 deletions libs/model/include/mapget/model/stringpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct StringPool : public simfil::StringPool
GeometryStr,
GeometryNameStr,
GeometriesStr,
OffsetTypeStr,
TypeStr,
CoordinatesStr,
ElevationStr,
Expand Down
1 change: 1 addition & 0 deletions libs/model/src/stringpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ StringPool::StringPool(const std::string_view& nodeId) : nodeId_(nodeId) {
addStaticKey(GeometryNameStr, "geometryName");
addStaticKey(GeometriesStr, "geometries");
addStaticKey(TypeStr, "type");
addStaticKey(OffsetTypeStr, "offsetType");
addStaticKey(CoordinatesStr, "coordinates");
addStaticKey(ElevationStr, "elevation");
addStaticKey(SourceDataStr, "_sourceData");
Expand Down
17 changes: 17 additions & 0 deletions libs/model/src/validity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ Validity::Validity(Validity::Data* data,
});
}

if (data_->geomOffsetType_ != InvalidOffsetType) {
fields_.emplace_back(
StringPool::OffsetTypeStr,
[](Validity const& self)
{
std::string_view resultString = "Invalid";
switch (self.geometryOffsetType()) {
case InvalidOffsetType: break;
case GeoPosOffset: resultString = "GeoPosOffset"; break;
case BufferOffset: resultString = "BufferOffset"; break;
case RelativeLengthOffset: resultString = "RelativeLengthOffset"; break;
case MetricLengthOffset: resultString = "MetricLengthOffset"; break;
}
return model_ptr<simfil::ValueNode>::make(resultString, self.model_);
});
}

auto exposeOffsetPoint = [this](StringId fieldName, uint32_t pointIndex, Point const& p)
{
fields_.emplace_back(
Expand Down

0 comments on commit ff9faa3

Please sign in to comment.