summaryrefslogtreecommitdiff
path: root/src/mbgl/tile
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-09-28 10:21:19 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-09-28 15:47:21 -0700
commita323b0dcec65056f04d994bda8fd3ee475d1639f (patch)
treefb1899f1d0d1878abde2151979a31e8180042c69 /src/mbgl/tile
parent068ed9496cd146efdb17093d42fadfe55274deef (diff)
downloadqtlocation-mapboxgl-a323b0dcec65056f04d994bda8fd3ee475d1639f.tar.gz
[core] Split GeoJSONTileData and related classes into a separate header
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r--src/mbgl/tile/geojson_tile.cpp95
-rw-r--r--src/mbgl/tile/geojson_tile_data.hpp94
2 files changed, 95 insertions, 94 deletions
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index 5d8339d775..ee4989462c 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -1,104 +1,11 @@
#include <mbgl/tile/geojson_tile.hpp>
-#include <mbgl/tile/geometry_tile_data.hpp>
+#include <mbgl/tile/geojson_tile_data.hpp>
#include <mbgl/renderer/query.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
#include <mbgl/style/filter_evaluator.hpp>
-#include <mbgl/util/string.hpp>
-
-#include <mapbox/geojsonvt.hpp>
-#include <supercluster.hpp>
namespace mbgl {
-// Implements a simple in-memory Tile type that holds GeoJSON values. A GeoJSON tile can only have
-// one layer, and it is always returned regardless of which layer is requested.
-
-class GeoJSONTileFeature : public GeometryTileFeature {
-public:
- const mapbox::geometry::feature<int16_t>& feature;
-
- GeoJSONTileFeature(const mapbox::geometry::feature<int16_t>& feature_)
- : feature(feature_) {
- }
-
- FeatureType getType() const override {
- return apply_visitor(ToFeatureType(), feature.geometry);
- }
-
- PropertyMap getProperties() const override {
- return feature.properties;
- }
-
- optional<FeatureIdentifier> getID() const override {
- 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);
- }
-
- return geometry;
- }
-
- optional<Value> getValue(const std::string& key) const override {
- auto it = feature.properties.find(key);
- if (it != feature.properties.end()) {
- return optional<Value>(it->second);
- }
- return optional<Value>();
- }
-};
-
-class GeoJSONTileLayer : public GeometryTileLayer {
-public:
- GeoJSONTileLayer(std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features_)
- : features(std::move(features_)) {
- }
-
- std::size_t featureCount() const override {
- return features->size();
- }
-
- std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override {
- return std::make_unique<GeoJSONTileFeature>((*features)[i]);
- }
-
- std::string getName() const override {
- return "";
- }
-
-private:
- std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features;
-};
-
-class GeoJSONTileData : public GeometryTileData {
-public:
- GeoJSONTileData(mapbox::geometry::feature_collection<int16_t> features_)
- : features(std::make_shared<mapbox::geometry::feature_collection<int16_t>>(
- std::move(features_))) {
- }
-
- GeoJSONTileData(std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features_)
- : features(std::move(features_)) {
- }
-
- std::unique_ptr<GeometryTileData> clone() const override {
- return std::make_unique<GeoJSONTileData>(features);
- }
-
- std::unique_ptr<GeometryTileLayer> getLayer(const std::string&) const override {
- return std::make_unique<GeoJSONTileLayer>(features);
- }
-
-
-private:
- std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features;
-};
-
GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
std::string sourceID_,
const TileParameters& parameters,
diff --git a/src/mbgl/tile/geojson_tile_data.hpp b/src/mbgl/tile/geojson_tile_data.hpp
new file mode 100644
index 0000000000..3402c2a009
--- /dev/null
+++ b/src/mbgl/tile/geojson_tile_data.hpp
@@ -0,0 +1,94 @@
+#include <mbgl/tile/geometry_tile_data.hpp>
+
+namespace mbgl {
+
+// Implements a simple in-memory Tile type that holds GeoJSON values. A GeoJSON tile can only have
+// one layer, and it is always returned regardless of which layer is requested.
+
+class GeoJSONTileFeature : public GeometryTileFeature {
+public:
+ const mapbox::geometry::feature<int16_t>& feature;
+
+ GeoJSONTileFeature(const mapbox::geometry::feature<int16_t>& feature_)
+ : feature(feature_) {
+ }
+
+ FeatureType getType() const override {
+ return apply_visitor(ToFeatureType(), feature.geometry);
+ }
+
+ PropertyMap getProperties() const override {
+ return feature.properties;
+ }
+
+ optional<FeatureIdentifier> getID() const override {
+ 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);
+ }
+
+ return geometry;
+ }
+
+ optional<Value> getValue(const std::string& key) const override {
+ auto it = feature.properties.find(key);
+ if (it != feature.properties.end()) {
+ return optional<Value>(it->second);
+ }
+ return optional<Value>();
+ }
+};
+
+class GeoJSONTileLayer : public GeometryTileLayer {
+public:
+ GeoJSONTileLayer(std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features_)
+ : features(std::move(features_)) {
+ }
+
+ std::size_t featureCount() const override {
+ return features->size();
+ }
+
+ std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override {
+ return std::make_unique<GeoJSONTileFeature>((*features)[i]);
+ }
+
+ std::string getName() const override {
+ return "";
+ }
+
+private:
+ std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features;
+};
+
+class GeoJSONTileData : public GeometryTileData {
+public:
+ GeoJSONTileData(mapbox::geometry::feature_collection<int16_t> features_)
+ : features(std::make_shared<mapbox::geometry::feature_collection<int16_t>>(
+ std::move(features_))) {
+ }
+
+ GeoJSONTileData(std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features_)
+ : features(std::move(features_)) {
+ }
+
+ std::unique_ptr<GeometryTileData> clone() const override {
+ return std::make_unique<GeoJSONTileData>(features);
+ }
+
+ std::unique_ptr<GeometryTileLayer> getLayer(const std::string&) const override {
+ return std::make_unique<GeoJSONTileLayer>(features);
+ }
+
+
+private:
+ std::shared_ptr<const mapbox::geometry::feature_collection<int16_t>> features;
+};
+
+} // namespace mbgl