summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-08-26 17:47:24 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-06 12:52:13 -0700
commit0afd14ae29e03f2781981180ddc42208e3da67c0 (patch)
tree8e585306bab3a02e2941490e8380e563c1ecd53a /src
parent1c51b43dafdcf74000290cbb09d7307253e683ab (diff)
downloadqtlocation-mapboxgl-0afd14ae29e03f2781981180ddc42208e3da67c0.tar.gz
[core] Eliminate use of util::ptr in GeometryTile* interfaces
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp4
-rw-r--r--src/mbgl/annotation/annotation_tile.cpp4
-rw-r--r--src/mbgl/annotation/annotation_tile.hpp8
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp6
-rw-r--r--src/mbgl/annotation/symbol_annotation_impl.cpp9
-rw-r--r--src/mbgl/tile/geojson_tile.cpp31
-rw-r--r--src/mbgl/tile/geometry_tile_data.hpp19
-rw-r--r--src/mbgl/tile/vector_tile.cpp23
8 files changed, 41 insertions, 63 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp
index f1ddf99602..fac494f223 100644
--- a/src/mbgl/annotation/annotation_manager.cpp
+++ b/src/mbgl/annotation/annotation_manager.cpp
@@ -124,9 +124,7 @@ std::unique_ptr<AnnotationTileData> AnnotationManager::getTileData(const Canonic
auto tileData = std::make_unique<AnnotationTileData>();
- AnnotationTileLayer& pointLayer = *tileData->layers.emplace(
- PointLayerID,
- std::make_unique<AnnotationTileLayer>(PointLayerID)).first->second;
+ AnnotationTileLayer& pointLayer = tileData->layers.emplace(PointLayerID, PointLayerID).first->second;
LatLngBounds tileBounds(tileID);
diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp
index 2c676420dd..6b225ce20b 100644
--- a/src/mbgl/annotation/annotation_tile.cpp
+++ b/src/mbgl/annotation/annotation_tile.cpp
@@ -40,10 +40,10 @@ optional<Value> AnnotationTileFeature::getValue(const std::string& key) const {
AnnotationTileLayer::AnnotationTileLayer(std::string name_)
: name(std::move(name_)) {}
-util::ptr<const GeometryTileLayer> AnnotationTileData::getLayer(const std::string& name) const {
+const GeometryTileLayer* AnnotationTileData::getLayer(const std::string& name) const {
auto it = layers.find(name);
if (it != layers.end()) {
- return it->second;
+ return &it->second;
}
return nullptr;
}
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp
index 78ed9e4080..19a731ee7b 100644
--- a/src/mbgl/annotation/annotation_tile.hpp
+++ b/src/mbgl/annotation/annotation_tile.hpp
@@ -45,10 +45,10 @@ public:
AnnotationTileLayer(std::string);
std::size_t featureCount() const override { return features.size(); }
- util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override { return features[i]; }
+ std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override { return std::make_unique<AnnotationTileFeature>(features[i]); }
std::string getName() const override { return name; };
- std::vector<util::ptr<const AnnotationTileFeature>> features;
+ std::vector<AnnotationTileFeature> features;
private:
std::string name;
@@ -56,9 +56,9 @@ private:
class AnnotationTileData : public GeometryTileData {
public:
- util::ptr<const GeometryTileLayer> getLayer(const std::string&) const override;
+ const GeometryTileLayer* getLayer(const std::string&) const override;
- std::unordered_map<std::string, util::ptr<AnnotationTileLayer>> layers;
+ std::unordered_map<std::string, AnnotationTileLayer> layers;
};
} // namespace mbgl
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index 345fe3acda..d3ddf62b9e 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -38,8 +38,7 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati
if (shapeTile.features.empty())
return;
- AnnotationTileLayer& layer = *data.layers.emplace(layerID,
- std::make_unique<AnnotationTileLayer>(layerID)).first->second;
+ AnnotationTileLayer& layer = data.layers.emplace(layerID, layerID).first->second;
ToGeometryCollection toGeometryCollection;
ToFeatureType toFeatureType;
@@ -54,8 +53,7 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati
renderGeometry = fixupPolygons(renderGeometry);
}
- layer.features.emplace_back(
- std::make_shared<AnnotationTileFeature>(id, featureType, renderGeometry));
+ layer.features.emplace_back(id, featureType, renderGeometry);
}
}
diff --git a/src/mbgl/annotation/symbol_annotation_impl.cpp b/src/mbgl/annotation/symbol_annotation_impl.cpp
index 20454e05c1..040de21214 100644
--- a/src/mbgl/annotation/symbol_annotation_impl.cpp
+++ b/src/mbgl/annotation/symbol_annotation_impl.cpp
@@ -30,11 +30,10 @@ void SymbolAnnotationImpl::updateLayer(const CanonicalTileID& tileID, Annotation
projected.y = std::fmod(projected.y, 1);
projected *= double(util::EXTENT);
- layer.features.emplace_back(
- std::make_shared<const AnnotationTileFeature>(id,
- FeatureType::Point,
- GeometryCollection {{ {{ convertPoint<int16_t>(projected) }} }},
- featureProperties));
+ layer.features.emplace_back(id,
+ FeatureType::Point,
+ GeometryCollection {{ {{ convertPoint<int16_t>(projected) }} }},
+ featureProperties);
}
} // namespace mbgl
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index 6dc4bd1499..bba347f39d 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -46,12 +46,17 @@ public:
}
};
-class GeoJSONTileLayer : public GeometryTileLayer {
+class GeoJSONTileData : public GeometryTileData,
+ public GeometryTileLayer {
public:
- const mapbox::geometry::feature_collection<int16_t>& features;
+ mapbox::geometry::feature_collection<int16_t> features;
+
+ GeoJSONTileData(mapbox::geometry::feature_collection<int16_t> features_)
+ : features(std::move(features_)) {
+ }
- GeoJSONTileLayer(const mapbox::geometry::feature_collection<int16_t>& features_)
- : features(features_) {
+ const GeometryTileLayer* getLayer(const std::string&) const override {
+ return this;
}
std::string getName() const override {
@@ -62,22 +67,8 @@ public:
return features.size();
}
- util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override {
- return std::make_shared<GeoJSONTileFeature>(features[i]);
- }
-};
-
-class GeoJSONTileData : public GeometryTileData {
-public:
- mapbox::geometry::feature_collection<int16_t> features;
-
- GeoJSONTileData(mapbox::geometry::feature_collection<int16_t> features_)
- : features(std::move(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 std::make_shared<GeoJSONTileLayer>(features);
+ std::unique_ptr<GeometryTileFeature> getFeature(std::size_t i) const override {
+ return std::make_unique<GeoJSONTileFeature>(features[i]);
}
};
diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp
index dcc8e66fcb..2714b139ed 100644
--- a/src/mbgl/tile/geometry_tile_data.hpp
+++ b/src/mbgl/tile/geometry_tile_data.hpp
@@ -2,19 +2,12 @@
#include <mbgl/util/geometry.hpp>
#include <mbgl/util/feature.hpp>
-#include <mbgl/util/chrono.hpp>
-#include <mbgl/util/ptr.hpp>
-#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/optional.hpp>
-#include <mbgl/util/variant.hpp>
-#include <mbgl/util/constants.hpp>
#include <cstdint>
#include <string>
#include <vector>
-#include <unordered_map>
-#include <functional>
-#include <iostream>
+#include <memory>
namespace mbgl {
@@ -37,7 +30,7 @@ public:
using std::vector<GeometryCoordinates>::vector;
};
-class GeometryTileFeature : private util::noncopyable {
+class GeometryTileFeature {
public:
virtual ~GeometryTileFeature() = default;
virtual FeatureType getType() const = 0;
@@ -47,18 +40,18 @@ public:
virtual GeometryCollection getGeometries() const = 0;
};
-class GeometryTileLayer : private util::noncopyable {
+class GeometryTileLayer {
public:
virtual ~GeometryTileLayer() = default;
virtual std::size_t featureCount() const = 0;
- virtual util::ptr<const GeometryTileFeature> getFeature(std::size_t) const = 0;
+ virtual std::unique_ptr<GeometryTileFeature> getFeature(std::size_t) const = 0;
virtual std::string getName() const = 0;
};
-class GeometryTileData : private util::noncopyable {
+class GeometryTileData {
public:
virtual ~GeometryTileData() = default;
- virtual util::ptr<const GeometryTileLayer> getLayer(const std::string&) const = 0;
+ virtual const GeometryTileLayer* getLayer(const std::string&) const = 0;
};
// classifies an array of rings into polygons with outer rings and holes
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index e96080ce8c..c388a60cbb 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -39,7 +39,7 @@ public:
VectorTileLayer(protozero::pbf_reader);
std::size_t featureCount() const override { return features.size(); }
- util::ptr<const GeometryTileFeature> getFeature(std::size_t) const override;
+ std::unique_ptr<GeometryTileFeature> getFeature(std::size_t) const override;
std::string getName() const override;
private:
@@ -59,12 +59,12 @@ class VectorTileData : public GeometryTileData {
public:
VectorTileData(std::shared_ptr<const std::string> data);
- util::ptr<const GeometryTileLayer> getLayer(const std::string&) const override;
+ const GeometryTileLayer* getLayer(const std::string&) const override;
private:
std::shared_ptr<const std::string> data;
mutable bool parsed = false;
- mutable std::map<std::string, util::ptr<GeometryTileLayer>> layers;
+ mutable std::map<std::string, VectorTileLayer> layers;
};
VectorTile::VectorTile(const OverscaledTileID& id_,
@@ -242,21 +242,20 @@ VectorTileData::VectorTileData(std::shared_ptr<const std::string> data_)
: data(std::move(data_)) {
}
-util::ptr<const GeometryTileLayer> VectorTileData::getLayer(const std::string& name) const {
+const GeometryTileLayer* VectorTileData::getLayer(const std::string& name) const {
if (!parsed) {
parsed = true;
protozero::pbf_reader tile_pbf(*data);
while (tile_pbf.next(3)) {
- util::ptr<VectorTileLayer> layer = std::make_shared<VectorTileLayer>(tile_pbf.get_message());
- layers.emplace(layer->name, layer);
+ VectorTileLayer layer(tile_pbf.get_message());
+ layers.emplace(layer.name, std::move(layer));
}
}
- auto layer_it = layers.find(name);
- if (layer_it != layers.end()) {
- return layer_it->second;
+ auto it = layers.find(name);
+ if (it != layers.end()) {
+ return &it->second;
}
-
return nullptr;
}
@@ -291,8 +290,8 @@ VectorTileLayer::VectorTileLayer(protozero::pbf_reader layer_pbf) {
}
}
-util::ptr<const GeometryTileFeature> VectorTileLayer::getFeature(std::size_t i) const {
- return std::make_shared<VectorTileFeature>(features.at(i), *this);
+std::unique_ptr<GeometryTileFeature> VectorTileLayer::getFeature(std::size_t i) const {
+ return std::make_unique<VectorTileFeature>(features.at(i), *this);
}
std::string VectorTileLayer::getName() const {