Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add Location Indicator layer #16340

Merged
merged 4 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ add_library(
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/light.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/position.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/property_value.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/rotation.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/source.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/tileset.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/conversion/transition_options.hpp
Expand Down Expand Up @@ -217,6 +218,7 @@ add_library(
${PROJECT_SOURCE_DIR}/include/mbgl/style/position.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/property_expression.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/property_value.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/rotation.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/source.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/sources/custom_geometry_source.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/sources/geojson_source.hpp
Expand Down Expand Up @@ -548,6 +550,7 @@ add_library(
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/light.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/position.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/property_value.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/rotation.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/source.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/stringify.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/conversion/tileset.cpp
Expand Down Expand Up @@ -825,7 +828,9 @@ if(MBGL_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/include/mbgl/gl/custom_layer_factory.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/renderable_resource.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/renderer_backend.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/layermanager/location_indicator_layer_factory.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/platform/gl_functions.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/style/layers/location_indicator_layer.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/attribute.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/attribute.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/command_encoder.cpp
Expand All @@ -851,12 +856,12 @@ if(MBGL_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/src/mbgl/gl/offscreen_texture.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/offscreen_texture.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/program.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_custom_layer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_custom_layer.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_pass.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_pass.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/renderbuffer_resource.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/renderer_backend.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_custom_layer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_custom_layer.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/state.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/texture.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/texture.hpp
Expand All @@ -874,6 +879,7 @@ if(MBGL_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_array_extension.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_buffer_resource.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_buffer_resource.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/layermanager/location_indicator_layer_factory.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/platform/gl_functions.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/background.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/background_pattern.cpp
Expand Down Expand Up @@ -906,6 +912,13 @@ if(MBGL_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_sdf_icon.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_sdf_text.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_text_and_icon.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/render_location_indicator_layer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/render_location_indicator_layer.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer_impl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer_impl.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer_properties.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer_properties.hpp
)
endif()

Expand Down
15 changes: 15 additions & 0 deletions include/mbgl/layermanager/location_indicator_layer_factory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <mbgl/layermanager/layer_factory.hpp>

namespace mbgl {

class LocationIndicatorLayerFactory : public LayerFactory {
galinelle marked this conversation as resolved.
Show resolved Hide resolved
protected:
const style::LayerTypeInfo* getTypeInfo() const noexcept final;
std::unique_ptr<style::Layer> createLayer(const std::string& id,
const style::conversion::Convertible& value) noexcept final;
std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};

} // namespace mbgl
5 changes: 5 additions & 0 deletions include/mbgl/style/conversion/constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ struct Converter<std::vector<float>> {
optional<std::vector<float>> operator()(const Convertible& value, Error& error) const;
};

template <size_t N>
struct Converter<std::array<double, N>> {
optional<std::array<double, N>> operator()(const Convertible& value, Error& error) const;
};

template <>
struct Converter<std::vector<std::string>> {
optional<std::vector<std::string>> operator()(const Convertible& value, Error& error) const;
Expand Down
4 changes: 4 additions & 0 deletions include/mbgl/style/conversion/property_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ struct Converter<PropertyValue<T>> {
}
};

template <>
struct Converter<PropertyValue<std::array<double, 3>>, void> {
optional<PropertyValue<std::array<double, 3>>> operator()(const Convertible& value, Error& error, bool, bool) const;
};
} // namespace conversion
} // namespace style
} // namespace mbgl
18 changes: 18 additions & 0 deletions include/mbgl/style/conversion/rotation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <mbgl/style/conversion.hpp>
#include <mbgl/style/rotation.hpp>
#include <mbgl/util/optional.hpp>

namespace mbgl {
namespace style {
namespace conversion {

template <>
struct Converter<style::Rotation> {
optional<style::Rotation> operator()(const Convertible& value, Error& error) const;
};

} // namespace conversion
} // namespace style
} // namespace mbgl
6 changes: 6 additions & 0 deletions include/mbgl/style/conversion_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <mbgl/style/expression/image.hpp>
#include <mbgl/style/layer.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/rotation.hpp>
#include <mbgl/style/transition_options.hpp>
#include <mbgl/util/feature.hpp>
#include <mbgl/util/geojson.hpp>
Expand Down Expand Up @@ -343,6 +344,11 @@ struct ValueFactory<Position> {
}
};

template <>
struct ValueFactory<Rotation> {
static Value make(const Rotation& rotation) { return {rotation.getAngle()}; }
};

template <typename T>
Value makeValue(T&& arg) {
return ValueFactory<std::decay_t<T>>::make(std::forward<T>(arg));
Expand Down
8 changes: 8 additions & 0 deletions include/mbgl/style/expression/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <mbgl/style/expression/image.hpp>
#include <mbgl/style/expression/type.hpp>
#include <mbgl/style/position.hpp>
#include <mbgl/style/rotation.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/enum.hpp>
Expand Down Expand Up @@ -147,6 +148,13 @@ std::vector<optional<T>> fromExpressionValues(const std::vector<optional<Value>>
return result;
}

template <>
struct ValueConverter<Rotation> {
static type::Type expressionType() { return type::Number; }
static Value toExpressionValue(const mbgl::style::Rotation& value);
static optional<Rotation> fromExpressionValue(const Value& v);
};

} // namespace expression
} // namespace style
} // namespace mbgl
1 change: 0 additions & 1 deletion include/mbgl/style/layers/background_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/style/layers/circle_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/style/layers/fill_extrusion_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/style/layers/fill_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/style/layers/heatmap_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/style/layers/hillshade_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
7 changes: 6 additions & 1 deletion include/mbgl/style/layers/layer.hpp.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
<% if (type === 'location-indicator') { -%>
#include <mbgl/style/rotation.hpp>
<% } -%>
<% if (type === 'symbol') { -%>
#include <mbgl/style/expression/formatted.hpp>
<% } -%>
#include <mbgl/util/color.hpp>

