summaryrefslogtreecommitdiff
path: root/src/mbgl/tile
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-08-25 17:54:02 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-08-26 10:30:55 -0700
commitf07f59207825206172ac8aa46a74ea797d287ce7 (patch)
tree40db24112c08adc271719291941cd7fafdf980f6 /src/mbgl/tile
parentd2abb1b6d5cc129acaadab15152ae286b989d9ba (diff)
downloadqtlocation-mapboxgl-f07f59207825206172ac8aa46a74ea797d287ce7.tar.gz
[core] Simplify GeoJSONTile constructor
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r--src/mbgl/tile/geojson_tile.cpp53
-rw-r--r--src/mbgl/tile/geojson_tile.hpp20
2 files changed, 22 insertions, 51 deletions
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index a510b74dad..1aff959168 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -63,51 +63,38 @@ class GeoJSONTileData : public GeometryTileData {
public:
std::shared_ptr<GeoJSONTileLayer> layer = std::make_shared<GeoJSONTileLayer>();
- util::ptr<const GeometryTileLayer> getLayer(const std::string&) const override {
- // We're ignoring the layer name because GeoJSON tiles only have one layer.
- return layer;
- }
-};
+ GeoJSONTileData(const mapbox::geometry::feature_collection<int16_t>& features) {
+ for (auto& feature : features) {
+ const FeatureType featureType = apply_visitor(ToFeatureType(), feature.geometry);
-// Converts the geojsonvt::Tile to a a GeoJSONTile. They have a differing internal structure.
-std::unique_ptr<GeoJSONTileData> convertTile(const mapbox::geometry::feature_collection<int16_t>& features) {
- auto result = std::make_unique<GeoJSONTileData>();
+ if (featureType == FeatureType::Unknown) {
+ continue;
+ }
- for (auto& feature : features) {
- const FeatureType featureType = apply_visitor(ToFeatureType(), feature.geometry);
+ GeometryCollection geometry = apply_visitor(ToGeometryCollection(), feature.geometry);
- if (featureType == FeatureType::Unknown) {
- continue;
- }
-
- GeometryCollection geometry = apply_visitor(ToGeometryCollection(), feature.geometry);
+ // https://github.com/mapbox/geojson-vt-cpp/issues/44
+ if (featureType == FeatureType::Polygon) {
+ geometry = fixupPolygons(geometry);
+ }
- // https://github.com/mapbox/geojson-vt-cpp/issues/44
- if (featureType == FeatureType::Polygon) {
- geometry = fixupPolygons(geometry);
+ layer->features.emplace_back(std::make_shared<GeoJSONTileFeature>(
+ featureType, std::move(geometry), PropertyMap(feature.properties)));
}
-
- result->layer->features.emplace_back(std::make_shared<GeoJSONTileFeature>(
- featureType, std::move(geometry), PropertyMap(feature.properties)));
}
- return result;
-}
-
-GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
- std::string sourceID_,
- 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).features));
-}
+ util::ptr<const GeometryTileLayer> getLayer(const std::string&) const override {
+ // We're ignoring the layer name because GeoJSON tiles only have one layer.
+ return layer;
+ }
+};
GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
std::string sourceID_,
const style::UpdateParameters& parameters,
- mapbox::supercluster::Supercluster& supercluster)
+ const mapbox::geometry::feature_collection<int16_t>& features)
: GeometryTile(overscaledTileID, sourceID_, parameters.style, parameters.mode) {
- setData(convertTile(supercluster.getTile(id.canonical.z, id.canonical.x, id.canonical.y)));
+ setData(std::make_unique<GeoJSONTileData>(features));
}
void GeoJSONTile::setNecessity(Necessity) {}
diff --git a/src/mbgl/tile/geojson_tile.hpp b/src/mbgl/tile/geojson_tile.hpp
index 422101b767..be5a50c7a4 100644
--- a/src/mbgl/tile/geojson_tile.hpp
+++ b/src/mbgl/tile/geojson_tile.hpp
@@ -1,18 +1,7 @@
#pragma once
#include <mbgl/tile/geometry_tile.hpp>
-
-namespace mapbox {
-
-namespace geojsonvt {
-class GeoJSONVT;
-} // namespace geojsonvt
-
-namespace supercluster {
-class Supercluster;
-} // namespace supercluster
-
-} // namespace mapbox
+#include <mbgl/util/feature.hpp>
namespace mbgl {
@@ -25,12 +14,7 @@ public:
GeoJSONTile(const OverscaledTileID&,
std::string sourceID,
const style::UpdateParameters&,
- mapbox::geojsonvt::GeoJSONVT&);
-
- GeoJSONTile(const OverscaledTileID&,
- std::string sourceID,
- const style::UpdateParameters&,
- mapbox::supercluster::Supercluster&);
+ const mapbox::geometry::feature_collection<int16_t>&);
void setNecessity(Necessity) final;
};