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/geometry_tile_data.hpp | |
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/geometry_tile_data.hpp')
-rw-r--r-- | src/mbgl/tile/geometry_tile_data.hpp | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp index 1dc22e0c55..4055a80ecf 100644 --- a/src/mbgl/tile/geometry_tile_data.hpp +++ b/src/mbgl/tile/geometry_tile_data.hpp @@ -14,6 +14,7 @@ #include <vector> #include <unordered_map> #include <functional> +#include <iostream> namespace mbgl { @@ -41,8 +42,8 @@ public: virtual ~GeometryTileFeature() = default; virtual FeatureType getType() const = 0; virtual optional<Value> getValue(const std::string& key) const = 0; - virtual Feature::property_map getProperties() const { return Feature::property_map(); } - virtual optional<uint64_t> getID() const { return {}; } + virtual PropertyMap getProperties() const { return PropertyMap(); } + virtual optional<FeatureIdentifier> getID() const { return {}; } virtual GeometryCollection getGeometries() const = 0; }; @@ -73,4 +74,70 @@ Feature convertFeature(const GeometryTileFeature&, const CanonicalTileID&); // The result is guaranteed to have correctly wound, strictly simple rings. GeometryCollection fixupPolygons(const GeometryCollection&); +struct ToGeometryCollection { + GeometryCollection operator()(const mapbox::geometry::point<int16_t>& geom) const { + return { { geom } }; + } + GeometryCollection operator()(const mapbox::geometry::multi_point<int16_t>& geom) const { + GeometryCoordinates coordinates; + coordinates.reserve(geom.size()); + for (const auto& point : geom) { + coordinates.emplace_back(point); + } + return { coordinates }; + } + GeometryCollection operator()(const mapbox::geometry::line_string<int16_t>& geom) const { + GeometryCoordinates coordinates; + coordinates.reserve(geom.size()); + for (const auto& point : geom) { + coordinates.emplace_back(point); + } + return { coordinates }; + } + GeometryCollection operator()(const mapbox::geometry::multi_line_string<int16_t>& geom) const { + GeometryCollection collection; + collection.reserve(geom.size()); + for (const auto& ring : geom) { + GeometryCoordinates coordinates; + coordinates.reserve(ring.size()); + for (const auto& point : ring) { + coordinates.emplace_back(point); + } + collection.push_back(std::move(coordinates)); + } + return collection; + } + GeometryCollection operator()(const mapbox::geometry::polygon<int16_t>& geom) const { + GeometryCollection collection; + collection.reserve(geom.size()); + for (const auto& ring : geom) { + GeometryCoordinates coordinates; + coordinates.reserve(ring.size()); + for (const auto& point : ring) { + coordinates.emplace_back(point); + } + collection.push_back(std::move(coordinates)); + } + return collection; + } + GeometryCollection operator()(const mapbox::geometry::multi_polygon<int16_t>& geom) const { + GeometryCollection collection; + for (auto& polygon : geom) { + for (auto& ring : polygon) { + GeometryCoordinates coordinates; + coordinates.reserve(ring.size()); + for (auto& point : ring) { + coordinates.emplace_back(point); + } + collection.push_back(std::move(coordinates)); + } + } + return collection; + } + GeometryCollection operator()(const mapbox::geometry::geometry_collection<int16_t>&) const { + GeometryCollection collection; + return collection; + } +}; + } // namespace mbgl |