diff options
Diffstat (limited to 'src/mbgl/tile/geojson_tile_data.hpp')
-rw-r--r-- | src/mbgl/tile/geojson_tile_data.hpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mbgl/tile/geojson_tile_data.hpp b/src/mbgl/tile/geojson_tile_data.hpp index 3605af9690..21a65144d9 100644 --- a/src/mbgl/tile/geojson_tile_data.hpp +++ b/src/mbgl/tile/geojson_tile_data.hpp @@ -25,15 +25,17 @@ public: return feature.id; } - GeometryCollection getGeometries() const override { - GeometryCollection geometry = apply_visitor(ToGeometryCollection(), feature.geometry); - - // https://github.com/mapbox/geojson-vt-cpp/issues/44 - if (getType() == FeatureType::Polygon) { - geometry = fixupPolygons(geometry); + const GeometryCollection& getGeometries() const override { + if (!geometry) { + geometry = apply_visitor(ToGeometryCollection(), feature.geometry); + + // https://github.com/mapbox/geojson-vt-cpp/issues/44 + if (getType() == FeatureType::Polygon) { + geometry = fixupPolygons(*geometry); + } } - return geometry; + return *geometry; } optional<Value> getValue(const std::string& key) const override { @@ -43,6 +45,8 @@ public: } return optional<Value>(); } + + mutable optional<GeometryCollection> geometry; }; class GeoJSONTileLayer : public GeometryTileLayer { |