diff options
author | Young Hahn <young@mapbox.com> | 2016-07-06 17:29:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 17:29:34 -0400 |
commit | 71a3b1d0db170cfc1786be88c3e7b286c50dece9 (patch) | |
tree | 1d51cc28946dc990f8f613795417cb76ea8c00df /src/mbgl/tile/geojson_tile.cpp | |
parent | 903d609b40b6d0f4873f7bb46d96f4a06d7b17d6 (diff) | |
download | qtlocation-mapboxgl-71a3b1d0db170cfc1786be88c3e7b286c50dece9.tar.gz |
[core] geometry@0.8.0 / geojsonvt@6.0.0 (#5514)
* [core] geometry.hpp 0.8.0
* geojsonvt @ 6.0.0
* Update platform deps, build scripts
* Perf optimizations/cleanup
* Rebase in geometry@080
* D.R.Y. etc
* Ensure fill annotation geometries have closed rings.
* Optimizations
* Update to geojsonvt @ 6.1.0 for clean handoff between geojson parsing and geojsonvt
* Apply close multi/poly geoms for line annotations as well
Diffstat (limited to 'src/mbgl/tile/geojson_tile.cpp')
-rw-r--r-- | src/mbgl/tile/geojson_tile.cpp | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp index e2f8b69e4d..0dc4ac9107 100644 --- a/src/mbgl/tile/geojson_tile.cpp +++ b/src/mbgl/tile/geojson_tile.cpp @@ -11,16 +11,16 @@ namespace mbgl { class GeoJSONTileFeature : public GeometryTileFeature { public: - GeoJSONTileFeature(FeatureType, GeometryCollection&&, Feature::property_map&&); + GeoJSONTileFeature(FeatureType, GeometryCollection&&, PropertyMap&&); FeatureType getType() const override; optional<Value> getValue(const std::string&) const override; - Feature::property_map getProperties() const override { return properties; } + PropertyMap getProperties() const override { return properties; } GeometryCollection getGeometries() const override; private: const FeatureType type; const GeometryCollection geometries; - const Feature::property_map properties; + const PropertyMap properties; }; class GeoJSONTileLayer : public GeometryTileLayer { @@ -49,52 +49,28 @@ private: std::unique_ptr<GeoJSONTileData> convertTile(const mapbox::geojsonvt::Tile& tile) { std::shared_ptr<GeoJSONTileLayer> layer; - if (tile) { + if (!tile.features.empty()) { std::vector<std::shared_ptr<const GeoJSONTileFeature>> features; GeometryCoordinates line; + ToFeatureType toFeatureType; + ToGeometryCollection toGeometryCollection; + for (auto& feature : tile.features) { - const FeatureType featureType = - (feature.type == mapbox::geojsonvt::TileFeatureType::Point - ? FeatureType::Point - : (feature.type == mapbox::geojsonvt::TileFeatureType::LineString - ? FeatureType::LineString - : (feature.type == mapbox::geojsonvt::TileFeatureType::Polygon - ? FeatureType::Polygon - : FeatureType::Unknown))); + const FeatureType featureType = apply_visitor(toFeatureType, feature.geometry); + if (featureType == FeatureType::Unknown) { continue; } - GeometryCollection geometry; - - // Flatten the geometry; GeoJSONVT distinguishes between a Points array and Rings array - // (Points = GeoJSON types Point, MultiPoint, LineString) - // (Rings = GeoJSON types MultiLineString, Polygon, MultiPolygon) - // However, in Mapbox GL, we use one structure for both types, and just have one outer - // element for Points. - if (feature.tileGeometry.is<mapbox::geojsonvt::TilePoints>()) { - line.clear(); - for (auto& point : feature.tileGeometry.get<mapbox::geojsonvt::TilePoints>()) { - line.emplace_back(point.x, point.y); - } - geometry.emplace_back(std::move(line)); - } else if (feature.tileGeometry.is<mapbox::geojsonvt::TileRings>()) { - for (auto& ring : feature.tileGeometry.get<mapbox::geojsonvt::TileRings>()) { - line.clear(); - for (auto& point : ring) { - line.emplace_back(point.x, point.y); - } - geometry.emplace_back(std::move(line)); - } - } + GeometryCollection geometry = apply_visitor(toGeometryCollection, feature.geometry); // https://github.com/mapbox/geojson-vt-cpp/issues/44 if (featureType == FeatureType::Polygon) { geometry = fixupPolygons(geometry); } - Feature::property_map properties{ feature.tags.begin(), feature.tags.end() }; + PropertyMap properties = feature.properties; features.emplace_back(std::make_shared<GeoJSONTileFeature>( featureType, std::move(geometry), std::move(properties))); @@ -118,7 +94,7 @@ void GeoJSONTile::setNecessity(Necessity) {} GeoJSONTileFeature::GeoJSONTileFeature(FeatureType type_, GeometryCollection&& geometries_, - Feature::property_map&& properties_) + PropertyMap&& properties_) : type(type_), geometries(std::move(geometries_)), properties(std::move(properties_)) { } |