From 71a3b1d0db170cfc1786be88c3e7b286c50dece9 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Wed, 6 Jul 2016 17:29:34 -0400 Subject: [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 --- src/mbgl/tile/geojson_tile.cpp | 48 +++++++++++------------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) (limited to 'src/mbgl/tile/geojson_tile.cpp') 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 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 convertTile(const mapbox::geojsonvt::Tile& tile) { std::shared_ptr layer; - if (tile) { + if (!tile.features.empty()) { std::vector> 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()) { - line.clear(); - for (auto& point : feature.tileGeometry.get()) { - line.emplace_back(point.x, point.y); - } - geometry.emplace_back(std::move(line)); - } else if (feature.tileGeometry.is()) { - for (auto& ring : feature.tileGeometry.get()) { - 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( 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_)) { } -- cgit v1.2.1