diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-08-22 15:55:37 +0200 |
---|---|---|
committer | tobrun <tobrun.van.nuland@gmail.com> | 2018-08-23 15:58:38 +0200 |
commit | 461cceb7ebbbcd6d2dda734ae845b1221254e28e (patch) | |
tree | 0a421437f74416e84f64221808baad7b411447da | |
parent | 38501130a775431218a75c6439ec92beee74e398 (diff) | |
download | qtlocation-mapboxgl-461cceb7ebbbcd6d2dda734ae845b1221254e28e.tar.gz |
[core] - expose getChildren, getLeaves, getClusterExpansionZoom on SuperclusterData
-rw-r--r-- | include/mbgl/style/sources/geojson_source.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 28 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.hpp | 6 |
4 files changed, 52 insertions, 1 deletions
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index a03b910279..36cc9bb4bb 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -33,9 +33,12 @@ public: void setURL(const std::string& url); void setGeoJSON(const GeoJSON&); - optional<std::string> getURL() const; + mapbox::geometry::feature_collection<double> getChildren(const std::uint32_t) const; + mapbox::geometry::feature_collection<double> getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) const; + std::uint8_t getClusterExpansionZoom(std::uint32_t) const; + class Impl; const Impl& impl() const; diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 4e3478322d..665cc9c0dc 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -40,6 +40,20 @@ optional<std::string> GeoJSONSource::getURL() const { return url; } +mapbox::geometry::feature_collection<double> GeoJSONSource::getChildren(const std::uint32_t cluster_id) const { + return impl().getData()->getChildren(cluster_id); +} + +mapbox::geometry::feature_collection<double> GeoJSONSource::getLeaves(const std::uint32_t cluster_id, + const std::uint32_t limit = 10, + const std::uint32_t offset = 0) const{ + return impl().getData()->getLeaves(cluster_id, limit, offset); +} + +std::uint8_t GeoJSONSource::getClusterExpansionZoom(std::uint32_t cluster_id) const { + return impl().getData()->getClusterExpansionZoom(cluster_id); +} + void GeoJSONSource::loadDescription(FileSource& fileSource) { if (!url) { loaded = true; diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 5ec3909d3e..fd7e6b50f6 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -21,6 +21,20 @@ public: return impl.getTile(tileID.z, tileID.x, tileID.y).features; } + mapbox::geometry::feature_collection<double> getChildren(const std::uint32_t) final { + return {}; + } + + mapbox::geometry::feature_collection<double> getLeaves(const std::uint32_t, + const std::uint32_t, + const std::uint32_t) final { + return {}; + } + + std::uint8_t getClusterExpansionZoom(std::uint32_t) final { + return 0; + } + private: mapbox::geojsonvt::GeoJSONVT impl; }; @@ -35,6 +49,20 @@ public: return impl.getTile(tileID.z, tileID.x, tileID.y); } + mapbox::geometry::feature_collection<double> getChildren(const std::uint32_t cluster_id) final { + return impl.getChildren(cluster_id); + } + + mapbox::geometry::feature_collection<double> getLeaves(const std::uint32_t cluster_id, + const std::uint32_t limit = 10, + const std::uint32_t offset = 0) final { + return impl.getLeaves(cluster_id, limit, offset); + } + + std::uint8_t getClusterExpansionZoom(std::uint32_t cluster_id) final { + return impl.getClusterExpansionZoom(cluster_id); + } + private: mapbox::supercluster::Supercluster impl; }; diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index a524bab9f2..f12e16ccb2 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -15,6 +15,12 @@ class GeoJSONData { public: virtual ~GeoJSONData() = default; virtual mapbox::geometry::feature_collection<int16_t> getTile(const CanonicalTileID&) = 0; + + // SuperclusterData + virtual mapbox::geometry::feature_collection<double> getChildren(const std::uint32_t) = 0; + virtual mapbox::geometry::feature_collection<double> getLeaves(const std::uint32_t, const std::uint32_t, + const std::uint32_t) = 0; + virtual std::uint8_t getClusterExpansionZoom(std::uint32_t) = 0; }; class GeoJSONSource::Impl : public Source::Impl { |