<% if (type === 'line' || type === 'symbol') { -%>
Expand All @@ -29,7 +34,7 @@ class TransitionOptions;

class <%- camelize(type) %>Layer : public Layer {
public:
<% if (type === 'background') { -%>
<% if ((type === 'background') || (type === 'location-indicator')) { -%>
<%- camelize(type) %>Layer(const std::string& layerID);
<% } else { -%>
<%- camelize(type) %>Layer(const std::string& layerID, const std::string& sourceID);
Expand Down
1 change: 0 additions & 1 deletion include/mbgl/style/layers/line_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

#include <vector>
Expand Down
117 changes: 117 additions & 0 deletions include/mbgl/style/layers/location_indicator_layer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// clang-format off

// This file is generated. Do not edit.

#pragma once

#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/rotation.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
namespace style {

class TransitionOptions;

class LocationIndicatorLayer : public Layer {
public:
LocationIndicatorLayer(const std::string& layerID);
~LocationIndicatorLayer() final;

// Layout properties

static PropertyValue<expression::Image> getDefaultBearingImage();
const PropertyValue<expression::Image>& getBearingImage() const;
void setBearingImage(const PropertyValue<expression::Image>&);

static PropertyValue<float> getDefaultImageTiltDisplacement();
const PropertyValue<float>& getImageTiltDisplacement() const;
void setImageTiltDisplacement(const PropertyValue<float>&);

static PropertyValue<float> getDefaultPerspectiveCompensation();
const PropertyValue<float>& getPerspectiveCompensation() const;
void setPerspectiveCompensation(const PropertyValue<float>&);

static PropertyValue<expression::Image> getDefaultShadowImage();
const PropertyValue<expression::Image>& getShadowImage() const;
void setShadowImage(const PropertyValue<expression::Image>&);

static PropertyValue<expression::Image> getDefaultTopImage();
const PropertyValue<expression::Image>& getTopImage() const;
void setTopImage(const PropertyValue<expression::Image>&);

// Paint properties

static PropertyValue<float> getDefaultAccuracyRadius();
const PropertyValue<float>& getAccuracyRadius() const;
void setAccuracyRadius(const PropertyValue<float>&);
void setAccuracyRadiusTransition(const TransitionOptions&);
TransitionOptions getAccuracyRadiusTransition() const;

static PropertyValue<Color> getDefaultAccuracyRadiusBorderColor();
const PropertyValue<Color>& getAccuracyRadiusBorderColor() const;
void setAccuracyRadiusBorderColor(const PropertyValue<Color>&);
void setAccuracyRadiusBorderColorTransition(const TransitionOptions&);
TransitionOptions getAccuracyRadiusBorderColorTransition() const;

static PropertyValue<Color> getDefaultAccuracyRadiusColor();
const PropertyValue<Color>& getAccuracyRadiusColor() const;
void setAccuracyRadiusColor(const PropertyValue<Color>&);
void setAccuracyRadiusColorTransition(const TransitionOptions&);
TransitionOptions getAccuracyRadiusColorTransition() const;

static PropertyValue<Rotation> getDefaultBearing();
const PropertyValue<Rotation>& getBearing() const;
void setBearing(const PropertyValue<Rotation>&);
void setBearingTransition(const TransitionOptions&);
TransitionOptions getBearingTransition() const;

static PropertyValue<float> getDefaultBearingImageSize();
const PropertyValue<float>& getBearingImageSize() const;
void setBearingImageSize(const PropertyValue<float>&);
void setBearingImageSizeTransition(const TransitionOptions&);
TransitionOptions getBearingImageSizeTransition() const;

static PropertyValue<std::array<double, 3>> getDefaultLocation();
const PropertyValue<std::array<double, 3>>& getLocation() const;
void setLocation(const PropertyValue<std::array<double, 3>>&);
void setLocationTransition(const TransitionOptions&);
TransitionOptions getLocationTransition() const;

static PropertyValue<float> getDefaultShadowImageSize();
const PropertyValue<float>& getShadowImageSize() const;
void setShadowImageSize(const PropertyValue<float>&);
void setShadowImageSizeTransition(const TransitionOptions&);
TransitionOptions getShadowImageSizeTransition() const;

static PropertyValue<float> getDefaultTopImageSize();
const PropertyValue<float>& getTopImageSize() const;
void setTopImageSize(const PropertyValue<float>&);
void setTopImageSizeTransition(const TransitionOptions&);
TransitionOptions getTopImageSizeTransition() const;

// Private implementation

class Impl;
const Impl& impl() const;

Mutable<Impl> mutableImpl() const;
LocationIndicatorLayer(Immutable<Impl>);
std::unique_ptr<Layer> cloneRef(const std::string& id) const final;

protected:
// Dynamic properties
optional<conversion::Error> setPropertyInternal(const std::string& name, const conversion::Convertible& value) final;

StyleProperty getProperty(const std::string& name) const final;
Value serialize() const final;

Mutable<Layer::Impl> mutableBaseImpl() const final;
};

} // namespace style
} // namespace mbgl

// clang-format on
1 change: 0 additions & 1 deletion include/mbgl/style/layers/raster_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>

namespace mbgl {
Expand Down
Loading