summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorGali Nelle <galinelle.mapbox@gmail.com>2020-03-25 17:35:44 +0200
committergalinelle <paolo.angelelli@mapbox.com>2020-04-08 14:00:26 +0300
commit9a55c282fecfdd76b1acdf64cef0ce2ed99472ef (patch)
treed2c412ef6ac4782d28cea66b761deeb5fff10cc3 /src/mbgl/style
parent7f53cec17b047a1804952a8da543dc10321e1dae (diff)
downloadqtlocation-mapboxgl-9a55c282fecfdd76b1acdf64cef0ce2ed99472ef.tar.gz
Add LocationIndicatorLayer
New key is "G" in mbgl-glfw, cycling between no puck, centered in the viewport and positioned in Tokyo.
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/conversion/constant.cpp22
-rw-r--r--src/mbgl/style/conversion/property_value.cpp19
-rw-r--r--src/mbgl/style/conversion/stringify.hpp9
-rw-r--r--src/mbgl/style/expression/value.cpp4
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs7
-rw-r--r--src/mbgl/style/layers/layer_properties.cpp.ejs4
-rw-r--r--src/mbgl/style/layers/layer_properties.hpp.ejs2
-rw-r--r--src/mbgl/style/layers/location_indicator_layer.cpp626
-rw-r--r--src/mbgl/style/layers/location_indicator_layer_impl.cpp12
-rw-r--r--src/mbgl/style/layers/location_indicator_layer_impl.hpp34
-rw-r--r--src/mbgl/style/layers/location_indicator_layer_properties.cpp35
-rw-r--r--src/mbgl/style/layers/location_indicator_layer_properties.hpp114
12 files changed, 882 insertions, 6 deletions
diff --git a/src/mbgl/style/conversion/constant.cpp b/src/mbgl/style/conversion/constant.cpp
index ffdb17858d..0e4e29f689 100644
--- a/src/mbgl/style/conversion/constant.cpp
+++ b/src/mbgl/style/conversion/constant.cpp
@@ -127,6 +127,28 @@ template optional<std::array<float, 2>> Converter<std::array<float, 2>>::operato
template optional<std::array<float, 3>> Converter<std::array<float, 3>>::operator()(const Convertible&, Error&) const;
template optional<std::array<float, 4>> Converter<std::array<float, 4>>::operator()(const Convertible&, Error&) const;
+template <size_t N>
+optional<std::array<double, N>> Converter<std::array<double, N>>::operator()(const Convertible& value,
+ Error& error) const {
+ if (!isArray(value) || arrayLength(value) != N) {
+ error.message = "value must be an array of " + util::toString(N) + " numbers";
+ return nullopt;
+ }
+
+ std::array<double, N> result;
+ for (size_t i = 0; i < N; i++) {
+ optional<double> n = toDouble(arrayMember(value, i));
+ if (!n) {
+ error.message = "value must be an array of " + util::toString(N) + " numbers";
+ return nullopt;
+ }
+ result[i] = *n;
+ }
+ return result;
+}
+
+template optional<std::array<double, 3>> Converter<std::array<double, 3>>::operator()(const Convertible&, Error&) const;
+
optional<std::vector<float>> Converter<std::vector<float>>::operator()(const Convertible& value, Error& error) const {
if (!isArray(value)) {
error.message = "value must be an array";
diff --git a/src/mbgl/style/conversion/property_value.cpp b/src/mbgl/style/conversion/property_value.cpp
index 5e03189e64..1a0e686850 100644
--- a/src/mbgl/style/conversion/property_value.cpp
+++ b/src/mbgl/style/conversion/property_value.cpp
@@ -88,6 +88,25 @@ Converter<PropertyValue<mbgl::style::expression::Image>>::operator()(conversion:
bool,
bool) const;
+optional<PropertyValue<std::array<double, 3>>>
+mbgl::style::conversion::Converter<PropertyValue<std::array<double, 3>>, void>::operator()(const Convertible& value,
+ Error& error,
+ bool,
+ bool) const {
+ optional<std::array<double, 3>> a = convert<std::array<double, 3>>(value, error);
+
+ if (!a) {
+ return nullopt;
+ }
+ std::array<double, 3> res;
+ res[0] = (*a)[0];
+ res[1] = (*a)[1];
+ res[2] = (*a)[2];
+
+ PropertyValue<std::array<double, 3>> r(res);
+ return r;
+}
+
} // namespace conversion
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/conversion/stringify.hpp b/src/mbgl/style/conversion/stringify.hpp
index 3816182450..d7908153f4 100644
--- a/src/mbgl/style/conversion/stringify.hpp
+++ b/src/mbgl/style/conversion/stringify.hpp
@@ -77,6 +77,15 @@ void stringify(Writer& writer, const std::array<float, 4>& v) {
}
template <class Writer>
+void stringify(Writer& writer, const std::array<double, 3>& v) {
+ writer.StartArray();
+ writer.Double(v[0]);
+ writer.Double(v[1]);
+ writer.Double(v[2]);
+ writer.EndArray();
+}
+
+template <class Writer>
void stringify(Writer&, const Value&);
template <class Writer, class T>
diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp
index 110844f421..9f40d17b02 100644
--- a/src/mbgl/style/expression/value.cpp
+++ b/src/mbgl/style/expression/value.cpp
@@ -310,6 +310,10 @@ template <> type::Type valueTypeToExpressionType<type::ErrorType>() { return typ
template type::Type valueTypeToExpressionType<std::array<double, 4>>();
template struct ValueConverter<std::array<double, 4>>;
+// for LocationIndicator position
+template type::Type valueTypeToExpressionType<std::array<double, 3>>();
+template struct ValueConverter<std::array<double, 3>>;
+
// layout/paint property types
template type::Type valueTypeToExpressionType<float>();
template type::Type valueTypeToExpressionType<Position>();
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index ab44a92784..fd5bf619f7 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -8,8 +8,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer_impl.hpp>
+#include <mbgl/style/layers/<%- type.replace(/-/g, '_') %>_layer.hpp>
+#include <mbgl/style/layers/<%- type.replace(/-/g, '_') %>_layer_impl.hpp>
#include <mbgl/style/layer_observer.hpp>
#include <mbgl/style/conversion/color_ramp_property_value.hpp>
#include <mbgl/style/conversion/constant.hpp>
@@ -80,6 +80,7 @@ layerCapabilities['heatmap'] = defaults.require('Source')
.set('TileKind', 'Geometry')
.finalize();
layerCapabilities['raster'] = defaults.require('Source').set('TileKind', 'Raster').finalize();
+layerCapabilities['location-indicator'] = defaults.finalize();
// Splits lines that are over 120 characters at the firts occurance of '='.
const split120Line = line => {
@@ -99,7 +100,7 @@ const LayerTypeInfo* <%- camelize(type) %>Layer::Impl::staticTypeInfo() noexcept
}
-<% if (type === 'background') { -%>
+<% if ((type === 'background') || (type === 'location-indicator')) { -%>
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID)
: Layer(makeMutable<Impl>(layerID, std::string())) {
}
diff --git a/src/mbgl/style/layers/layer_properties.cpp.ejs b/src/mbgl/style/layers/layer_properties.cpp.ejs
index 18b07efea8..09f4c48373 100644
--- a/src/mbgl/style/layers/layer_properties.cpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.cpp.ejs
@@ -7,9 +7,9 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer_properties.hpp>
+#include <mbgl/style/layers/<%- type.replace(/-/g, '_') %>_layer_properties.hpp>
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer_impl.hpp>
+#include <mbgl/style/layers/<%- type.replace(/-/g, '_') %>_layer_impl.hpp>
namespace mbgl {
namespace style {
diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs
index af67f14b90..66cff8c3c0 100644
--- a/src/mbgl/style/layers/layer_properties.hpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.hpp.ejs
@@ -11,7 +11,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layer_properties.hpp>
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
+#include <mbgl/style/layers/<%- type.replace(/-/g, '_') %>_layer.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
#include <mbgl/style/properties.hpp>
diff --git a/src/mbgl/style/layers/location_indicator_layer.cpp b/src/mbgl/style/layers/location_indicator_layer.cpp
new file mode 100644
index 0000000000..03b826cc18
--- /dev/null
+++ b/src/mbgl/style/layers/location_indicator_layer.cpp
@@ -0,0 +1,626 @@
+// clang-format off
+
+// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
+
+#include <mbgl/style/layers/location_indicator_layer.hpp>
+#include <mbgl/style/layers/location_indicator_layer_impl.hpp>
+#include <mbgl/style/layer_observer.hpp>
+#include <mbgl/style/conversion/color_ramp_property_value.hpp>
+#include <mbgl/style/conversion/constant.hpp>
+#include <mbgl/style/conversion/property_value.hpp>
+#include <mbgl/style/conversion/transition_options.hpp>
+#include <mbgl/style/conversion/json.hpp>
+#include <mbgl/style/conversion_impl.hpp>
+#include <mbgl/util/traits.hpp>
+
+#include <mapbox/eternal.hpp>
+
+namespace mbgl {
+namespace style {
+
+
+// static
+const LayerTypeInfo* LocationIndicatorLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo{"location-indicator",
+ LayerTypeInfo::Source::NotRequired,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::FadingTiles::NotRequired,
+ LayerTypeInfo::CrossTileIndex::NotRequired,
+ LayerTypeInfo::TileKind::NotRequired};
+ return &typeInfo;
+}
+
+
+LocationIndicatorLayer::LocationIndicatorLayer(const std::string& layerID)
+ : Layer(makeMutable<Impl>(layerID, std::string())) {
+}
+
+LocationIndicatorLayer::LocationIndicatorLayer(Immutable<Impl> impl_)
+ : Layer(std::move(impl_)) {
+}
+
+LocationIndicatorLayer::~LocationIndicatorLayer() = default;
+
+const LocationIndicatorLayer::Impl& LocationIndicatorLayer::impl() const {
+ return static_cast<const Impl&>(*baseImpl);
+}
+
+Mutable<LocationIndicatorLayer::Impl> LocationIndicatorLayer::mutableImpl() const {
+ return makeMutable<Impl>(impl());
+}
+
+std::unique_ptr<Layer> LocationIndicatorLayer::cloneRef(const std::string& id_) const {
+ auto impl_ = mutableImpl();
+ impl_->id = id_;
+ impl_->paint = LocationIndicatorPaintProperties::Transitionable();
+ return std::make_unique<LocationIndicatorLayer>(std::move(impl_));
+}
+
+void LocationIndicatorLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>& writer) const {
+ layout.stringify(writer);
+}
+
+// Layout properties
+
+PropertyValue<float> LocationIndicatorLayer::getDefaultBearing() {
+ return Bearing::defaultValue();
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getBearing() const {
+ return impl().layout.get<Bearing>();
+}
+
+void LocationIndicatorLayer::setBearing(const PropertyValue<float>& value) {
+ if (value == getBearing()) return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<Bearing>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+PropertyValue<expression::Image> LocationIndicatorLayer::getDefaultBearingImage() {
+ return BearingImage::defaultValue();
+}
+
+const PropertyValue<expression::Image>& LocationIndicatorLayer::getBearingImage() const {
+ return impl().layout.get<BearingImage>();
+}
+
+void LocationIndicatorLayer::setBearingImage(const PropertyValue<expression::Image>& value) {
+ if (value == getBearingImage()) return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<BearingImage>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+PropertyValue<float> LocationIndicatorLayer::getDefaultImageTiltDisplacement() {
+ return ImageTiltDisplacement::defaultValue();
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getImageTiltDisplacement() const {
+ return impl().layout.get<ImageTiltDisplacement>();
+}
+
+void LocationIndicatorLayer::setImageTiltDisplacement(const PropertyValue<float>& value) {
+ if (value == getImageTiltDisplacement()) return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<ImageTiltDisplacement>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+PropertyValue<float> LocationIndicatorLayer::getDefaultPerspectiveCompensation() {
+ return PerspectiveCompensation::defaultValue();
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getPerspectiveCompensation() const {
+ return impl().layout.get<PerspectiveCompensation>();
+}
+
+void LocationIndicatorLayer::setPerspectiveCompensation(const PropertyValue<float>& value) {
+ if (value == getPerspectiveCompensation()) return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<PerspectiveCompensation>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+PropertyValue<expression::Image> LocationIndicatorLayer::getDefaultShadowImage() {
+ return ShadowImage::defaultValue();
+}
+
+const PropertyValue<expression::Image>& LocationIndicatorLayer::getShadowImage() const {
+ return impl().layout.get<ShadowImage>();
+}
+
+void LocationIndicatorLayer::setShadowImage(const PropertyValue<expression::Image>& value) {
+ if (value == getShadowImage()) return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<ShadowImage>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+PropertyValue<expression::Image> LocationIndicatorLayer::getDefaultTopImage() {
+ return TopImage::defaultValue();
+}
+
+const PropertyValue<expression::Image>& LocationIndicatorLayer::getTopImage() const {
+ return impl().layout.get<TopImage>();
+}
+
+void LocationIndicatorLayer::setTopImage(const PropertyValue<expression::Image>& value) {
+ if (value == getTopImage()) return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<TopImage>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+// Paint properties
+
+PropertyValue<float> LocationIndicatorLayer::getDefaultAccuracyRadius() {
+ return {0};
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getAccuracyRadius() const {
+ return impl().paint.template get<AccuracyRadius>().value;
+}
+
+void LocationIndicatorLayer::setAccuracyRadius(const PropertyValue<float>& value) {
+ if (value == getAccuracyRadius())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<AccuracyRadius>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setAccuracyRadiusTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<AccuracyRadius>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getAccuracyRadiusTransition() const {
+ return impl().paint.template get<AccuracyRadius>().options;
+}
+
+PropertyValue<Color> LocationIndicatorLayer::getDefaultAccuracyRadiusBorderColor() {
+ return {Color::white()};
+}
+
+const PropertyValue<Color>& LocationIndicatorLayer::getAccuracyRadiusBorderColor() const {
+ return impl().paint.template get<AccuracyRadiusBorderColor>().value;
+}
+
+void LocationIndicatorLayer::setAccuracyRadiusBorderColor(const PropertyValue<Color>& value) {
+ if (value == getAccuracyRadiusBorderColor())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<AccuracyRadiusBorderColor>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setAccuracyRadiusBorderColorTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<AccuracyRadiusBorderColor>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getAccuracyRadiusBorderColorTransition() const {
+ return impl().paint.template get<AccuracyRadiusBorderColor>().options;
+}
+
+PropertyValue<Color> LocationIndicatorLayer::getDefaultAccuracyRadiusColor() {
+ return {Color::white()};
+}
+
+const PropertyValue<Color>& LocationIndicatorLayer::getAccuracyRadiusColor() const {
+ return impl().paint.template get<AccuracyRadiusColor>().value;
+}
+
+void LocationIndicatorLayer::setAccuracyRadiusColor(const PropertyValue<Color>& value) {
+ if (value == getAccuracyRadiusColor())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<AccuracyRadiusColor>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setAccuracyRadiusColorTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<AccuracyRadiusColor>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getAccuracyRadiusColorTransition() const {
+ return impl().paint.template get<AccuracyRadiusColor>().options;
+}
+
+PropertyValue<float> LocationIndicatorLayer::getDefaultBearingImageSize() {
+ return {0};
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getBearingImageSize() const {
+ return impl().paint.template get<BearingImageSize>().value;
+}
+
+void LocationIndicatorLayer::setBearingImageSize(const PropertyValue<float>& value) {
+ if (value == getBearingImageSize())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<BearingImageSize>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setBearingImageSizeTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<BearingImageSize>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getBearingImageSizeTransition() const {
+ return impl().paint.template get<BearingImageSize>().options;
+}
+
+PropertyValue<std::array<double, 3>> LocationIndicatorLayer::getDefaultLocation() {
+ return {{{0, 0, 0}}};
+}
+
+const PropertyValue<std::array<double, 3>>& LocationIndicatorLayer::getLocation() const {
+ return impl().paint.template get<Location>().value;
+}
+
+void LocationIndicatorLayer::setLocation(const PropertyValue<std::array<double, 3>>& value) {
+ if (value == getLocation())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<Location>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setLocationTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<Location>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getLocationTransition() const {
+ return impl().paint.template get<Location>().options;
+}
+
+PropertyValue<float> LocationIndicatorLayer::getDefaultShadowImageSize() {
+ return {0};
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getShadowImageSize() const {
+ return impl().paint.template get<ShadowImageSize>().value;
+}
+
+void LocationIndicatorLayer::setShadowImageSize(const PropertyValue<float>& value) {
+ if (value == getShadowImageSize())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<ShadowImageSize>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setShadowImageSizeTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<ShadowImageSize>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getShadowImageSizeTransition() const {
+ return impl().paint.template get<ShadowImageSize>().options;
+}
+
+PropertyValue<float> LocationIndicatorLayer::getDefaultTopImageSize() {
+ return {0};
+}
+
+const PropertyValue<float>& LocationIndicatorLayer::getTopImageSize() const {
+ return impl().paint.template get<TopImageSize>().value;
+}
+
+void LocationIndicatorLayer::setTopImageSize(const PropertyValue<float>& value) {
+ if (value == getTopImageSize())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<TopImageSize>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void LocationIndicatorLayer::setTopImageSizeTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<TopImageSize>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions LocationIndicatorLayer::getTopImageSizeTransition() const {
+ return impl().paint.template get<TopImageSize>().options;
+}
+
+using namespace conversion;
+
+namespace {
+
+constexpr uint8_t kPaintPropertyCount = 14u;
+
+enum class Property : uint8_t {
+ AccuracyRadius,
+ AccuracyRadiusBorderColor,
+ AccuracyRadiusColor,
+ BearingImageSize,
+ Location,
+ ShadowImageSize,
+ TopImageSize,
+ AccuracyRadiusTransition,
+ AccuracyRadiusBorderColorTransition,
+ AccuracyRadiusColorTransition,
+ BearingImageSizeTransition,
+ LocationTransition,
+ ShadowImageSizeTransition,
+ TopImageSizeTransition,
+ Bearing = kPaintPropertyCount,
+ BearingImage,
+ ImageTiltDisplacement,
+ PerspectiveCompensation,
+ ShadowImage,
+ TopImage,
+};
+
+template <typename T>
+constexpr uint8_t toUint8(T t) noexcept {
+ return uint8_t(mbgl::underlying_type(t));
+}
+
+MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>(
+ {{"accuracy-radius", toUint8(Property::AccuracyRadius)},
+ {"accuracy-radius-border-color", toUint8(Property::AccuracyRadiusBorderColor)},
+ {"accuracy-radius-color", toUint8(Property::AccuracyRadiusColor)},
+ {"bearing-image-size", toUint8(Property::BearingImageSize)},
+ {"location", toUint8(Property::Location)},
+ {"shadow-image-size", toUint8(Property::ShadowImageSize)},
+ {"top-image-size", toUint8(Property::TopImageSize)},
+ {"accuracy-radius-transition", toUint8(Property::AccuracyRadiusTransition)},
+ {"accuracy-radius-border-color-transition", toUint8(Property::AccuracyRadiusBorderColorTransition)},
+ {"accuracy-radius-color-transition", toUint8(Property::AccuracyRadiusColorTransition)},
+ {"bearing-image-size-transition", toUint8(Property::BearingImageSizeTransition)},
+ {"location-transition", toUint8(Property::LocationTransition)},
+ {"shadow-image-size-transition", toUint8(Property::ShadowImageSizeTransition)},
+ {"top-image-size-transition", toUint8(Property::TopImageSizeTransition)},
+ {"bearing", toUint8(Property::Bearing)},
+ {"bearing-image", toUint8(Property::BearingImage)},
+ {"image-tilt-displacement", toUint8(Property::ImageTiltDisplacement)},
+ {"perspective-compensation", toUint8(Property::PerspectiveCompensation)},
+ {"shadow-image", toUint8(Property::ShadowImage)},
+ {"top-image", toUint8(Property::TopImage)}});
+
+StyleProperty getLayerProperty(const LocationIndicatorLayer& layer, Property property) {
+ switch (property) {
+ case Property::AccuracyRadius:
+ return makeStyleProperty(layer.getAccuracyRadius());
+ case Property::AccuracyRadiusBorderColor:
+ return makeStyleProperty(layer.getAccuracyRadiusBorderColor());
+ case Property::AccuracyRadiusColor:
+ return makeStyleProperty(layer.getAccuracyRadiusColor());
+ case Property::BearingImageSize:
+ return makeStyleProperty(layer.getBearingImageSize());
+ case Property::Location:
+ return makeStyleProperty(layer.getLocation());
+ case Property::ShadowImageSize:
+ return makeStyleProperty(layer.getShadowImageSize());
+ case Property::TopImageSize:
+ return makeStyleProperty(layer.getTopImageSize());
+ case Property::AccuracyRadiusTransition:
+ return makeStyleProperty(layer.getAccuracyRadiusTransition());
+ case Property::AccuracyRadiusBorderColorTransition:
+ return makeStyleProperty(layer.getAccuracyRadiusBorderColorTransition());
+ case Property::AccuracyRadiusColorTransition:
+ return makeStyleProperty(layer.getAccuracyRadiusColorTransition());
+ case Property::BearingImageSizeTransition:
+ return makeStyleProperty(layer.getBearingImageSizeTransition());
+ case Property::LocationTransition:
+ return makeStyleProperty(layer.getLocationTransition());
+ case Property::ShadowImageSizeTransition:
+ return makeStyleProperty(layer.getShadowImageSizeTransition());
+ case Property::TopImageSizeTransition:
+ return makeStyleProperty(layer.getTopImageSizeTransition());
+ case Property::Bearing:
+ return makeStyleProperty(layer.getBearing());
+ case Property::BearingImage:
+ return makeStyleProperty(layer.getBearingImage());
+ case Property::ImageTiltDisplacement:
+ return makeStyleProperty(layer.getImageTiltDisplacement());
+ case Property::PerspectiveCompensation:
+ return makeStyleProperty(layer.getPerspectiveCompensation());
+ case Property::ShadowImage:
+ return makeStyleProperty(layer.getShadowImage());
+ case Property::TopImage:
+ return makeStyleProperty(layer.getTopImage());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const LocationIndicatorLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
+} // namespace
+
+Value LocationIndicatorLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
+optional<Error> LocationIndicatorLayer::setPropertyInternal(const std::string& name, const Convertible& value) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) return Error{"layer doesn't support this property"};
+
+ auto property = static_cast<Property>(it->second);
+
+ if (property == Property::AccuracyRadius || property == Property::BearingImageSize ||
+ property == Property::ShadowImageSize || property == Property::TopImageSize || property == Property::Bearing ||
+ property == Property::ImageTiltDisplacement || property == Property::PerspectiveCompensation) {
+ Error error;
+ const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ if (property == Property::AccuracyRadius) {
+ setAccuracyRadius(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::BearingImageSize) {
+ setBearingImageSize(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::ShadowImageSize) {
+ setShadowImageSize(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::TopImageSize) {
+ setTopImageSize(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::Bearing) {
+ setBearing(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::ImageTiltDisplacement) {
+ setImageTiltDisplacement(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::PerspectiveCompensation) {
+ setPerspectiveCompensation(*typedValue);
+ return nullopt;
+ }
+ }
+ if (property == Property::AccuracyRadiusBorderColor || property == Property::AccuracyRadiusColor) {
+ Error error;
+ const auto& typedValue = convert<PropertyValue<Color>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ if (property == Property::AccuracyRadiusBorderColor) {
+ setAccuracyRadiusBorderColor(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::AccuracyRadiusColor) {
+ setAccuracyRadiusColor(*typedValue);
+ return nullopt;
+ }
+ }
+ if (property == Property::Location) {
+ Error error;
+ const auto& typedValue = convert<PropertyValue<std::array<double, 3>>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ setLocation(*typedValue);
+ return nullopt;
+ }
+ if (property == Property::BearingImage || property == Property::ShadowImage || property == Property::TopImage) {
+ Error error;
+ const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ if (property == Property::BearingImage) {
+ setBearingImage(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::ShadowImage) {
+ setShadowImage(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::TopImage) {
+ setTopImage(*typedValue);
+ return nullopt;
+ }
+ }
+
+ Error error;
+ optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
+ if (!transition) {
+ return error;
+ }
+
+ if (property == Property::AccuracyRadiusTransition) {
+ setAccuracyRadiusTransition(*transition);
+ return nullopt;
+ }
+
+ if (property == Property::AccuracyRadiusBorderColorTransition) {
+ setAccuracyRadiusBorderColorTransition(*transition);
+ return nullopt;
+ }
+
+ if (property == Property::AccuracyRadiusColorTransition) {
+ setAccuracyRadiusColorTransition(*transition);
+ return nullopt;
+ }
+
+ if (property == Property::BearingImageSizeTransition) {
+ setBearingImageSizeTransition(*transition);
+ return nullopt;
+ }
+
+ if (property == Property::LocationTransition) {
+ setLocationTransition(*transition);
+ return nullopt;
+ }
+
+ if (property == Property::ShadowImageSizeTransition) {
+ setShadowImageSizeTransition(*transition);
+ return nullopt;
+ }
+
+ if (property == Property::TopImageSizeTransition) {
+ setTopImageSizeTransition(*transition);
+ return nullopt;
+ }
+
+ return Error{"layer doesn't support this property"};
+}
+
+StyleProperty LocationIndicatorLayer::getProperty(const std::string& name) const {
+ return getLayerProperty(*this, name);
+}
+
+Mutable<Layer::Impl> LocationIndicatorLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
+} // namespace style
+} // namespace mbgl
+
+// clang-format on
diff --git a/src/mbgl/style/layers/location_indicator_layer_impl.cpp b/src/mbgl/style/layers/location_indicator_layer_impl.cpp
new file mode 100644
index 0000000000..90a37f4b47
--- /dev/null
+++ b/src/mbgl/style/layers/location_indicator_layer_impl.cpp
@@ -0,0 +1,12 @@
+#include <mbgl/style/layers/location_indicator_layer.hpp>
+#include <mbgl/style/layers/location_indicator_layer_impl.hpp>
+
+namespace mbgl {
+namespace style {
+
+bool LocationIndicatorLayer::Impl::hasLayoutDifference(const Layer::Impl&) const {
+ return false;
+}
+
+} // namespace style
+} // namespace mbgl
diff --git a/src/mbgl/style/layers/location_indicator_layer_impl.hpp b/src/mbgl/style/layers/location_indicator_layer_impl.hpp
new file mode 100644
index 0000000000..954484ecb8
--- /dev/null
+++ b/src/mbgl/style/layers/location_indicator_layer_impl.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <array>
+#include <mbgl/map/transform_state.hpp>
+#include <mbgl/renderer/paint_parameters.hpp>
+#include <mbgl/style/layer_impl.hpp>
+#include <mbgl/style/layer_properties.hpp>
+#include <mbgl/style/layers/location_indicator_layer.hpp>
+#include <mbgl/style/layers/location_indicator_layer_properties.hpp>
+#include <mbgl/util/color.hpp>
+#include <mbgl/util/geo.hpp>
+#include <memory>
+#include <string>
+
+namespace mbgl {
+
+class TransformState;
+
+namespace style {
+
+class LocationIndicatorLayer::Impl : public Layer::Impl {
+public:
+ using Layer::Impl::Impl;
+
+ bool hasLayoutDifference(const Layer::Impl &) const override;
+ void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer> &) const override;
+
+ LocationIndicatorLayoutProperties::Unevaluated layout;
+ LocationIndicatorPaintProperties::Transitionable paint;
+ DECLARE_LAYER_TYPE_INFO;
+};
+
+} // namespace style
+} // namespace mbgl
diff --git a/src/mbgl/style/layers/location_indicator_layer_properties.cpp b/src/mbgl/style/layers/location_indicator_layer_properties.cpp
new file mode 100644
index 0000000000..818e45b5af
--- /dev/null
+++ b/src/mbgl/style/layers/location_indicator_layer_properties.cpp
@@ -0,0 +1,35 @@
+// clang-format off
+
+// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
+
+#include <mbgl/style/layers/location_indicator_layer_properties.hpp>
+
+#include <mbgl/style/layers/location_indicator_layer_impl.hpp>
+
+namespace mbgl {
+namespace style {
+
+LocationIndicatorLayerProperties::LocationIndicatorLayerProperties(
+ Immutable<LocationIndicatorLayer::Impl> impl_)
+ : LayerProperties(std::move(impl_)) {}
+
+LocationIndicatorLayerProperties::LocationIndicatorLayerProperties(
+ Immutable<LocationIndicatorLayer::Impl> impl_,
+ LocationIndicatorPaintProperties::PossiblyEvaluated evaluated_)
+ : LayerProperties(std::move(impl_)),
+ evaluated(std::move(evaluated_)) {}
+
+LocationIndicatorLayerProperties::~LocationIndicatorLayerProperties() = default;
+
+unsigned long LocationIndicatorLayerProperties::constantsMask() const {
+ return evaluated.constantsMask();
+}
+
+const LocationIndicatorLayer::Impl& LocationIndicatorLayerProperties::layerImpl() const {
+ return static_cast<const LocationIndicatorLayer::Impl&>(*baseImpl);
+}
+
+} // namespace style
+} // namespace mbgl
+
+// clang-format on
diff --git a/src/mbgl/style/layers/location_indicator_layer_properties.hpp b/src/mbgl/style/layers/location_indicator_layer_properties.hpp
new file mode 100644
index 0000000000..d1f0879f74
--- /dev/null
+++ b/src/mbgl/style/layers/location_indicator_layer_properties.hpp
@@ -0,0 +1,114 @@
+// clang-format off
+
+// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
+
+#pragma once
+
+#include <mbgl/style/types.hpp>
+#include <mbgl/style/layer_properties.hpp>
+#include <mbgl/style/layers/location_indicator_layer.hpp>
+#include <mbgl/style/layout_property.hpp>
+#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+
+namespace mbgl {
+namespace style {
+
+struct Bearing : LayoutProperty<float> {
+ static constexpr const char *name() { return "bearing"; }
+ static float defaultValue() { return 0; }
+};
+
+struct BearingImage : LayoutProperty<expression::Image> {
+ static constexpr const char *name() { return "bearing-image"; }
+ static expression::Image defaultValue() { return {}; }
+};
+
+struct ImageTiltDisplacement : LayoutProperty<float> {
+ static constexpr const char *name() { return "image-tilt-displacement"; }
+ static float defaultValue() { return 0; }
+};
+
+struct PerspectiveCompensation : LayoutProperty<float> {
+ static constexpr const char *name() { return "perspective-compensation"; }
+ static float defaultValue() { return 0.85; }
+};
+
+struct ShadowImage : LayoutProperty<expression::Image> {
+ static constexpr const char *name() { return "shadow-image"; }
+ static expression::Image defaultValue() { return {}; }
+};
+
+struct TopImage : LayoutProperty<expression::Image> {
+ static constexpr const char *name() { return "top-image"; }
+ static expression::Image defaultValue() { return {}; }
+};
+
+struct AccuracyRadius : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct AccuracyRadiusBorderColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::white(); }
+};
+
+struct AccuracyRadiusColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::white(); }
+};
+
+struct BearingImageSize : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct Location : PaintProperty<std::array<double, 3>> {
+ static std::array<double, 3> defaultValue() { return {{0, 0, 0}}; }
+};
+
+struct ShadowImageSize : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct TopImageSize : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+class LocationIndicatorLayoutProperties : public Properties<
+ Bearing,
+ BearingImage,
+ ImageTiltDisplacement,
+ PerspectiveCompensation,
+ ShadowImage,
+ TopImage
+> {};
+
+class LocationIndicatorPaintProperties : public Properties<
+ AccuracyRadius,
+ AccuracyRadiusBorderColor,
+ AccuracyRadiusColor,
+ BearingImageSize,
+ Location,
+ ShadowImageSize,
+ TopImageSize
+> {};
+
+class LocationIndicatorLayerProperties final : public LayerProperties {
+public:
+ explicit LocationIndicatorLayerProperties(Immutable<LocationIndicatorLayer::Impl>);
+ LocationIndicatorLayerProperties(
+ Immutable<LocationIndicatorLayer::Impl>,
+ LocationIndicatorPaintProperties::PossiblyEvaluated);
+ ~LocationIndicatorLayerProperties() override;
+
+ unsigned long constantsMask() const override;
+
+ const LocationIndicatorLayer::Impl& layerImpl() const;
+ // Data members.
+ LocationIndicatorPaintProperties::PossiblyEvaluated evaluated;
+};
+
+} // namespace style
+} // namespace mbgl
+
+// clang-format on