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

[core] Add support for data-driven styling #7372

Merged
merged 6 commits into from
Feb 2, 2017
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ matrix:
- make qt-app
- make qt-qml-app
- make qt-test
- scripts/valgrind.sh build/qt-linux-x86_64/Release/mbgl-test --gtest_filter=-*.Load
- scripts/valgrind.sh build/qt-linux-x86_64/Release/mbgl-test --gtest_filter=-*.Load --gtest_filter=-Memory.Vector

cache:
directories:
Expand Down
23 changes: 21 additions & 2 deletions cmake/core-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ set(MBGL_CORE_FILES
src/mbgl/gl/framebuffer.hpp
src/mbgl/gl/gl.cpp
src/mbgl/gl/index_buffer.hpp
src/mbgl/gl/normalization.hpp
src/mbgl/gl/object.cpp
src/mbgl/gl/object.hpp
src/mbgl/gl/primitives.hpp
src/mbgl/gl/program.hpp
src/mbgl/gl/renderbuffer.hpp
src/mbgl/gl/segment.cpp
src/mbgl/gl/segment.hpp
src/mbgl/gl/state.hpp
src/mbgl/gl/stencil_mode.cpp
Expand Down Expand Up @@ -205,22 +207,23 @@ set(MBGL_CORE_FILES

# style
include/mbgl/style/conversion.hpp
include/mbgl/style/data_driven_property_value.hpp
include/mbgl/style/filter.hpp
include/mbgl/style/filter_evaluator.hpp
include/mbgl/style/function.hpp
include/mbgl/style/layer.hpp
include/mbgl/style/property_value.hpp
include/mbgl/style/source.hpp
include/mbgl/style/transition_options.hpp
include/mbgl/style/types.hpp
include/mbgl/style/undefined.hpp
src/mbgl/style/bucket_parameters.cpp
src/mbgl/style/bucket_parameters.hpp
src/mbgl/style/cascade_parameters.hpp
src/mbgl/style/class_dictionary.cpp
src/mbgl/style/class_dictionary.hpp
src/mbgl/style/cross_faded_property_evaluator.cpp
src/mbgl/style/cross_faded_property_evaluator.hpp
src/mbgl/style/function.cpp
src/mbgl/style/data_driven_property_evaluator.hpp
src/mbgl/style/group_by_layout.cpp
src/mbgl/style/group_by_layout.hpp
src/mbgl/style/layer.cpp
Expand All @@ -230,8 +233,10 @@ set(MBGL_CORE_FILES
src/mbgl/style/layout_property.hpp
src/mbgl/style/observer.hpp
src/mbgl/style/paint_property.hpp
src/mbgl/style/paint_property_binder.hpp
src/mbgl/style/parser.cpp
src/mbgl/style/parser.hpp
src/mbgl/style/possibly_evaluated_property_value.hpp
src/mbgl/style/property_evaluation_parameters.hpp
src/mbgl/style/property_evaluator.hpp
src/mbgl/style/property_parsing.cpp
Expand All @@ -252,6 +257,7 @@ set(MBGL_CORE_FILES

# style/conversion
include/mbgl/style/conversion/constant.hpp
include/mbgl/style/conversion/data_driven_property_value.hpp
include/mbgl/style/conversion/filter.hpp
include/mbgl/style/conversion/function.hpp
include/mbgl/style/conversion/geojson.hpp
Expand All @@ -264,6 +270,17 @@ set(MBGL_CORE_FILES
include/mbgl/style/conversion/tileset.hpp
src/mbgl/style/conversion/stringify.hpp

# style/function
include/mbgl/style/function/camera_function.hpp
include/mbgl/style/function/categorical_stops.hpp
include/mbgl/style/function/composite_function.hpp
include/mbgl/style/function/exponential_stops.hpp
include/mbgl/style/function/identity_stops.hpp
include/mbgl/style/function/interval_stops.hpp
include/mbgl/style/function/source_function.hpp
src/mbgl/style/function/categorical_stops.cpp
src/mbgl/style/function/identity_stops.cpp

# style/layers
include/mbgl/style/layers/background_layer.hpp
include/mbgl/style/layers/circle_layer.hpp
Expand Down Expand Up @@ -437,6 +454,7 @@ set(MBGL_CORE_FILES
src/mbgl/util/i18n.hpp
src/mbgl/util/ignore.hpp
src/mbgl/util/indexed_tuple.hpp
src/mbgl/util/interpolate.cpp
src/mbgl/util/interpolate.hpp
src/mbgl/util/intersection_tests.cpp
src/mbgl/util/intersection_tests.hpp
Expand Down Expand Up @@ -469,6 +487,7 @@ set(MBGL_CORE_FILES
src/mbgl/util/tile_cover.cpp
src/mbgl/util/tile_cover.hpp
src/mbgl/util/token.hpp
src/mbgl/util/type_list.hpp
src/mbgl/util/url.cpp
src/mbgl/util/url.hpp
src/mbgl/util/utf.hpp
Expand Down
8 changes: 7 additions & 1 deletion cmake/test-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(MBGL_TEST_FILES
test/src/mbgl/test/fixture_log_observer.hpp
test/src/mbgl/test/stub_file_source.cpp
test/src/mbgl/test/stub_file_source.hpp
test/src/mbgl/test/stub_geometry_tile_feature.hpp
test/src/mbgl/test/stub_layer_observer.hpp
test/src/mbgl/test/stub_style_observer.hpp
test/src/mbgl/test/stub_tile_observer.hpp
Expand Down Expand Up @@ -77,7 +78,12 @@ set(MBGL_TEST_FILES

# style
test/style/filter.test.cpp
test/style/functions.test.cpp

# style/function
test/style/function/camera_function.test.cpp
test/style/function/source_function.test.cpp

# style
test/style/group_by_layout.test.cpp
test/style/paint_property.test.cpp
test/style/source.test.cpp
Expand Down
11 changes: 6 additions & 5 deletions include/mbgl/annotation/annotation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <mbgl/util/variant.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/data_driven_property_value.hpp>

#include <cstdint>
#include <vector>
Expand All @@ -29,17 +30,17 @@ using ShapeAnnotationGeometry = variant<
class LineAnnotation {
public:
ShapeAnnotationGeometry geometry;
style::PropertyValue<float> opacity { 1.0f };
style::DataDrivenPropertyValue<float> opacity { 1.0f };
style::PropertyValue<float> width { 1.0f };
style::PropertyValue<Color> color { Color::black() };
style::DataDrivenPropertyValue<Color> color { Color::black() };
};

class FillAnnotation {
public:
ShapeAnnotationGeometry geometry;
style::PropertyValue<float> opacity { 1.0f };
style::PropertyValue<Color> color { Color::black() };
style::PropertyValue<Color> outlineColor {};
style::DataDrivenPropertyValue<float> opacity { 1.0f };
style::DataDrivenPropertyValue<Color> color { Color::black() };
style::DataDrivenPropertyValue<Color> outlineColor {};
};

// An annotation whose type and properties are sourced from a style layer.
Expand Down
46 changes: 46 additions & 0 deletions include/mbgl/style/conversion/data_driven_property_value.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/constant.hpp>
#include <mbgl/style/conversion/function.hpp>

namespace mbgl {
namespace style {
namespace conversion {

template <class T>
struct Converter<DataDrivenPropertyValue<T>> {
template <class V>
Result<DataDrivenPropertyValue<T>> operator()(const V& value) const {
if (isUndefined(value)) {
return {};
} else if (!isObject(value)) {
Result<T> constant = convert<T>(value);
if (!constant) {
return constant.error();
}
return DataDrivenPropertyValue<T>(*constant);
} else if (!objectMember(value, "property")) {
Result<CameraFunction<T>> function = convert<CameraFunction<T>>(value);
if (!function) {
return function.error();
}
return DataDrivenPropertyValue<T>(*function);
} else {
Result<CompositeFunction<T>> composite = convert<CompositeFunction<T>>(value);
if (composite) {
return DataDrivenPropertyValue<T>(*composite);
}
Result<SourceFunction<T>> source = convert<SourceFunction<T>>(value);
if (!source) {
return source.error();
}
return DataDrivenPropertyValue<T>(*source);
}
}
};

} // namespace conversion
} // namespace style
} // namespace mbgl
Loading