summaryrefslogtreecommitdiff
path: root/src/mbgl/tile
diff options
context:
space:
mode:
authorVladimir Agafonkin <agafonkin@gmail.com>2016-07-27 20:18:41 +0300
committerGitHub <noreply@github.com>2016-07-27 20:18:41 +0300
commit9ecc0d95979ca2fa3154f4b47c8f9fa4717fe696 (patch)
treeb5e09683505cec994e3198a92cd8863d54979e3e /src/mbgl/tile
parent6edaf2dc81ab771d1da27c939b19502753aa895f (diff)
downloadqtlocation-mapboxgl-9ecc0d95979ca2fa3154f4b47c8f9fa4717fe696.tar.gz
GeoJSON point clustering (#5724)
* add supercluster dependency * prepare GeoJSONTile for Supercluster * prepare GeoJSONSource for accepting options * try removing mbgl::GeoJSON * fix setGeoJSON types * add GeoJSONSource getURL * add geojson to include path * add Supercluster index in GeoJSONSource * fix GeoJSONSource getZoomRange * bring back mbgl::GeoJSON header * fix tidy warnings hopefully * try test-suite with enabled cluster test * fix formatting in clustering-related files
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r--src/mbgl/tile/geojson_tile.cpp24
-rw-r--r--src/mbgl/tile/geojson_tile.hpp11
2 files changed, 27 insertions, 8 deletions
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index 0dc4ac9107..ab596bd9ba 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -3,6 +3,7 @@
#include <mbgl/style/update_parameters.hpp>
#include <mapbox/geojsonvt.hpp>
+#include <supercluster.hpp>
namespace mbgl {
@@ -46,17 +47,16 @@ private:
};
// Converts the geojsonvt::Tile to a a GeoJSONTile. They have a differing internal structure.
-std::unique_ptr<GeoJSONTileData> convertTile(const mapbox::geojsonvt::Tile& tile) {
+std::unique_ptr<GeoJSONTileData> convertTile(const mapbox::geometry::feature_collection<int16_t>& features) {
std::shared_ptr<GeoJSONTileLayer> layer;
- if (!tile.features.empty()) {
- std::vector<std::shared_ptr<const GeoJSONTileFeature>> features;
- GeometryCoordinates line;
+ if (!features.empty()) {
+ std::vector<std::shared_ptr<const GeoJSONTileFeature>> convertedFeatures;
ToFeatureType toFeatureType;
ToGeometryCollection toGeometryCollection;
- for (auto& feature : tile.features) {
+ for (auto& feature : features) {
const FeatureType featureType = apply_visitor(toFeatureType, feature.geometry);
if (featureType == FeatureType::Unknown) {
@@ -72,11 +72,11 @@ std::unique_ptr<GeoJSONTileData> convertTile(const mapbox::geojsonvt::Tile& tile
PropertyMap properties = feature.properties;
- features.emplace_back(std::make_shared<GeoJSONTileFeature>(
+ convertedFeatures.emplace_back(std::make_shared<GeoJSONTileFeature>(
featureType, std::move(geometry), std::move(properties)));
}
- layer = std::make_unique<GeoJSONTileLayer>(std::move(features));
+ layer = std::make_unique<GeoJSONTileLayer>(std::move(convertedFeatures));
}
return std::make_unique<GeoJSONTileData>(layer);
@@ -87,7 +87,15 @@ GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
const style::UpdateParameters& parameters,
mapbox::geojsonvt::GeoJSONVT& geojsonvt)
: GeometryTile(overscaledTileID, sourceID_, parameters.style, parameters.mode) {
- setData(convertTile(geojsonvt.getTile(id.canonical.z, id.canonical.x, id.canonical.y)));
+ setData(convertTile(geojsonvt.getTile(id.canonical.z, id.canonical.x, id.canonical.y).features));
+}
+
+GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
+ std::string sourceID_,
+ const style::UpdateParameters& parameters,
+ mapbox::supercluster::Supercluster& supercluster)
+ : GeometryTile(overscaledTileID, sourceID_, parameters.style, parameters.mode) {
+ setData(convertTile(supercluster.getTile(id.canonical.z, id.canonical.x, id.canonical.y)));
}
void GeoJSONTile::setNecessity(Necessity) {}
diff --git a/src/mbgl/tile/geojson_tile.hpp b/src/mbgl/tile/geojson_tile.hpp
index 09fdd1ec9b..422101b767 100644
--- a/src/mbgl/tile/geojson_tile.hpp
+++ b/src/mbgl/tile/geojson_tile.hpp
@@ -3,9 +3,15 @@
#include <mbgl/tile/geometry_tile.hpp>
namespace mapbox {
+
namespace geojsonvt {
class GeoJSONVT;
} // namespace geojsonvt
+
+namespace supercluster {
+class Supercluster;
+} // namespace supercluster
+
} // namespace mapbox
namespace mbgl {
@@ -21,6 +27,11 @@ public:
const style::UpdateParameters&,
mapbox::geojsonvt::GeoJSONVT&);
+ GeoJSONTile(const OverscaledTileID&,
+ std::string sourceID,
+ const style::UpdateParameters&,
+ mapbox::supercluster::Supercluster&);
+
void setNecessity(Necessity) final;
};