Skip to content

Commit

Permalink
Merge pull request #52 from ndsev/attribute-direction
Browse files Browse the repository at this point in the history
Show attribute direction as string.
  • Loading branch information
josephbirkner committed Dec 19, 2023
2 parents 0f5d07e + 4598db1 commit 014ee52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion libs/model/src/attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
namespace mapget
{

namespace {
std::string_view directionToString(Attribute::Direction const& d) {
switch (d) {
case Attribute::Empty: return "EMPTY";
case Attribute::Positive: return "POSITIVE";
case Attribute::Negative: return "NEGATIVE";
case Attribute::Both: return "BOTH";
case Attribute::None: return "NONE";
}
return "?";
}
}

Attribute::Attribute(Attribute::Data& data, simfil::ModelConstPtr l, simfil::ModelNodeAddress a)
: simfil::ProceduralObject<2, Attribute>(data.fields_, std::move(l), a), data_(data)
{
Expand All @@ -13,7 +26,7 @@ Attribute::Attribute(Attribute::Data& data, simfil::ModelConstPtr l, simfil::Mod
Fields::DirectionStr,
[](Attribute const& self) {
return model_ptr<simfil::ValueNode>::make(
(int64_t)self.data_.direction_,
directionToString(self.data_.direction_),
self.model_);
});
if (data_.validity_.value_)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ TEST_CASE("FeatureLayer", "[test.featurelayer]")

SECTION("toGeoJSON")
{
constexpr auto expected = R"({"areaId":"TheBestArea","geometry":{"geometries":[{"coordinates":[[41.0,10.0,0.0],[43.0,11.0,0.0]],"type":"LineString"},{"coordinates":[[41.5,10.5,0.0]],"type":"MultiPoint"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0]],"type":"MultiPoint"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0]],"type":"LineString"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0],[41.5,10.299999997019768,0.0]],"type":"MultiPolygon"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0],[41.5,10.299999997019768,0.0],[41.80000001192093,10.900000005960464,0.0]],"type":"Polygon"}],"type":"GeometryCollection"},"id":"Way.TheBestArea.42","properties":{"layer":{"cheese":{"mozzarella":{"direction":1,"smell":"neutral"}}},"main_ingredient":"Pepper"},"type":"Feature","typeId":"Way","wayId":42})";
constexpr auto expected = R"({"areaId":"TheBestArea","geometry":{"geometries":[{"coordinates":[[41.0,10.0,0.0],[43.0,11.0,0.0]],"type":"LineString"},{"coordinates":[[41.5,10.5,0.0]],"type":"MultiPoint"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0]],"type":"MultiPoint"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0]],"type":"LineString"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0],[41.5,10.299999997019768,0.0]],"type":"MultiPolygon"},{"coordinates":[[41.5,10.5,0.0],[41.600000001490116,10.700000002980232,0.0],[41.5,10.299999997019768,0.0],[41.80000001192093,10.900000005960464,0.0]],"type":"Polygon"}],"type":"GeometryCollection"},"id":"Way.TheBestArea.42","properties":{"layer":{"cheese":{"mozzarella":{"direction":"POSITIVE","smell":"neutral"}}},"main_ingredient":"Pepper"},"type":"Feature","typeId":"Way","wayId":42})";
std::stringstream featureGeoJson;
featureGeoJson << feature1->toGeoJson();
log().trace(featureGeoJson.str());
Expand Down

0 comments on commit 014ee52

Please sign in to comment.