diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-02-22 01:06:21 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-01 20:58:54 +0000 |
commit | 9771b0e569d91c37ab3ac98ef8bee11c816ddc80 (patch) | |
tree | 948bf1c460c865e8403751cd340fac6a9464cd06 | |
parent | fcaafcc428f932e36e195e6801855344798ca33e (diff) | |
download | qtlocation-mapboxgl-9771b0e569d91c37ab3ac98ef8bee11c816ddc80.tar.gz |
[core] Use GeometryTileFeature::defaultExtent by default
GeoJSONTile and AnnotationTile don't need to reimplement getExtent() if
they use the same default value. This also helps point and shape
annotations to avoid using raw values.
-rw-r--r-- | src/mbgl/annotation/annotation_tile.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/annotation/point_annotation_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/annotation/shape_annotation_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/tile/geojson_tile.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 4 |
5 files changed, 5 insertions, 7 deletions
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp index b2d98c6a3b..8d0804d7f9 100644 --- a/src/mbgl/annotation/annotation_tile.hpp +++ b/src/mbgl/annotation/annotation_tile.hpp @@ -17,7 +17,6 @@ public: FeatureType getType() const override { return type; } optional<Value> getValue(const std::string&) const override; GeometryCollection getGeometries() const override { return geometries; } - uint32_t getExtent() const override { return 4096; } const FeatureType type; const std::unordered_map<std::string, std::string> properties; diff --git a/src/mbgl/annotation/point_annotation_impl.cpp b/src/mbgl/annotation/point_annotation_impl.cpp index 10e65e4c07..b0bce8c308 100644 --- a/src/mbgl/annotation/point_annotation_impl.cpp +++ b/src/mbgl/annotation/point_annotation_impl.cpp @@ -12,12 +12,11 @@ void PointAnnotationImpl::updateLayer(const TileID& tileID, AnnotationTileLayer& std::unordered_map<std::string, std::string> featureProperties; featureProperties.emplace("sprite", point.icon.empty() ? std::string("default_marker") : point.icon); - const uint16_t extent = 4096; const mbgl::ScreenCoordinate pp = point.position.project(); const uint32_t z2 = 1 << tileID.z; const uint32_t x = pp.x * z2; const uint32_t y = pp.y * z2; - const GeometryCoordinate coordinate(extent * (pp.x * z2 - x), extent * (pp.y * z2 - y)); + const GeometryCoordinate coordinate(GeometryTileFeature::defaultExtent * (pp.x * z2 - x), GeometryTileFeature::defaultExtent * (pp.y * z2 - y)); layer.features.emplace_back( std::make_shared<const AnnotationTileFeature>(FeatureType::Point, diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index c8b31ef11f..a9277ee0a7 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -81,11 +81,10 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) { static const double baseTolerance = 4; - static const uint16_t extent = 4096; if (!shapeTiler) { const uint64_t maxAmountOfTiles = 1 << maxZoom; - const double tolerance = baseTolerance / (maxAmountOfTiles * extent); + const double tolerance = baseTolerance / (maxAmountOfTiles * GeometryTileFeature::defaultExtent); geojsonvt::ProjectedRings rings; std::vector<geojsonvt::LonLat> points; diff --git a/src/mbgl/tile/geojson_tile.hpp b/src/mbgl/tile/geojson_tile.hpp index 6f3cbc10d1..ce9c643de2 100644 --- a/src/mbgl/tile/geojson_tile.hpp +++ b/src/mbgl/tile/geojson_tile.hpp @@ -25,7 +25,6 @@ public: FeatureType getType() const override; optional<Value> getValue(const std::string&) const override; GeometryCollection getGeometries() const override; - uint32_t getExtent() const override { return 4096; } private: const FeatureType type; diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index 13333dab53..3fcb910371 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -31,11 +31,13 @@ using GeometryCollection = std::vector<GeometryCoordinates>; class GeometryTileFeature : private util::noncopyable { public: + static const uint32_t defaultExtent = 4096; + virtual ~GeometryTileFeature() = default; virtual FeatureType getType() const = 0; virtual optional<Value> getValue(const std::string& key) const = 0; virtual GeometryCollection getGeometries() const = 0; - virtual uint32_t getExtent() const = 0; + virtual uint32_t getExtent() const { return defaultExtent; } }; class GeometryTileLayer : private util::noncopyable { |