diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 18:29:42 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 20:02:50 +0100 |
commit | abafb52f37beb5659efc2105ccd1568e1f754898 (patch) | |
tree | 6a60636d3497560ca61e5aae5f6d7061c4f18553 /include/mbgl/style | |
parent | bff6aeb4da41dee1f5f1cfa0be81b6c257257253 (diff) | |
download | qtlocation-mapboxgl-abafb52f37beb5659efc2105ccd1568e1f754898.tar.gz |
make most headers private
Diffstat (limited to 'include/mbgl/style')
20 files changed, 0 insertions, 1462 deletions
diff --git a/include/mbgl/style/applied_class_properties.hpp b/include/mbgl/style/applied_class_properties.hpp deleted file mode 100644 index 827f15a2a1..0000000000 --- a/include/mbgl/style/applied_class_properties.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MBGL_STYLE_APPLIED_CLASS_PROPERTIES -#define MBGL_STYLE_APPLIED_CLASS_PROPERTIES - -#include <mbgl/style/property_value.hpp> -#include <mbgl/style/class_dictionary.hpp> -#include <mbgl/util/time.hpp> - -#include <list> - -namespace mbgl { - -class AppliedClassProperty { -public: - AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value); - -public: - const ClassID name; - const timestamp begin; - const timestamp end; - const PropertyValue value; -}; - - -class AppliedClassProperties { -public: - std::list<AppliedClassProperty> properties; - -public: - // Returns thie ID of the most recent - ClassID mostRecent() const; - void add(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value); - bool hasTransitions() const; - void cleanup(timestamp now); - bool empty() const; -}; - -} - -#endif diff --git a/include/mbgl/style/class_dictionary.hpp b/include/mbgl/style/class_dictionary.hpp deleted file mode 100644 index ecf80be3e3..0000000000 --- a/include/mbgl/style/class_dictionary.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef MBGL_STYLE_CLASS_DICTIONARY -#define MBGL_STYLE_CLASS_DICTIONARY - -#include <cstdint> -#include <string> -#include <unordered_map> - -namespace mbgl { - -enum class ClassID : uint32_t { - Fallback = 0, // These values are from the fallback properties - Default = 1, // These values are from the default style for a layer - Named = 2 // These values (and all subsequent IDs) are from a named style from the layer -}; - -class ClassDictionary { -private: - ClassDictionary(); - -public: - static ClassDictionary &Get(); - - // Returns an ID for a class name. If the class name does not yet have an ID, one is - // auto-generated and stored for future reference. - ClassID lookup(const std::string &class_name); - - // Returns either Fallback, Default or Named, depending on the type of the class id. - ClassID normalize(ClassID id); - -private: - std::unordered_map<std::string, ClassID> store = { { "", ClassID::Default } }; - uint32_t offset = 0; -}; - -} - -#endif diff --git a/include/mbgl/style/class_properties.hpp b/include/mbgl/style/class_properties.hpp deleted file mode 100644 index 888a90c5d7..0000000000 --- a/include/mbgl/style/class_properties.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef MBGL_STYLE_CLASS_PROPERTIES -#define MBGL_STYLE_CLASS_PROPERTIES - -#include <mbgl/style/property_key.hpp> -#include <mbgl/style/property_value.hpp> -#include <mbgl/style/property_transition.hpp> - -#include <map> - -namespace mbgl { - -class ClassProperties { -public: - inline ClassProperties() {} - inline ClassProperties(ClassProperties &&properties_) - : properties(std::move(properties_.properties)) {} - - inline void set(PropertyKey key, const PropertyValue &value) { - properties.emplace(key, value); - } - - inline void set(PropertyKey key, const PropertyTransition &transition) { - transitions.emplace(key, transition); - } - - const PropertyTransition &getTransition(PropertyKey key, const PropertyTransition &defaultTransition) const; - - // Route-through iterable interface so that you can iterate on the object as is. - inline std::map<PropertyKey, PropertyValue>::const_iterator begin() const { - return properties.begin(); - } - inline std::map<PropertyKey, PropertyValue>::const_iterator end() const { - return properties.end(); - } - -public: - std::map<PropertyKey, PropertyValue> properties; - std::map<PropertyKey, PropertyTransition> transitions; -}; - -} - -#endif diff --git a/include/mbgl/style/filter_expression.hpp b/include/mbgl/style/filter_expression.hpp deleted file mode 100644 index 8c6f447770..0000000000 --- a/include/mbgl/style/filter_expression.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef MBGL_STYLE_FILTER_EXPRESSION -#define MBGL_STYLE_FILTER_EXPRESSION - -#include <mbgl/style/value.hpp> - -#include <rapidjson/document.h> - -#include <string> -#include <vector> - -namespace mbgl { - -typedef mapbox::util::variant< - struct NullExpression, - struct EqualsExpression, - struct NotEqualsExpression, - struct LessThanExpression, - struct LessThanEqualsExpression, - struct GreaterThanExpression, - struct GreaterThanEqualsExpression, - struct InExpression, - struct NotInExpression, - struct AnyExpression, - struct AllExpression, - struct NoneExpression - > FilterExpression; - -FilterExpression parseFilterExpression(const rapidjson::Value&); - -template <class Extractor> -bool evaluate(const FilterExpression&, const Extractor&); - -struct NullExpression { - template <class Extractor> - bool evaluate(const Extractor&) const { return true; } -}; - -struct EqualsExpression { - std::string key; - Value value; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct NotEqualsExpression { - std::string key; - Value value; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct LessThanExpression { - std::string key; - Value value; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct LessThanEqualsExpression { - std::string key; - Value value; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct GreaterThanExpression { - std::string key; - Value value; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct GreaterThanEqualsExpression { - std::string key; - Value value; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct InExpression { - std::string key; - std::vector<Value> values; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct NotInExpression { - std::string key; - std::vector<Value> values; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct AnyExpression { - std::vector<FilterExpression> expressions; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct AllExpression { - std::vector<FilterExpression> expressions; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -struct NoneExpression { - std::vector<FilterExpression> expressions; - - template <class Extractor> - bool evaluate(const Extractor&) const; -}; - -} - -#endif diff --git a/include/mbgl/style/filter_expression_private.hpp b/include/mbgl/style/filter_expression_private.hpp deleted file mode 100644 index 381f8f617c..0000000000 --- a/include/mbgl/style/filter_expression_private.hpp +++ /dev/null @@ -1,118 +0,0 @@ -#include <mbgl/util/optional.hpp> -#include <mbgl/style/value_comparison.hpp> - -namespace mbgl { - -template <class Extractor> -struct Evaluator : public mapbox::util::static_visitor<bool> -{ - const Extractor& extractor; - - Evaluator(const Extractor& extractor_) - : extractor(extractor_) {} - - template <class E> - bool operator()(const E& e) const { return e.evaluate(extractor); } -}; - -template <class Extractor> -bool evaluate(const FilterExpression& expression, const Extractor& extractor) { - return mapbox::util::apply_visitor(Evaluator<Extractor>(extractor), expression); -}; - -template <class Extractor> -bool EqualsExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - return actual && util::relaxed_equal(*actual, value); -} - -template <class Extractor> -bool NotEqualsExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - return !actual || util::relaxed_not_equal(*actual, value); -} - -template <class Extractor> -bool LessThanExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - return actual && util::relaxed_less(*actual, value); -} - -template <class Extractor> -bool LessThanEqualsExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - return actual && util::relaxed_less_equal(*actual, value); -} - -template <class Extractor> -bool GreaterThanExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - return actual && util::relaxed_greater(*actual, value); -} - -template <class Extractor> -bool GreaterThanEqualsExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - return actual && util::relaxed_greater_equal(*actual, value); -} - -template <class Extractor> -bool InExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - if (!actual) - return false; - for (const auto& v: values) { - if (util::relaxed_equal(*actual, v)) { - return true; - } - } - return false; -} - -template <class Extractor> -bool NotInExpression::evaluate(const Extractor& extractor) const { - mapbox::util::optional<Value> actual = extractor.getValue(key); - if (!actual) - return true; - for (const auto& v: values) { - if (util::relaxed_equal(*actual, v)) { - return false; - } - } - return true; -} - -template <class Extractor> -bool AnyExpression::evaluate(const Extractor& extractor) const { - Evaluator<Extractor> evaluator(extractor); - for (const auto& e: expressions) { - if (mapbox::util::apply_visitor(evaluator, e)) { - return true; - } - } - return false; -} - -template <class Extractor> -bool AllExpression::evaluate(const Extractor& extractor) const { - Evaluator<Extractor> evaluator(extractor); - for (const auto& e: expressions) { - if (!mapbox::util::apply_visitor(evaluator, e)) { - return false; - } - } - return true; -} - -template <class Extractor> -bool NoneExpression::evaluate(const Extractor& extractor) const { - Evaluator<Extractor> evaluator(extractor); - for (const auto& e: expressions) { - if (mapbox::util::apply_visitor(evaluator, e)) { - return false; - } - } - return true; -} - -} diff --git a/include/mbgl/style/function_properties.hpp b/include/mbgl/style/function_properties.hpp deleted file mode 100644 index 924f192330..0000000000 --- a/include/mbgl/style/function_properties.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef MBGL_STYLE_FUNCTION_PROPERTIES -#define MBGL_STYLE_FUNCTION_PROPERTIES - -#include <mbgl/util/variant.hpp> - -#include <vector> - -namespace mbgl { - -template <typename T> -struct ConstantFunction { - inline ConstantFunction(const T &value_) : value(value_) {} - inline T evaluate(float) const { return value; } - -private: - const T value; -}; - -template <typename T> -struct StopsFunction { - inline StopsFunction(const std::vector<std::pair<float, T>> &values_, float base_) : values(values_), base(base_) {} - T evaluate(float z) const; - -private: - const std::vector<std::pair<float, T>> values; - const float base; -}; - -template <typename T> -using Function = mapbox::util::variant< - std::false_type, - ConstantFunction<T>, - StopsFunction<T> ->; - -template <typename T> -struct FunctionEvaluator { - typedef T result_type; - inline FunctionEvaluator(float z_) : z(z_) {} - - inline result_type operator()(const std::false_type &) { - return result_type(); - } - - template <template <typename> class Fn> - inline result_type operator()(const Fn<T>& fn) { - return fn.evaluate(z); - } -private: - float z; -}; - -} - -#endif diff --git a/include/mbgl/style/property_fallback.hpp b/include/mbgl/style/property_fallback.hpp deleted file mode 100644 index 5c5eae0cd6..0000000000 --- a/include/mbgl/style/property_fallback.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MBGL_STYLE_PROPERTY_FALLBACK -#define MBGL_STYLE_PROPERTY_FALLBACK - -#include <mbgl/style/property_key.hpp> -#include <mbgl/style/property_value.hpp> - -#include <map> - -namespace mbgl { - -class PropertyFallbackValue { -public: - static const PropertyValue &Get(PropertyKey key) { - auto it = properties.find(key); - if (it != properties.end()) { - return it->second; - } else { - return defaultProperty; - } - } - -private: - static const std::map<PropertyKey, PropertyValue> properties; - static const PropertyValue defaultProperty; -}; - -} - -#endif diff --git a/include/mbgl/style/property_key.hpp b/include/mbgl/style/property_key.hpp deleted file mode 100644 index efeebf0242..0000000000 --- a/include/mbgl/style/property_key.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MBGL_STYLE_PROPERTY_KEY -#define MBGL_STYLE_PROPERTY_KEY - -namespace mbgl { - -enum class PropertyKey { - FillAntialias, - FillOpacity, - FillColor, - FillOutlineColor, - FillTranslate, // for transitions only - FillTranslateX, - FillTranslateY, - FillTranslateAnchor, - FillImage, - - LineOpacity, - LineColor, - LineTranslate, // for transitions only - LineTranslateX, - LineTranslateY, - LineTranslateAnchor, - LineWidth, - LineGapWidth, - LineBlur, - LineDashArray, // for transitions only - LineDashLand, - LineDashGap, - LineImage, - - IconOpacity, - IconRotate, - IconSize, - IconColor, - IconHaloColor, - IconHaloWidth, - IconHaloBlur, - IconTranslate, // for transitions only - IconTranslateX, - IconTranslateY, - IconTranslateAnchor, - - TextOpacity, - TextSize, - TextColor, - TextHaloColor, - TextHaloWidth, - TextHaloBlur, - TextTranslate, // for transitions only - TextTranslateX, - TextTranslateY, - TextTranslateAnchor, - - RasterOpacity, - RasterHueRotate, - RasterBrightness, // for transitions only - RasterBrightnessLow, - RasterBrightnessHigh, - RasterSaturation, - RasterContrast, - RasterFade, - - BackgroundOpacity, - BackgroundColor, - BackgroundImage -}; - -} - -#endif diff --git a/include/mbgl/style/property_transition.hpp b/include/mbgl/style/property_transition.hpp deleted file mode 100644 index 07b7cfe288..0000000000 --- a/include/mbgl/style/property_transition.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef MBGL_STYLE_PROPERTY_TRANSITION -#define MBGL_STYLE_PROPERTY_TRANSITION - -#include <cstdint> - -namespace mbgl { - -struct PropertyTransition { - uint16_t duration = 0; - uint16_t delay = 0; -}; - -} - -#endif
\ No newline at end of file diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp deleted file mode 100644 index 1b22b31177..0000000000 --- a/include/mbgl/style/property_value.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MBGL_STYLE_PROPERTY_VALUE -#define MBGL_STYLE_PROPERTY_VALUE - -#include <mbgl/util/variant.hpp> -#include <mbgl/style/function_properties.hpp> -#include <mbgl/style/types.hpp> - -namespace mbgl { - -typedef mapbox::util::variant< - std::string, - TranslateAnchorType, - RotateAnchorType, - Function<bool>, - Function<float>, - Function<Color> -> PropertyValue; - -} - -#endif diff --git a/include/mbgl/style/style.hpp b/include/mbgl/style/style.hpp deleted file mode 100644 index 56f318ecbb..0000000000 --- a/include/mbgl/style/style.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MBGL_STYLE_STYLE -#define MBGL_STYLE_STYLE - -#include <mbgl/style/property_transition.hpp> -#include <mbgl/style/style_source.hpp> - -#include <mbgl/util/time.hpp> -#include <mbgl/util/uv.hpp> -#include <mbgl/util/ptr.hpp> - -#include <cstdint> -#include <map> -#include <string> -#include <unordered_map> -#include <vector> -#include <set> - -namespace mbgl { - -class Sprite; -class StyleLayer; -class StyleLayerGroup; - -class Style { -public: - struct exception : std::runtime_error { exception(const char *msg) : std::runtime_error(msg) {} }; - -public: - Style(); - ~Style(); - - void loadJSON(const uint8_t *const data); - - size_t layerCount() const; - void updateProperties(float z, timestamp t); - - void setDefaultTransitionDuration(uint16_t duration_milliseconds = 0); - - void setAppliedClasses(const std::vector<std::string> &classes); - const std::vector<std::string> &getAppliedClasses() const; - void toggleClass(const std::string &name); - - // Updates the styling information to reflect the current array - // of applied classes. - void updateClasses(); - - bool hasTransitions() const; - - const std::string &getSpriteURL() const; - -public: - util::ptr<StyleLayerGroup> layers; - std::vector<std::string> appliedClasses; - std::string glyph_url; - -private: - std::string sprite_url; - -private: - PropertyTransition defaultTransition; - bool initial_render_complete = false; - - std::unique_ptr<uv::rwlock> mtx; -}; - -} - -#endif diff --git a/include/mbgl/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp deleted file mode 100644 index d84d35d5b2..0000000000 --- a/include/mbgl/style/style_bucket.hpp +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_BUCKET -#define MBGL_STYLE_STYLE_BUCKET - -#include <mbgl/style/types.hpp> -#include <mbgl/style/filter_expression.hpp> -#include <mbgl/style/style_source.hpp> - -#include <mbgl/util/vec.hpp> -#include <mbgl/util/variant.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/ptr.hpp> - -#include <forward_list> - -namespace mbgl { - -class Source; - -class StyleBucketFill { -public: - WindingType winding = WindingType::NonZero; -}; - -class StyleBucketLine { -public: - CapType cap = CapType::Butt; - JoinType join = JoinType::Miter; - float miter_limit = 2.0f; - float round_limit = 1.0f; -}; - -class StyleBucketSymbol { -public: - // Make movable only. - inline StyleBucketSymbol() = default; - inline StyleBucketSymbol(StyleBucketSymbol &&) = default; - inline StyleBucketSymbol& operator=(StyleBucketSymbol &&) = default; - inline StyleBucketSymbol(const StyleBucketSymbol &) = delete; - inline StyleBucketSymbol& operator=(const StyleBucketSymbol &) = delete; - - PlacementType placement = PlacementType::Point; - float min_distance = 250.0f; - bool avoid_edges = false; - - struct { - bool allow_overlap = false; - bool ignore_placement = false; - bool optional = false; - RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport; - float max_size = 1.0f; - std::string image; - float rotate = 0.0f; - float padding = 2.0f; - bool keep_upright = false; - vec2<float> offset = {0, 0}; - } icon; - - struct { - RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport; - std::string field; - std::string font; - float max_size = 16.0f; - float max_width = 15.0f * 24 /* em */; - float line_height = 1.2f * 24 /* em */; - float letter_spacing = 0.0f * 24 /* em */; - TextJustifyType justify = TextJustifyType::Center; - TextAnchorType anchor = TextAnchorType::Center; - float max_angle = 45.0f /* degrees */; - float rotate = 0.0f; - float slant = 0.0f; - float padding = 2.0f; - bool keep_upright = true; - TextTransformType transform = TextTransformType::None; - vec2<float> offset = {0, 0}; - bool allow_overlap = false; - bool ignore_placement = false; - bool optional = false; - } text; -}; - -class StyleBucketRaster { -public: - bool prerendered = false; - uint16_t size = 256; - float blur = 0.0f; - float buffer = 0.03125f; -}; - -typedef mapbox::util::variant<StyleBucketFill, StyleBucketLine, StyleBucketSymbol, - StyleBucketRaster, std::false_type> StyleBucketRender; - - -class StyleBucket { -public: - typedef util::ptr<StyleBucket> Ptr; - - StyleBucket(StyleLayerType type); - - std::string name; - util::ptr<StyleSource> style_source; - std::string source_layer; - FilterExpression filter; - StyleBucketRender render = std::false_type(); - float min_zoom = -std::numeric_limits<float>::infinity(); - float max_zoom = std::numeric_limits<float>::infinity(); -}; - - - -}; - -#endif diff --git a/include/mbgl/style/style_layer.hpp b/include/mbgl/style/style_layer.hpp deleted file mode 100644 index 641dc1e71c..0000000000 --- a/include/mbgl/style/style_layer.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_LAYER -#define MBGL_STYLE_STYLE_LAYER - -#include <mbgl/style/class_dictionary.hpp> -#include <mbgl/style/class_properties.hpp> -#include <mbgl/style/style_properties.hpp> -#include <mbgl/style/applied_class_properties.hpp> - -#include <mbgl/util/ptr.hpp> - -#include <vector> -#include <string> -#include <map> -#include <set> - -namespace mbgl { - -class StyleBucket; -class StyleLayerGroup; - -class StyleLayer { -public: - StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles); - - template <typename T> const T &getProperties() { - if (properties.is<T>()) { - return properties.get<T>(); - } else { - return defaultStyleProperties<T>(); - } - } - - // Determines whether this layer is the background layer. - bool isBackground() const; - - // Updates the StyleProperties information in this layer by evaluating all - // pending transitions and applied classes in order. - void updateProperties(float z, timestamp now); - - // Sets the list of classes and creates transitions to the currently applied values. - void setClasses(const std::vector<std::string> &class_names, timestamp now, - const PropertyTransition &defaultTransition); - - bool hasTransitions() const; - -private: - // Applies all properties from a class, if they haven't been applied already. - void applyClassProperties(ClassID class_id, std::set<PropertyKey> &already_applied, - timestamp now, const PropertyTransition &defaultTransition); - - // Sets the properties of this object by evaluating all pending transitions and - // aplied classes in order. - template <typename T> void applyStyleProperties(float z, timestamp now); - template <typename T> void applyStyleProperty(PropertyKey key, T &, float z, timestamp now); - template <typename T> void applyTransitionedStyleProperty(PropertyKey key, T &, float z, timestamp now); - - // Removes all expired style transitions. - void cleanupAppliedStyleProperties(timestamp now); - -public: - // The name of this layer. - const std::string id; - - StyleLayerType type = StyleLayerType::Unknown; - - // Bucket information, telling the renderer how to generate the geometries - // for this layer (feature property filters, tessellation instructions, ...). - util::ptr<StyleBucket> bucket; - - // Contains all style classes that can be applied to this layer. - const std::map<ClassID, ClassProperties> styles; - -private: - // For every property, stores a list of applied property values, with - // optional transition times. - std::map<PropertyKey, AppliedClassProperties> appliedStyle; - -public: - // Stores the evaluated, and cascaded styling information, specific to this - // layer's type. - StyleProperties properties; - - // Child layer array (if this layer has child layers). - util::ptr<StyleLayerGroup> layers; -}; - -} - -#endif diff --git a/include/mbgl/style/style_layer_group.hpp b/include/mbgl/style/style_layer_group.hpp deleted file mode 100644 index 1af6e23bd7..0000000000 --- a/include/mbgl/style/style_layer_group.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_LAYER_GROUP -#define MBGL_STYLE_STYLE_LAYER_GROUP - -#include <mbgl/style/style_layer.hpp> - -#include <vector> - -namespace mbgl { - -class StyleLayerGroup { -public: - void setClasses(const std::vector<std::string> &class_names, timestamp now, - const PropertyTransition &defaultTransition); - void updateProperties(float z, timestamp t); - - bool hasTransitions() const; -public: - std::vector<util::ptr<StyleLayer>> layers; -}; - -} - -#endif diff --git a/include/mbgl/style/style_parser.hpp b/include/mbgl/style/style_parser.hpp deleted file mode 100644 index c37e856034..0000000000 --- a/include/mbgl/style/style_parser.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_PARSER -#define MBGL_STYLE_STYLE_PARSER - -#include <rapidjson/document.h> -#include <mbgl/style/style.hpp> -#include <mbgl/style/style_source.hpp> -#include <mbgl/style/filter_expression.hpp> -#include <mbgl/style/class_properties.hpp> -#include <mbgl/style/style_bucket.hpp> - -#include <unordered_map> -#include <forward_list> -#include <tuple> - -namespace mbgl { - -enum class ClassID : uint32_t; - -class StyleLayer; -class StyleLayerGroup; - -class StyleParser { -public: - using JSVal = const rapidjson::Value&; - - StyleParser(); - - void parse(JSVal document); - - util::ptr<StyleLayerGroup> getLayers() { - return root; - } - - std::string getSprite() const { - return sprite; - } - - std::string getGlyphURL() const { - return glyph_url; - } - -private: - void parseConstants(JSVal value); - JSVal replaceConstant(JSVal value); - - void parseSources(JSVal value); - - std::unique_ptr<StyleLayerGroup> createLayers(JSVal value); - util::ptr<StyleLayer> createLayer(JSVal value); - void parseLayers(); - void parseLayer(std::pair<JSVal, util::ptr<StyleLayer>> &pair); - void parsePaints(JSVal value, std::map<ClassID, ClassProperties> &paints); - void parsePaint(JSVal, ClassProperties &properties); - void parseReference(JSVal value, util::ptr<StyleLayer> &layer); - void parseBucket(JSVal value, util::ptr<StyleLayer> &layer); - void parseLayout(JSVal value, util::ptr<StyleLayer> &layer); - void parseSprite(JSVal value); - void parseGlyphURL(JSVal value); - - // Parses optional properties into a render bucket. - template<typename T> - bool parseRenderProperty(JSVal value, T &target, const char *name); - template <typename Parser, typename T> - bool parseRenderProperty(JSVal value, T &target, const char *name); - - // Parses optional properties into style class properties. - template <typename T> - bool parseOptionalProperty(const char *property_name, PropertyKey key, ClassProperties &klass, JSVal value); - template <typename T> - bool parseOptionalProperty(const char *property_name, const std::vector<PropertyKey> &keys, ClassProperties &klass, JSVal value); - template <typename T> - bool parseOptionalProperty(const char *property_name, T &target, JSVal value); - template <typename T> - bool setProperty(JSVal value, const char *property_name, PropertyKey key, ClassProperties &klass); - template <typename T> - bool setProperty(JSVal value, const char *property_name, T &target); - - template <typename T> - std::tuple<bool, T> parseProperty(JSVal value, const char *property_name); - - template <typename T> - bool parseFunction(PropertyKey key, ClassProperties &klass, JSVal value); - template <typename T> - std::tuple<bool, Function<T>> parseFunction(JSVal value); - template <typename T> - T parseFunctionArgument(JSVal value); - - FilterExpression parseFilter(JSVal); - -private: - std::unordered_map<std::string, const rapidjson::Value *> constants; - - std::unordered_map<std::string, const util::ptr<StyleSource>> sources; - - // This stores the root layer. - util::ptr<StyleLayerGroup> root; - - // This maps ids to Layer objects, with all items being at the root level. - std::unordered_map<std::string, std::pair<JSVal, util::ptr<StyleLayer>>> layers; - - // Store a stack of layers we're parsing right now. This is to prevent reference cycles. - std::forward_list<StyleLayer *> stack; - - // Base URL of the sprite image. - std::string sprite; - - // URL template for glyph PBFs. - std::string glyph_url; -}; - -} - -#endif diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp deleted file mode 100644 index c44b7c34c8..0000000000 --- a/include/mbgl/style/style_properties.hpp +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_PROPERTIES -#define MBGL_STYLE_STYLE_PROPERTIES - -#include <mbgl/util/variant.hpp> -#include <mbgl/style/types.hpp> -#include <mbgl/style/function_properties.hpp> - -#include <array> -#include <string> -#include <type_traits> -#include <memory> - -namespace mbgl { - -struct FillProperties { - FillProperties() {} - bool antialias = true; - float opacity = 1.0f; - Color fill_color = {{ 0, 0, 0, 1 }}; - Color stroke_color = {{ 0, 0, 0, -1 }}; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translateAnchor = TranslateAnchorType::Map; - std::string image; - - inline bool isVisible() const { - return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0); - } -}; - -struct LineProperties { - inline LineProperties() {} - float opacity = 1.0f; - Color color = {{ 0, 0, 0, 1 }}; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translateAnchor = TranslateAnchorType::Map; - float width = 1; - float gap_width = 0; - float blur = 0; - std::array<float, 2> dash_array = {{ 1, -1 }}; - std::string image; - - inline bool isVisible() const { - return opacity > 0 && color[3] > 0 && width > 0; - } -}; - -struct SymbolProperties { - inline SymbolProperties() {} - - struct { - float opacity = 1.0f; - float rotate = 0.0f; - float size = 1.0f; - Color color = {{ 0, 0, 0, 1 }}; - Color halo_color = {{ 0, 0, 0, 0 }}; - float halo_width = 0.0f; - float halo_blur = 0.0f; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translate_anchor = TranslateAnchorType::Map; - } icon; - - struct { - float opacity = 1.0f; - float size = 16.0f; - Color color = {{ 0, 0, 0, 1 }}; - Color halo_color = {{ 0, 0, 0, 0 }}; - float halo_width = 0.0f; - float halo_blur = 0.0f; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translate_anchor = TranslateAnchorType::Map; - } text; - - inline bool isVisible() const { - return (icon.opacity > 0 && (icon.color[3] > 0 || icon.halo_color[3] > 0) && icon.size > 0) || - (text.opacity > 0 && (text.color[3] > 0 || text.halo_color[3] > 0) && text.size > 0); - } -}; - -struct RasterProperties { - inline RasterProperties() {} - float opacity = 1.0f; - float hue_rotate = 0.0f; - std::array<float, 2> brightness = {{ 0, 1 }}; - float saturation = 0.0f; - float contrast = 0.0f; - float fade = 0.0f; - - inline bool isVisible() const { - return opacity > 0; - } -}; - -struct BackgroundProperties { - inline BackgroundProperties() {} - float opacity = 1.0f; - Color color = {{ 0, 0, 0, 1 }}; - std::string image; -}; - -typedef mapbox::util::variant< - FillProperties, - LineProperties, - SymbolProperties, - RasterProperties, - BackgroundProperties, - std::false_type -> StyleProperties; - -template <typename T> -const T &defaultStyleProperties(); - -} - -#endif diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp deleted file mode 100644 index 8c7d028880..0000000000 --- a/include/mbgl/style/style_source.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_SOURCE -#define MBGL_STYLE_STYLE_SOURCE - -#include <mbgl/style/types.hpp> -#include <mbgl/util/ptr.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <rapidjson/document.h> - -#include <vector> -#include <string> - -namespace mbgl { - -class Source; - -class SourceInfo : private util::noncopyable { -public: - SourceType type = SourceType::Vector; - std::string url; - std::vector<std::string> tiles; - uint16_t tile_size = 512; - uint16_t min_zoom = 0; - uint16_t max_zoom = 22; - std::string attribution; - std::array<float, 3> center = {{0, 0, 0}}; - std::array<float, 4> bounds = {{-180, -90, 180, 90}}; - - void parseTileJSONProperties(const rapidjson::Value&); -}; - - -class StyleSource : private util::noncopyable { -public: - SourceInfo info; - bool enabled = false; - util::ptr<Source> source; -}; - -} - -#endif diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp deleted file mode 100644 index 2f7ca7683d..0000000000 --- a/include/mbgl/style/types.hpp +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef MBGL_STYLE_TYPES -#define MBGL_STYLE_TYPES - -#include <mbgl/util/enum.hpp> - -#include <string> -#include <array> - -namespace mbgl { - -// Stores a premultiplied color, with all four channels ranging from 0..1 -typedef std::array<float, 4> Color; - -// ------------------------------------------------------------------------------------------------- - -enum class StyleLayerType : uint8_t { - Unknown, - Fill, - Line, - Symbol, - Raster, - Background -}; - -MBGL_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, { - { StyleLayerType::Unknown, "unknown" }, - { StyleLayerType::Fill, "fill" }, - { StyleLayerType::Line, "line" }, - { StyleLayerType::Symbol, "symbol" }, - { StyleLayerType::Raster, "raster" }, - { StyleLayerType::Background, "background" }, - { StyleLayerType(-1), "unknown" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class SourceType : uint8_t { - Vector, - Raster, - GeoJSON, - Video -}; - -MBGL_DEFINE_ENUM_CLASS(SourceTypeClass, SourceType, { - { SourceType::Vector, "vector" }, - { SourceType::Raster, "raster" }, - { SourceType::GeoJSON, "geojson" }, - { SourceType::Video, "video" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class WindingType : bool { - EvenOdd, - NonZero, -}; - -MBGL_DEFINE_ENUM_CLASS(WindingTypeClass, WindingType, { - { WindingType::EvenOdd, "even-odd" }, - { WindingType::NonZero, "non-zero" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class CapType : uint8_t { - Round, - Butt, - Square, -}; - -MBGL_DEFINE_ENUM_CLASS(CapTypeClass, CapType, { - { CapType::Round, "round" }, - { CapType::Butt, "butt" }, - { CapType::Square, "square" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class JoinType : uint8_t { - Miter, - Bevel, - Round -}; - -MBGL_DEFINE_ENUM_CLASS(JoinTypeClass, JoinType, { - { JoinType::Miter, "miter" }, - { JoinType::Bevel, "bevel" }, - { JoinType::Round, "round" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class TranslateAnchorType : bool { - Map, - Viewport -}; - -MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, { - { TranslateAnchorType::Map, "map" }, - { TranslateAnchorType::Viewport, "viewport" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class RotateAnchorType : bool { - Map, - Viewport, -}; - -MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, { - { RotateAnchorType::Map, "map" }, - { RotateAnchorType::Viewport, "viewport" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class PlacementType : bool { - Point, - Line, -}; - -MBGL_DEFINE_ENUM_CLASS(PlacementTypeClass, PlacementType, { - { PlacementType::Point, "point" }, - { PlacementType::Line, "line" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class RotationAlignmentType : bool { - Map, - Viewport, -}; - -MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, { - { RotationAlignmentType::Map, "map" }, - { RotationAlignmentType::Viewport, "viewport" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class TextJustifyType : uint8_t { - Center, - Left, - Right -}; - -MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, { - { TextJustifyType::Center, "center" }, - { TextJustifyType::Left, "left" }, - { TextJustifyType::Right, "right" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class TextAnchorType : uint8_t { - Center, - Left, - Right, - Top, - Bottom, - TopLeft, - TopRight, - BottomLeft, - BottomRight -}; - -MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, { - { TextAnchorType::Center, "center" }, - { TextAnchorType::Left, "left" }, - { TextAnchorType::Right, "right" }, - { TextAnchorType::Top, "top" }, - { TextAnchorType::Bottom, "bottom" }, - { TextAnchorType::TopLeft, "top-left" }, - { TextAnchorType::TopRight, "top-right" }, - { TextAnchorType::BottomLeft, "bottom-left" }, - { TextAnchorType::BottomRight, "bottom-right" } -}); - -// ------------------------------------------------------------------------------------------------- - -enum class TextTransformType : uint8_t { - None, - Uppercase, - Lowercase, -}; - -MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, { - { TextTransformType::None, "none" }, - { TextTransformType::Uppercase, "uppercase" }, - { TextTransformType::Lowercase, "lowercase" }, -}); - -} - -#endif - diff --git a/include/mbgl/style/value.hpp b/include/mbgl/style/value.hpp deleted file mode 100644 index 87d6f4cda3..0000000000 --- a/include/mbgl/style/value.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MBGL_STYLE_VALUE -#define MBGL_STYLE_VALUE - -#include <mbgl/util/variant.hpp> -#include <mbgl/util/pbf.hpp> -#include <rapidjson/document.h> - -#include <cstdlib> -#include <cerrno> - -namespace mbgl { - -typedef mapbox::util::variant<bool, int64_t, uint64_t, double, std::string> Value; - -std::string toString(const Value &value); - -Value parseValue(pbf data); -Value parseValue(const rapidjson::Value&); - -namespace util { -inline bool parseNumericString(const std::string &str, double &result) { - char *end = nullptr; - const char *begin = str.c_str(); - result = std::strtod(begin, &end); - while (*end != '\0' && isspace(*end)) end++; // eat whitespace after the end - return errno == 0 && end - begin == long(str.size()); -} -} - -template <typename T> -T toNumber(const Value &value) { - if (value.is<std::string>()) { - double val; - return util::parseNumericString(value.get<std::string>(), val) ? val : 0; - } - else if (value.is<bool>()) return value.get<bool>(); - else if (value.is<int64_t>()) return value.get<int64_t>(); - else if (value.is<uint64_t>()) return value.get<uint64_t>(); - else if (value.is<double>()) return value.get<double>(); - else return 0; -} - -} - -#endif diff --git a/include/mbgl/style/value_comparison.hpp b/include/mbgl/style/value_comparison.hpp deleted file mode 100644 index 98e29afa7c..0000000000 --- a/include/mbgl/style/value_comparison.hpp +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef MBGL_STYLE_VALUE_COMPARISON -#define MBGL_STYLE_VALUE_COMPARISON - -#include "value.hpp" -#include <cstdlib> -#include <cerrno> - -namespace mbgl { - -namespace util { - -namespace detail { - -template <typename Operator> -struct relaxed_operator_visitor { - typedef bool result_type; - - template <typename T0, typename T1> - inline bool operator()(T0, T1) const { return false; } - - template <typename T> - inline bool operator()(T lhs, T rhs) const { return Operator()(lhs, rhs); } - - inline bool operator()(int64_t lhs, uint64_t rhs) const { - return Operator()(double(lhs), double(rhs)); - } - - inline bool operator()(int64_t lhs, double rhs) const { - return Operator()(double(lhs), rhs); - } - - inline bool operator()(uint64_t lhs, int64_t rhs) const { - return Operator()(double(lhs), double(rhs)); - } - - inline bool operator()(uint64_t lhs, double rhs) const { - return Operator()(double(lhs), rhs); - } - - inline bool operator()(double lhs, uint64_t rhs) const { - return Operator()(lhs, double(rhs)); - } - - inline bool operator()(double lhs, int64_t rhs) const { - return Operator()(lhs, double(rhs)); - } -}; - -struct relaxed_equal_operator { - template <typename T0, typename T1> - inline bool operator()(T0 lhs, T1 rhs) const { return lhs == rhs; } -}; - -struct relaxed_not_equal_operator { - template <typename T0, typename T1> - inline bool operator()(T0 lhs, T1 rhs) const { return lhs != rhs; } -}; - -struct relaxed_greater_operator { - template <typename T0, typename T1> - inline bool operator()(T0 lhs, T1 rhs) const { return lhs > rhs; } -}; - -struct relaxed_greater_equal_operator { - template <typename T0, typename T1> - inline bool operator()(T0 lhs, T1 rhs) const { return lhs >= rhs; } -}; - -struct relaxed_less_operator { - template <typename T0, typename T1> - inline bool operator()(T0 lhs, T1 rhs) const { return lhs < rhs; } -}; - -struct relaxed_less_equal_operator { - template <typename T0, typename T1> - inline bool operator()(T0 lhs, T1 rhs) const { return lhs <= rhs; } -}; - -} // end namespace detail - -inline bool relaxed_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_equal_operator>(), lhs, rhs); -} - -inline bool relaxed_not_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_not_equal_operator>(), lhs, rhs); -} - -inline bool relaxed_greater(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_operator>(), lhs, rhs); -} - -inline bool relaxed_greater_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_equal_operator>(), lhs, rhs); -} - -inline bool relaxed_less(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_less_operator>(), lhs, rhs); -} - -inline bool relaxed_less_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_less_equal_operator>(), lhs, rhs); -} - -} - -} - -#endif |