diff options
Diffstat (limited to 'src/mbgl/tile/geometry_tile_data.hpp')
-rw-r--r-- | src/mbgl/tile/geometry_tile_data.hpp | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp index 6ce67a532e..5d43a68388 100644 --- a/src/mbgl/tile/geometry_tile_data.hpp +++ b/src/mbgl/tile/geometry_tile_data.hpp @@ -35,6 +35,13 @@ public: GeometryCollection(Args&&... args) : std::vector<GeometryCoordinates>(std::forward<Args>(args)...) {} GeometryCollection(std::initializer_list<GeometryCoordinates> args) : std::vector<GeometryCoordinates>(std::move(args)) {} + GeometryCollection(GeometryCollection&&) = default; + GeometryCollection& operator=(GeometryCollection&&) = default; + + GeometryCollection clone() const { return GeometryCollection(*this); } + +private: + GeometryCollection(const GeometryCollection&) = default; }; class GeometryTileFeature { @@ -42,9 +49,9 @@ public: virtual ~GeometryTileFeature() = default; virtual FeatureType getType() const = 0; virtual optional<Value> getValue(const std::string& key) const = 0; - virtual PropertyMap getProperties() const { return PropertyMap(); } + virtual const PropertyMap& getProperties() const; virtual FeatureIdentifier getID() const { return NullValue {}; } - virtual GeometryCollection getGeometries() const = 0; + virtual const GeometryCollection& getGeometries() const; }; class GeometryTileLayer { @@ -90,31 +97,16 @@ struct ToGeometryCollection { 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 }; + return { geom }; } 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 }; + return { geom }; } 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)); + collection.emplace_back(ring); } return collection; } @@ -122,25 +114,15 @@ struct ToGeometryCollection { 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)); + collection.emplace_back(ring); } 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)); + for (const auto& polygon : geom) { + for (const auto& ring : polygon) { + collection.emplace_back(ring); } } return collection; |