summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/annotation/annotation.hpp14
-rw-r--r--src/mbgl/annotation/fill_annotation_impl.cpp2
-rw-r--r--src/mbgl/annotation/fill_annotation_impl.hpp2
-rw-r--r--src/mbgl/annotation/line_annotation_impl.cpp2
-rw-r--r--src/mbgl/annotation/line_annotation_impl.hpp2
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp14
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.hpp2
-rw-r--r--src/mbgl/annotation/style_sourced_annotation_impl.cpp2
-rw-r--r--src/mbgl/annotation/style_sourced_annotation_impl.hpp2
-rw-r--r--src/mbgl/annotation/symbol_annotation_impl.cpp5
-rw-r--r--src/mbgl/annotation/symbol_annotation_impl.hpp2
11 files changed, 20 insertions, 29 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp
index 3b2b7f3ade..8b0c3026a8 100644
--- a/include/mbgl/annotation/annotation.hpp
+++ b/include/mbgl/annotation/annotation.hpp
@@ -16,13 +16,19 @@ using AnnotationIDs = std::vector<AnnotationID>;
class SymbolAnnotation {
public:
- Geometry<double> geometry;
+ Point<double> geometry;
std::string icon;
};
+using ShapeAnnotationGeometry = variant<
+ LineString<double>,
+ Polygon<double>,
+ MultiLineString<double>,
+ MultiPolygon<double>>;
+
class LineAnnotation {
public:
- Geometry<double> geometry;
+ ShapeAnnotationGeometry geometry;
float opacity = 1;
float width = 1;
Color color = {{ 0, 0, 0, 1 }};
@@ -30,7 +36,7 @@ public:
class FillAnnotation {
public:
- Geometry<double> geometry;
+ ShapeAnnotationGeometry geometry;
float opacity = 1;
Color color = {{ 0, 0, 0, 1 }};
Color outlineColor = {{ 0, 0, 0, -1 }};
@@ -39,7 +45,7 @@ public:
// An annotation whose type and properties are sourced from a style layer.
class StyleSourcedAnnotation {
public:
- Geometry<double> geometry;
+ ShapeAnnotationGeometry geometry;
std::string layerID;
};
diff --git a/src/mbgl/annotation/fill_annotation_impl.cpp b/src/mbgl/annotation/fill_annotation_impl.cpp
index 2555f90439..093f53fb91 100644
--- a/src/mbgl/annotation/fill_annotation_impl.cpp
+++ b/src/mbgl/annotation/fill_annotation_impl.cpp
@@ -29,7 +29,7 @@ void FillAnnotationImpl::updateStyle(Style& style) const {
style.addLayer(std::move(layer), AnnotationManager::PointLayerID);
}
-const Geometry<double>& FillAnnotationImpl::geometry() const {
+const ShapeAnnotationGeometry& FillAnnotationImpl::geometry() const {
return annotation.geometry;
}
diff --git a/src/mbgl/annotation/fill_annotation_impl.hpp b/src/mbgl/annotation/fill_annotation_impl.hpp
index 1d98505c43..c396499e38 100644
--- a/src/mbgl/annotation/fill_annotation_impl.hpp
+++ b/src/mbgl/annotation/fill_annotation_impl.hpp
@@ -10,7 +10,7 @@ public:
FillAnnotationImpl(const AnnotationID, const FillAnnotation&, const uint8_t maxZoom);
void updateStyle(Style&) const final;
- const Geometry<double>& geometry() const final;
+ const ShapeAnnotationGeometry& geometry() const final;
private:
const FillAnnotation annotation;
diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp
index e22c36bcbe..5bcc142a5b 100644
--- a/src/mbgl/annotation/line_annotation_impl.cpp
+++ b/src/mbgl/annotation/line_annotation_impl.cpp
@@ -30,7 +30,7 @@ void LineAnnotationImpl::updateStyle(Style& style) const {
style.addLayer(std::move(layer), AnnotationManager::PointLayerID);
}
-const Geometry<double>& LineAnnotationImpl::geometry() const {
+const ShapeAnnotationGeometry& LineAnnotationImpl::geometry() const {
return annotation.geometry;
}
diff --git a/src/mbgl/annotation/line_annotation_impl.hpp b/src/mbgl/annotation/line_annotation_impl.hpp
index 05a79fc0c3..05d650c051 100644
--- a/src/mbgl/annotation/line_annotation_impl.hpp
+++ b/src/mbgl/annotation/line_annotation_impl.hpp
@@ -10,7 +10,7 @@ public:
LineAnnotationImpl(const AnnotationID, const LineAnnotation&, const uint8_t maxZoom);
void updateStyle(Style&) const final;
- const Geometry<double>& geometry() const final;
+ const ShapeAnnotationGeometry& geometry() const final;
private:
const LineAnnotation annotation;
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index a5116be72f..a2dc4c8093 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -57,18 +57,6 @@ struct ToGeoJSONVT {
return convertFeature(geojsonvt::ProjectedFeatureType::Polygon, converted);
}
- geojsonvt::ProjectedFeature operator()(const Point<double>&) {
- throw std::runtime_error("unsupported shape annotation geometry type");
- }
-
- geojsonvt::ProjectedFeature operator()(const MultiPoint<double>&) {
- throw std::runtime_error("unsupported shape annotation geometry type");
- }
-
- geojsonvt::ProjectedFeature operator()(const mapbox::geometry::geometry_collection<double>&) {
- throw std::runtime_error("unsupported shape annotation geometry type");
- }
-
private:
geojsonvt::LonLat convertPoint(const Point<double>& p) const {
return {
@@ -104,7 +92,7 @@ void ShapeAnnotationImpl::updateTile(const CanonicalTileID& tileID, AnnotationTi
const double tolerance = baseTolerance / (maxAmountOfTiles * util::EXTENT);
std::vector<geojsonvt::ProjectedFeature> features = {
- Geometry<double>::visit(geometry(), ToGeoJSONVT(tolerance))
+ ShapeAnnotationGeometry::visit(geometry(), ToGeoJSONVT(tolerance))
};
mapbox::geojsonvt::Options options;
diff --git a/src/mbgl/annotation/shape_annotation_impl.hpp b/src/mbgl/annotation/shape_annotation_impl.hpp
index f342c4b1fc..7f36f8b888 100644
--- a/src/mbgl/annotation/shape_annotation_impl.hpp
+++ b/src/mbgl/annotation/shape_annotation_impl.hpp
@@ -19,7 +19,7 @@ public:
virtual ~ShapeAnnotationImpl() = default;
virtual void updateStyle(Style&) const = 0;
- virtual const Geometry<double>& geometry() const = 0;
+ virtual const ShapeAnnotationGeometry& geometry() const = 0;
void updateTile(const CanonicalTileID&, AnnotationTile&);
diff --git a/src/mbgl/annotation/style_sourced_annotation_impl.cpp b/src/mbgl/annotation/style_sourced_annotation_impl.cpp
index 5d8f1f0da1..ae92d917aa 100644
--- a/src/mbgl/annotation/style_sourced_annotation_impl.cpp
+++ b/src/mbgl/annotation/style_sourced_annotation_impl.cpp
@@ -31,7 +31,7 @@ void StyleSourcedAnnotationImpl::updateStyle(Style& style) const {
style.addLayer(std::move(layer), sourceLayer->id);
}
-const Geometry<double>& StyleSourcedAnnotationImpl::geometry() const {
+const ShapeAnnotationGeometry& StyleSourcedAnnotationImpl::geometry() const {
return annotation.geometry;
}
diff --git a/src/mbgl/annotation/style_sourced_annotation_impl.hpp b/src/mbgl/annotation/style_sourced_annotation_impl.hpp
index 734f6c8290..98e9910c66 100644
--- a/src/mbgl/annotation/style_sourced_annotation_impl.hpp
+++ b/src/mbgl/annotation/style_sourced_annotation_impl.hpp
@@ -10,7 +10,7 @@ public:
StyleSourcedAnnotationImpl(const AnnotationID, const StyleSourcedAnnotation&, const uint8_t maxZoom);
void updateStyle(Style&) const final;
- const Geometry<double>& geometry() const final;
+ const ShapeAnnotationGeometry& geometry() const final;
private:
const StyleSourcedAnnotation annotation;
diff --git a/src/mbgl/annotation/symbol_annotation_impl.cpp b/src/mbgl/annotation/symbol_annotation_impl.cpp
index 5ad6142eec..44a89576bb 100644
--- a/src/mbgl/annotation/symbol_annotation_impl.cpp
+++ b/src/mbgl/annotation/symbol_annotation_impl.cpp
@@ -7,16 +7,13 @@ namespace mbgl {
SymbolAnnotationImpl::SymbolAnnotationImpl(const AnnotationID id_, const SymbolAnnotation& annotation_)
: id(id_),
annotation(annotation_) {
- if (!annotation.geometry.is<Point<double>>()) {
- throw std::runtime_error("unsupported symbol annotation geometry type");
- }
}
void SymbolAnnotationImpl::updateLayer(const CanonicalTileID& tileID, AnnotationTileLayer& layer) const {
std::unordered_map<std::string, std::string> featureProperties;
featureProperties.emplace("sprite", annotation.icon.empty() ? std::string("default_marker") : annotation.icon);
- const Point<double>& p = annotation.geometry.get<Point<double>>();
+ const Point<double>& p = annotation.geometry;
// Clamp to the latitude limits of Web Mercator.
const double constrainedLatitude = util::clamp(p.y, -util::LATITUDE_MAX, util::LATITUDE_MAX);
diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp
index 43c490140d..5dc882ab93 100644
--- a/src/mbgl/annotation/symbol_annotation_impl.hpp
+++ b/src/mbgl/annotation/symbol_annotation_impl.hpp
@@ -56,7 +56,7 @@ template <>
struct indexable<std::shared_ptr<const mbgl::SymbolAnnotationImpl>> {
using result_type = mbgl::LatLng;
inline mbgl::LatLng operator()(const std::shared_ptr<const mbgl::SymbolAnnotationImpl>& v) const {
- const mbgl::Point<double>& p = v->annotation.geometry.get<mbgl::Point<double>>();
+ const mbgl::Point<double>& p = v->annotation.geometry;
return mbgl::LatLng(p.y, p.x);
}
};