[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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user