From 22c8afced5970cac24a7ce98d67ac6741bb26cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 9 Jul 2014 16:27:23 -0700 Subject: [PATCH 1/2] replace {{token}} with {token}, and %d/%d/%d with {z}/{x}/{y} refs https://github.com/mapbox/mapbox-gl-style-spec/pull/87 --- bin/style.js | 56 +++++++++++++++---------------- include/llmr/style/value.hpp | 6 ---- include/llmr/util/token.hpp | 27 ++++++++------- src/map/source.cpp | 14 +++++--- src/text/glyph_store.cpp | 11 +++--- test/fixtures/styles/0.style.json | 2 +- test/fixtures/styles/1.style.json | 2 +- 7 files changed, 59 insertions(+), 59 deletions(-) diff --git a/bin/style.js b/bin/style.js index 21cca2af3..c292a2692 100644 --- a/bin/style.js +++ b/bin/style.js @@ -3,7 +3,7 @@ module.exports = { "version": 3, "sprite": "https://www.mapbox.com/mapbox-gl-styles/sprites/outdoors", - "glyphs": "https://mapbox.s3.amazonaws.com/gl-glyphs-256/{{fontstack}}/{{range}}.pbf", + "glyphs": "https://mapbox.s3.amazonaws.com/gl-glyphs-256/{fontstack}/{range}.pbf", "sources": { "mapbox": { "type": "vector", @@ -1739,7 +1739,7 @@ module.exports = { "filter": { "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 24, @@ -1764,7 +1764,7 @@ module.exports = { "filter": { "$type": "line", "labelrank": 1 }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 30, @@ -1794,7 +1794,7 @@ module.exports = { "filter": { "$type": "line", "labelrank": 2 }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 24, @@ -1823,7 +1823,7 @@ module.exports = { "filter": { "$type": "line", "labelrank": 3 }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 18, @@ -1852,7 +1852,7 @@ module.exports = { "filter": { "$type": "line", "labelrank": [4, 5, 6] }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 16, @@ -1881,7 +1881,7 @@ module.exports = { "filter": { "$type": "point", "labelrank": 1 }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 30, @@ -1912,7 +1912,7 @@ module.exports = { "filter": { "$type": "point", "labelrank": 2 }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 24, @@ -1943,7 +1943,7 @@ module.exports = { "filter": { "$type": "point", "labelrank": 3 }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 18, @@ -1974,7 +1974,7 @@ module.exports = { "filter": { "$type": "point", "labelrank": [4, 5, 6] }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 16, @@ -2005,7 +2005,7 @@ module.exports = { "filter": { "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Regular, Arial Unicode MS Regular", "text-max-size": 16, @@ -2036,7 +2036,7 @@ module.exports = { "filter": { "type": "city", "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 20, @@ -2067,7 +2067,7 @@ module.exports = { "filter": { "type": "town", "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 24, @@ -2098,7 +2098,7 @@ module.exports = { "filter": { "type": "village", "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 22, @@ -2129,7 +2129,7 @@ module.exports = { "filter": { "type": ["hamlet", "suburb", "neighbourhood"], "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold, Arial Unicode MS Bold", "text-max-size": 18, @@ -2159,7 +2159,7 @@ module.exports = { "filter": { "class": ["motorway", "main"], "$type": "line" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-padding": 2, "text-font": "Open Sans Regular, Arial Unicode MS Regular", @@ -2185,7 +2185,7 @@ module.exports = { "filter": { "class": ["street", "street_limited"], "$type": "line" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-padding": 2, "text-font": "Open Sans Regular, Arial Unicode MS Regular", @@ -2211,7 +2211,7 @@ module.exports = { "filter": { "class": ["service", "driveway", "path"], "$type": "line" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-padding": 2, "text-font": "Open Sans Regular, Arial Unicode MS Regular", @@ -2238,7 +2238,7 @@ module.exports = { "render": { "type": "text", "text-path": "curve", - "text-field": "{{ele}} m", + "text-field": "{ele} m", "text-font": "Open Sans Regular, Arial Unicode MS Regular", "text-max-size": 10, "text-max-angle": 0.5 @@ -2262,7 +2262,7 @@ module.exports = { "filter": { "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 12, @@ -2283,7 +2283,7 @@ module.exports = { "filter": { "$type": "line" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "curve", "text-font": "Open Sans Semibold Italic, Arial Unicode MS Bold", "text-max-size": 12, @@ -2305,7 +2305,7 @@ module.exports = { "filter": { "scalerank": [1, 2] }, "render": { "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style.night": {} @@ -2316,7 +2316,7 @@ module.exports = { "filter": { "scalerank": [1, 2], "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-padding": 2, "text-font": "Open Sans Semibold, Arial Unicode MS Bold", @@ -2343,7 +2343,7 @@ module.exports = { "filter": { "scalerank": 3 }, "render": { "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style": { @@ -2365,7 +2365,7 @@ module.exports = { "filter": { "scalerank": 3, "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-padding": 2, "text-font": "Open Sans Semibold, Arial Unicode MS Bold", @@ -2400,7 +2400,7 @@ module.exports = { "filter": { "scalerank": 4 }, "render": { "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style": { @@ -2422,7 +2422,7 @@ module.exports = { "filter": { "scalerank": 4, "$type": "point" }, "render": { "type": "text", - "text-field": "{{name_en}}", + "text-field": "{name_en}", "text-path": "horizontal", "text-padding": 2, "text-font": "Open Sans Semibold, Arial Unicode MS Bold", @@ -2457,7 +2457,7 @@ module.exports = { "filter": { "maki": "airport" }, "render": { "type": "icon", - "icon-image": "{{maki}}-12", + "icon-image": "{maki}-12", "icon-size": 12 }, "style": { diff --git a/include/llmr/style/value.hpp b/include/llmr/style/value.hpp index bdcba4cad..fac316d3d 100644 --- a/include/llmr/style/value.hpp +++ b/include/llmr/style/value.hpp @@ -10,12 +10,6 @@ typedef util::variant Value; std::string toString(const Value &value); -inline std::string& operator+=(std::string& out, const Value& value) { - out += toString(value); - return out; -} - - Value parseValue(pbf data); namespace util { diff --git a/include/llmr/util/token.hpp b/include/llmr/util/token.hpp index db5b5fa0c..6795b97d1 100644 --- a/include/llmr/util/token.hpp +++ b/include/llmr/util/token.hpp @@ -9,40 +9,43 @@ namespace regex_impl = boost; namespace regex_impl = std; #endif +#include + namespace llmr { namespace util { namespace detail { -const regex_impl::regex tokenRegex("\\{\\{(\\w+)\\}\\}"); +const regex_impl::regex tokenRegex("\\{(\\w+)\\}"); const regex_impl::sregex_token_iterator tokensEnd = regex_impl::sregex_token_iterator(); } -template -std::string replaceTokens(const std::string &source, const Tokens &tokens) { +template +std::string replaceTokens(const std::string &source, const Lookup &lookup) { std::string result; result.reserve(source.size()); bool token = false; for (auto token_it = regex_impl::sregex_token_iterator(source.begin(), source.end(), detail::tokenRegex, {-1, 1}); - token_it != detail::tokensEnd; ++token_it, token = !token) { + token_it != detail::tokensEnd; ++token_it, token = !token) { if (!token_it->matched) { continue; } - if (token) { - const auto it_prop = tokens.find(token_it->str()); - if (it_prop != tokens.end()) { - result += it_prop->second; - } - } else { - result += token_it->str(); - } + result += token ? lookup(token_it->str()) : token_it->str(); } return result; } +template +inline std::string replaceTokens(const std::string &source, const std::map &properties) { + return replaceTokens(source, [&properties](const std::string &token) -> std::string { + const auto it_prop = properties.find(token); + return it_prop != properties.end() ? toString(it_prop->second) : ""; + }); +} + } // end namespace util } // end namespace llmr diff --git a/src/map/source.cpp b/src/map/source.cpp index c3c5e89fd..8d1593f76 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ Source::Source(SourceType type, const std::string &url, std::string Source::normalizeSourceURL(const std::string &url) { const std::string t = "mapbox://"; if (url.compare(0, t.length(), t) == 0) { - return std::string("http://api.tiles.mapbox.com/v3/") + url.substr(t.length()) + "/%d/%d/%d.vector.pbf"; + return std::string("http://api.tiles.mapbox.com/v3/") + url.substr(t.length()) + "/{z}/{x}/{y}.vector.pbf"; } else { return url; } @@ -142,14 +143,17 @@ TileData::State Source::addTile(Map &map, const Tile::ID& id) { if (!new_tile.data) { // If we don't find working tile data, we're just going to load it. - - std::string formed_url; + const std::string formed_url = util::replaceTokens(url, [&](const std::string &token) -> std::string { + if (token == "z") return std::to_string(normalized_id.z); + if (token == "x") return std::to_string(normalized_id.x); + if (token == "y") return std::to_string(normalized_id.y); + if (token == "ratio") return (map.getState().getPixelRatio() > 1.0 ? "@2x" : ""); + return ""; + }); if (type == SourceType::Vector) { - formed_url = util::sprintf<256>(url, normalized_id.z, normalized_id.x, normalized_id.y); new_tile.data = std::make_shared(normalized_id, map, formed_url); } else if (type == SourceType::Raster) { - formed_url = util::sprintf<256>(url, normalized_id.z, normalized_id.x, normalized_id.y, (map.getState().getPixelRatio() > 1.0 ? "@2x" : "")); new_tile.data = std::make_shared(normalized_id, map, formed_url); } else { throw std::runtime_error("source type not implemented"); diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index b79010670..f83d81089 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -120,12 +120,11 @@ GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, Gl : future(promise.get_future().share()) { // Load the glyph set URL - - const std::map tokens {{ - { "fontstack", fontStack }, - { "range", std::to_string(glyphRange.first) + "-" + std::to_string(glyphRange.second) } - }}; - std::string url = util::replaceTokens(glyphURL, tokens); + std::string url = util::replaceTokens(glyphURL, [&](const std::string &name) -> std::string { + if (name == "fontstack") return fontStack; + if (name == "range") return std::to_string(glyphRange.first) + "-" + std::to_string(glyphRange.second); + return ""; + }); // TODO: Find more reliable URL normalization function std::replace(url.begin(), url.end(), ' ', '+'); diff --git a/test/fixtures/styles/0.style.json b/test/fixtures/styles/0.style.json index 06d7a1db1..d5994b82c 100644 --- a/test/fixtures/styles/0.style.json +++ b/test/fixtures/styles/0.style.json @@ -3,7 +3,7 @@ "sources": { "mapbox": { "type": "vector", - "url": "tiles/%d-%d-%d.vector.pbf", + "url": "tiles/{z}-{x}-{y}.vector.pbf", "tileSize": 512, "maxZoom": 14 } diff --git a/test/fixtures/styles/1.style.json b/test/fixtures/styles/1.style.json index d35c4bc0f..0d0286b27 100644 --- a/test/fixtures/styles/1.style.json +++ b/test/fixtures/styles/1.style.json @@ -3,7 +3,7 @@ "sources": { "mapbox": { "type": "vector", - "url": "tiles/%d-%d-%d.vector.pbf", + "url": "tiles/{z}-{x}-{y}.vector.pbf", "tileSize": 512, "maxZoom": 14 } From cd69784edb7031bb0de530d3779d3c6b1690ebb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 9 Jul 2014 16:54:27 -0700 Subject: [PATCH 2/2] switch to GeoJSON-style geometry type names refs https://github.com/mapbox/mapbox-gl-style-spec/pull/69 --- bin/style.js | 46 ++++++++++++------------ include/llmr/style/filter_expression.hpp | 2 +- src/map/vector_tile.cpp | 2 +- src/style/filter_expression.cpp | 14 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bin/style.js b/bin/style.js index c292a2692..46f6f5b2b 100644 --- a/bin/style.js +++ b/bin/style.js @@ -1736,7 +1736,7 @@ module.exports = { "id": "country_label", "source": "mapbox", "source-layer": "country_label", - "filter": { "$type": "point" }, + "filter": { "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -1761,7 +1761,7 @@ module.exports = { "id": "marine_label_line_1", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": 1 }, + "filter": { "$type": "LineString", "labelrank": 1 }, "render": { "type": "text", "text-field": "{name_en}", @@ -1791,7 +1791,7 @@ module.exports = { "id": "marine_label_line_2", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": 2 }, + "filter": { "$type": "LineString", "labelrank": 2 }, "render": { "type": "text", "text-field": "{name_en}", @@ -1820,7 +1820,7 @@ module.exports = { "id": "marine_label_line_3", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": 3 }, + "filter": { "$type": "LineString", "labelrank": 3 }, "render": { "type": "text", "text-field": "{name_en}", @@ -1849,7 +1849,7 @@ module.exports = { "id": "marine_label_line_other", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "line", "labelrank": [4, 5, 6] }, + "filter": { "$type": "LineString", "labelrank": [4, 5, 6] }, "render": { "type": "text", "text-field": "{name_en}", @@ -1878,7 +1878,7 @@ module.exports = { "id": "marine_label_point_1", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": 1 }, + "filter": { "$type": "Point", "labelrank": 1 }, "render": { "type": "text", "text-field": "{name_en}", @@ -1909,7 +1909,7 @@ module.exports = { "id": "marine_label_point_2", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": 2 }, + "filter": { "$type": "Point", "labelrank": 2 }, "render": { "type": "text", "text-field": "{name_en}", @@ -1940,7 +1940,7 @@ module.exports = { "id": "marine_label_point_3", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": 3 }, + "filter": { "$type": "Point", "labelrank": 3 }, "render": { "type": "text", "text-field": "{name_en}", @@ -1971,7 +1971,7 @@ module.exports = { "id": "marine_label_point_other", "source": "mapbox", "source-layer": "marine_label", - "filter": { "$type": "point", "labelrank": [4, 5, 6] }, + "filter": { "$type": "Point", "labelrank": [4, 5, 6] }, "render": { "type": "text", "text-field": "{name_en}", @@ -2002,7 +2002,7 @@ module.exports = { "id": "state_label", "source": "mapbox", "source-layer": "state_label", - "filter": { "$type": "point" }, + "filter": { "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2033,7 +2033,7 @@ module.exports = { "id": "place_label_city", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": "city", "$type": "point" }, + "filter": { "type": "city", "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2064,7 +2064,7 @@ module.exports = { "id": "place_label_town", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": "town", "$type": "point" }, + "filter": { "type": "town", "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2095,7 +2095,7 @@ module.exports = { "id": "place_label_village", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": "village", "$type": "point" }, + "filter": { "type": "village", "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2126,7 +2126,7 @@ module.exports = { "id": "place_label_other", "source": "mapbox", "source-layer": "place_label", - "filter": { "type": ["hamlet", "suburb", "neighbourhood"], "$type": "point" }, + "filter": { "type": ["hamlet", "suburb", "neighbourhood"], "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2156,7 +2156,7 @@ module.exports = { "id": "road_label_1", "source": "mapbox", "source-layer": "road_label", - "filter": { "class": ["motorway", "main"], "$type": "line" }, + "filter": { "class": ["motorway", "main"], "$type": "LineString" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2182,7 +2182,7 @@ module.exports = { "id": "road_label_2", "source": "mapbox", "source-layer": "road_label", - "filter": { "class": ["street", "street_limited"], "$type": "line" }, + "filter": { "class": ["street", "street_limited"], "$type": "LineString" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2208,7 +2208,7 @@ module.exports = { "id": "road_label_3", "source": "mapbox", "source-layer": "road_label", - "filter": { "class": ["service", "driveway", "path"], "$type": "line" }, + "filter": { "class": ["service", "driveway", "path"], "$type": "LineString" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2234,7 +2234,7 @@ module.exports = { "id": "contour_label", "source": "mapbox", "source-layer": "contour", - "filter": { "index": [5, 10], "$type": "line" }, + "filter": { "index": [5, 10], "$type": "LineString" }, "render": { "type": "text", "text-path": "curve", @@ -2259,7 +2259,7 @@ module.exports = { "id": "water_label", "source": "mapbox", "source-layer": "water_label", - "filter": { "$type": "point" }, + "filter": { "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2280,7 +2280,7 @@ module.exports = { "id": "waterway_label", "source": "mapbox", "source-layer": "waterway_label", - "filter": { "$type": "line" }, + "filter": { "$type": "LineString" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2313,7 +2313,7 @@ module.exports = { "id": "poi_label_1-2", "source": "mapbox", "source-layer": "poi_label", - "filter": { "scalerank": [1, 2], "$type": "point" }, + "filter": { "scalerank": [1, 2], "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2362,7 +2362,7 @@ module.exports = { "id": "poi_label_3", "source": "mapbox", "source-layer": "poi_label", - "filter": { "scalerank": 3, "$type": "point" }, + "filter": { "scalerank": 3, "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", @@ -2419,7 +2419,7 @@ module.exports = { "id": "poi_label_4", "source": "mapbox", "source-layer": "poi_label", - "filter": { "scalerank": 4, "$type": "point" }, + "filter": { "scalerank": 4, "$type": "Point" }, "render": { "type": "text", "text-field": "{name_en}", diff --git a/include/llmr/style/filter_expression.hpp b/include/llmr/style/filter_expression.hpp index 696aa04ae..5c7a400d8 100644 --- a/include/llmr/style/filter_expression.hpp +++ b/include/llmr/style/filter_expression.hpp @@ -85,7 +85,7 @@ public: enum class GeometryType : uint8_t { Any, Point, - Line, + LineString, Polygon }; diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index fb4272668..a32db7fb3 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -272,7 +272,7 @@ void FilteredVectorTileLayer::iterator::operator++() { } else if (feature_pbf.tag == 3) { // geometry type switch (FeatureType(feature_pbf.varint())) { case FeatureType::Point: extractor.setType(FilterExpression::GeometryType::Point); break; - case FeatureType::LineString: extractor.setType(FilterExpression::GeometryType::Line); break; + case FeatureType::LineString: extractor.setType(FilterExpression::GeometryType::LineString); break; case FeatureType::Polygon: extractor.setType(FilterExpression::GeometryType::Polygon); break; default: break; } diff --git a/src/style/filter_expression.cpp b/src/style/filter_expression.cpp index 1a85b742e..58483acca 100644 --- a/src/style/filter_expression.cpp +++ b/src/style/filter_expression.cpp @@ -175,10 +175,10 @@ std::ostream& operator <<(std::ostream &s, FilterExpression::Operator op) { std::ostream& operator <<(std::ostream &s, FilterExpression::GeometryType type) { switch (type) { - case FilterExpression::GeometryType::Point: s << "point"; break; - case FilterExpression::GeometryType::Line: s << "line"; break; - case FilterExpression::GeometryType::Polygon: s << "polygon"; break; - case FilterExpression::GeometryType::Any: s << "any"; break; + case FilterExpression::GeometryType::Point: s << "Point"; break; + case FilterExpression::GeometryType::LineString: s << "LineString"; break; + case FilterExpression::GeometryType::Polygon: s << "Polygon"; break; + case FilterExpression::GeometryType::Any: s << ""; break; } return s; } @@ -265,9 +265,9 @@ void FilterExpression::setGeometryType(GeometryType g) { } FilterExpression::GeometryType parseGeometryType(const std::string &geometry) { - if (geometry == "point") return FilterExpression::GeometryType::Point; - if (geometry == "line") return FilterExpression::GeometryType::Line; - if (geometry == "polygon") return FilterExpression::GeometryType::Polygon; + if (geometry == "Point") return FilterExpression::GeometryType::Point; + if (geometry == "LineString") return FilterExpression::GeometryType::LineString; + if (geometry == "Polygon") return FilterExpression::GeometryType::Polygon; return FilterExpression::GeometryType::Any; }