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

[core] Implement circle-stroke properties #7356

Merged
merged 2 commits into from
Dec 9, 2016
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
6 changes: 6 additions & 0 deletions cmake/core-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ set(MBGL_CORE_FILES
include/mbgl/style/layers/background_layer.hpp
include/mbgl/style/layers/circle_layer.hpp
include/mbgl/style/layers/custom_layer.hpp
include/mbgl/style/layers/fill_extrusion_layer.hpp
include/mbgl/style/layers/fill_layer.hpp
include/mbgl/style/layers/line_layer.hpp
include/mbgl/style/layers/raster_layer.hpp
Expand All @@ -282,6 +283,11 @@ set(MBGL_CORE_FILES
src/mbgl/style/layers/custom_layer.cpp
src/mbgl/style/layers/custom_layer_impl.cpp
src/mbgl/style/layers/custom_layer_impl.hpp
src/mbgl/style/layers/fill_extrusion_layer.cpp
src/mbgl/style/layers/fill_extrusion_layer_impl.cpp
src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
src/mbgl/style/layers/fill_extrusion_layer_properties.cpp
src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
src/mbgl/style/layers/fill_layer.cpp
src/mbgl/style/layers/fill_layer_impl.cpp
src/mbgl/style/layers/fill_layer_impl.hpp
Expand Down
13 changes: 13 additions & 0 deletions include/mbgl/style/conversion/make_property_setters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/background_layer.hpp>

Expand Down Expand Up @@ -67,6 +68,7 @@ auto makeLayoutPropertySetters() {




return result;
}

Expand Down Expand Up @@ -115,6 +117,17 @@ auto makePaintPropertySetters() {
result["circle-translate"] = makePropertySetter<V>(&CircleLayer::setCircleTranslate);
result["circle-translate-anchor"] = makePropertySetter<V>(&CircleLayer::setCircleTranslateAnchor);
result["circle-pitch-scale"] = makePropertySetter<V>(&CircleLayer::setCirclePitchScale);
result["circle-stroke-width"] = makePropertySetter<V>(&CircleLayer::setCircleStrokeWidth);
result["circle-stroke-color"] = makePropertySetter<V>(&CircleLayer::setCircleStrokeColor);
result["circle-stroke-opacity"] = makePropertySetter<V>(&CircleLayer::setCircleStrokeOpacity);

result["fill-extrusion-opacity"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionOpacity);
result["fill-extrusion-color"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionColor);
result["fill-extrusion-translate"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionTranslate);
result["fill-extrusion-translate-anchor"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionTranslateAnchor);
result["fill-extrusion-pattern"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionPattern);
result["fill-extrusion-height"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionHeight);
result["fill-extrusion-base"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionBase);

result["raster-opacity"] = makePropertySetter<V>(&RasterLayer::setRasterOpacity);
result["raster-hue-rotate"] = makePropertySetter<V>(&RasterLayer::setRasterHueRotate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <mbgl/style/conversion/property_setter.hpp>

<% for (const layer of locals.layers) { -%>
#include <mbgl/style/layers/<%- layer.type %>_layer.hpp>
#include <mbgl/style/layers/<%- layer.type.replace('-', '_') %>_layer.hpp>
<% } -%>

#include <unordered_map>
Expand Down
4 changes: 4 additions & 0 deletions include/mbgl/style/layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SymbolLayer;
class RasterLayer;
class BackgroundLayer;
class CustomLayer;
class FillExtrusionLayer;

/**
* The runtime representation of a [layer](https://www.mapbox.com/mapbox-gl-style-spec/#layers) from the Mapbox Style
Expand Down Expand Up @@ -42,6 +43,7 @@ class Layer : public mbgl::util::noncopyable {
Raster,
Background,
Custom,
FillExtrusion,
};

class Impl;
Expand Down Expand Up @@ -95,6 +97,8 @@ class Layer : public mbgl::util::noncopyable {
return visitor(*as<BackgroundLayer>());
case Type::Custom:
return visitor(*as<CustomLayer>());
case Type::FillExtrusion:
return visitor(*as<FillExtrusionLayer>());
}
}

Expand Down
12 changes: 12 additions & 0 deletions include/mbgl/style/layers/circle_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ class CircleLayer : public Layer {
PropertyValue<CirclePitchScaleType> getCirclePitchScale(const optional<std::string>& klass = {}) const;
void setCirclePitchScale(PropertyValue<CirclePitchScaleType>, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultCircleStrokeWidth();
PropertyValue<float> getCircleStrokeWidth(const optional<std::string>& klass = {}) const;
void setCircleStrokeWidth(PropertyValue<float>, const optional<std::string>& klass = {});

static PropertyValue<Color> getDefaultCircleStrokeColor();
PropertyValue<Color> getCircleStrokeColor(const optional<std::string>& klass = {}) const;
void setCircleStrokeColor(PropertyValue<Color>, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultCircleStrokeOpacity();
PropertyValue<float> getCircleStrokeOpacity(const optional<std::string>& klass = {}) const;
void setCircleStrokeOpacity(PropertyValue<float>, const optional<std::string>& klass = {});

// Private implementation

class Impl;
Expand Down
72 changes: 72 additions & 0 deletions include/mbgl/style/layers/fill_extrusion_layer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// 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/util/color.hpp>

namespace mbgl {
namespace style {

class FillExtrusionLayer : public Layer {
public:
FillExtrusionLayer(const std::string& layerID, const std::string& sourceID);
~FillExtrusionLayer() final;

// Source
const std::string& getSourceID() const;
const std::string& getSourceLayer() const;
void setSourceLayer(const std::string& sourceLayer);

void setFilter(const Filter&);
const Filter& getFilter() const;

// Paint properties

static PropertyValue<float> getDefaultFillExtrusionOpacity();
PropertyValue<float> getFillExtrusionOpacity(const optional<std::string>& klass = {}) const;
void setFillExtrusionOpacity(PropertyValue<float>, const optional<std::string>& klass = {});

static PropertyValue<Color> getDefaultFillExtrusionColor();
PropertyValue<Color> getFillExtrusionColor(const optional<std::string>& klass = {}) const;
void setFillExtrusionColor(PropertyValue<Color>, const optional<std::string>& klass = {});

static PropertyValue<std::array<float, 2>> getDefaultFillExtrusionTranslate();
PropertyValue<std::array<float, 2>> getFillExtrusionTranslate(const optional<std::string>& klass = {}) const;
void setFillExtrusionTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {});

static PropertyValue<TranslateAnchorType> getDefaultFillExtrusionTranslateAnchor();
PropertyValue<TranslateAnchorType> getFillExtrusionTranslateAnchor(const optional<std::string>& klass = {}) const;
void setFillExtrusionTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});

static PropertyValue<std::string> getDefaultFillExtrusionPattern();
PropertyValue<std::string> getFillExtrusionPattern(const optional<std::string>& klass = {}) const;
void setFillExtrusionPattern(PropertyValue<std::string>, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultFillExtrusionHeight();
PropertyValue<float> getFillExtrusionHeight(const optional<std::string>& klass = {}) const;
void setFillExtrusionHeight(PropertyValue<float>, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultFillExtrusionBase();
PropertyValue<float> getFillExtrusionBase(const optional<std::string>& klass = {}) const;
void setFillExtrusionBase(PropertyValue<float>, const optional<std::string>& klass = {});

// Private implementation

class Impl;
Impl* const impl;

FillExtrusionLayer(const Impl&);
FillExtrusionLayer(const FillExtrusionLayer&) = delete;
};

template <>
inline bool Layer::is<FillExtrusionLayer>() const {
return type == Type::FillExtrusion;
}

} // namespace style
} // namespace mbgl
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"ejs": "^2.4.1",
"express": "^4.11.1",
"lodash": "^4.16.4",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#597115a1e1bd982944b068f8accde34eada74fc2",
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#7f62a4fc9f21e619824d68abbc4b03cbc1685572",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#0c6f3e00193248474349cd730e232eb5ffcd9bf4",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#b51b85ffb8c512e228c36c5405293ce51d123519",
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#49e8b407bdbbe6f7c92dbcb56d3d51f425fc2653",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#9252ffc5108131704b5acf52d78258ac05687871",
"mkdirp": "^0.5.1",
"node-cmake": "^1.2.1",
"request": "^2.72.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,52 @@ public PropertyValue<String> getCirclePitchScale() {
return (PropertyValue<String>) new PropertyValue(nativeGetCirclePitchScale());
}

/**
* Get the CircleStrokeWidth property
*
* @return property wrapper value around Float
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleStrokeWidth() {
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleStrokeWidth());
}

/**
* Get the CircleStrokeColor property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleStrokeColor() {
return (PropertyValue<String>) new PropertyValue(nativeGetCircleStrokeColor());
}
/**
* The stroke color of the circle.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getCircleStrokeColorAsInt() {
PropertyValue<String> value = getCircleStrokeColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("circle-stroke-color was set as a Function");
}
}


/**
* Get the CircleStrokeOpacity property
*
* @return property wrapper value around Float
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleStrokeOpacity() {
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleStrokeOpacity());
}

private native Object nativeGetCircleRadius();

private native Object nativeGetCircleColor();
Expand All @@ -210,6 +256,12 @@ public PropertyValue<String> getCirclePitchScale() {

private native Object nativeGetCirclePitchScale();

private native Object nativeGetCircleStrokeWidth();

private native Object nativeGetCircleStrokeColor();

private native Object nativeGetCircleStrokeOpacity();


@Override
protected native void finalize() throws Throwable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,76 @@ public static Property<Function<String>> circlePitchScale(Function<String> funct
return new PaintProperty<>("circle-pitch-scale", function);
}

/**
* The width of the circle's stroke. Strokes are placed outside of the "circle-radius".
*
* @param value a Float value
* @return property wrapper around Float
*/
public static Property<Float> circleStrokeWidth(Float value) {
return new PaintProperty<>("circle-stroke-width", value);
}

/**
* The width of the circle's stroke. Strokes are placed outside of the "circle-radius".
*
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static Property<Function<Float>> circleStrokeWidth(Function<Float> function) {
return new PaintProperty<>("circle-stroke-width", function);
}

/**
* The stroke color of the circle.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static Property<String> circleStrokeColor(@ColorInt int value) {
return new PaintProperty<>("circle-stroke-color", colorToRgbaString(value));
}

/**
* The stroke color of the circle.
*
* @param value a String value
* @return property wrapper around String
*/
public static Property<String> circleStrokeColor(String value) {
return new PaintProperty<>("circle-stroke-color", value);
}

/**
* The stroke color of the circle.
*
* @param function a wrapper function for String
* @return property wrapper around a String function
*/
public static Property<Function<String>> circleStrokeColor(Function<String> function) {
return new PaintProperty<>("circle-stroke-color", function);
}

/**
* The opacity of the circle's stroke.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static Property<Float> circleStrokeOpacity(Float value) {
return new PaintProperty<>("circle-stroke-opacity", value);
}

/**
* The opacity of the circle's stroke.
*
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static Property<Function<Float>> circleStrokeOpacity(Function<Float> function) {
return new PaintProperty<>("circle-stroke-opacity", function);
}

/**
* The opacity at which the image will be drawn.
*
Expand Down
Loading