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

Update shaders: get 'icon-pitch-alignment' and fix for issue #9456 #9479

Merged
merged 2 commits into from
Jul 12, 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
1 change: 1 addition & 0 deletions include/mbgl/style/conversion/make_property_setters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ auto makeLayoutPropertySetters() {
result["icon-padding"] = &setProperty<V, SymbolLayer, PropertyValue<float>, &SymbolLayer::setIconPadding>;
result["icon-keep-upright"] = &setProperty<V, SymbolLayer, PropertyValue<bool>, &SymbolLayer::setIconKeepUpright>;
result["icon-offset"] = &setProperty<V, SymbolLayer, DataDrivenPropertyValue<std::array<float, 2>>, &SymbolLayer::setIconOffset>;
result["icon-pitch-alignment"] = &setProperty<V, SymbolLayer, PropertyValue<AlignmentType>, &SymbolLayer::setIconPitchAlignment>;
result["text-pitch-alignment"] = &setProperty<V, SymbolLayer, PropertyValue<AlignmentType>, &SymbolLayer::setTextPitchAlignment>;
result["text-rotation-alignment"] = &setProperty<V, SymbolLayer, PropertyValue<AlignmentType>, &SymbolLayer::setTextRotationAlignment>;
result["text-field"] = &setProperty<V, SymbolLayer, DataDrivenPropertyValue<std::string>, &SymbolLayer::setTextField>;
Expand Down
4 changes: 4 additions & 0 deletions include/mbgl/style/layers/symbol_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class SymbolLayer : public Layer {
DataDrivenPropertyValue<std::array<float, 2>> getIconOffset() const;
void setIconOffset(DataDrivenPropertyValue<std::array<float, 2>>);

static PropertyValue<AlignmentType> getDefaultIconPitchAlignment();
PropertyValue<AlignmentType> getIconPitchAlignment() const;
void setIconPitchAlignment(PropertyValue<AlignmentType>);

static PropertyValue<AlignmentType> getDefaultTextPitchAlignment();
PropertyValue<AlignmentType> getTextPitchAlignment() const;
void setTextPitchAlignment(PropertyValue<AlignmentType>);
Expand Down
4 changes: 4 additions & 0 deletions include/mbgl/util/size.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Size {
constexpr uint32_t area() const {
return width * height;
}

constexpr float aspectRatio() const {
return static_cast<float>(width) / static_cast<float>(height);
}

constexpr bool isEmpty() const {
return width == 0 || height == 0;
Expand Down
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 36 files
+8 −1 build/generate-flow-typed-style-spec.js
+19 −19 flow-typed/style-spec.js
+9 −3 src/data/bucket.js
+4 −6 src/data/bucket/symbol_bucket.js
+2 −7 src/data/feature_index.js
+1 −1 src/data/program_configuration.js
+17 −5 src/source/canvas_source.js
+34 −11 src/source/geojson_source.js
+1 −1 src/source/geojson_worker_source.js
+41 −15 src/source/image_source.js
+77 −57 src/source/raster_tile_source.js
+73 −162 src/source/source.js
+10 −1 src/source/tile.js
+41 −19 src/source/vector_tile_source.js
+1 −1 src/source/vector_tile_worker_source.js
+35 −24 src/source/video_source.js
+1 −1 src/source/worker.js
+94 −0 src/source/worker_source.js
+4 −6 src/source/worker_tile.js
+24 −12 src/style/image_sprite.js
+68 −31 src/style/style_layer.js
+5 −2 src/style/style_layer/circle_style_layer.js
+7 −3 src/style/style_layer/fill_extrusion_style_layer.js
+11 −7 src/style/style_layer/fill_style_layer.js
+5 −2 src/style/style_layer/line_style_layer.js
+9 −3 src/style/style_layer/symbol_style_layer.js
+0 −3 test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/style.json
+0 −3 test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-viewport/style.json
+0 −3 test/integration/render-tests/icon-pitch-alignment/map-rotation-alignment-viewport/style.json
+0 −3 test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/style.json
+0 −3 test/integration/render-tests/regressions/mapbox-gl-js#4860/style.json
+6 −6 test/unit/data/bucket.test.js
+5 −5 test/unit/data/symbol_bucket.test.js
+1 −1 test/unit/style/style.test.js
+7 −7 test/unit/style/style_layer_index.test.js
+15 −15 test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,32 @@ public final class Property {
@Retention(RetentionPolicy.SOURCE)
public @interface ICON_TEXT_FIT {}

// ICON_PITCH_ALIGNMENT: Orientation of icon when map is pitched.

/**
* The icon is aligned to the plane of the map.
*/
public static final String ICON_PITCH_ALIGNMENT_MAP = "map";
/**
* The icon is aligned to the plane of the viewport.
*/
public static final String ICON_PITCH_ALIGNMENT_VIEWPORT = "viewport";
/**
* Automatically matches the value of {@link ICON_ROTATION_ALIGNMENT}.
*/
public static final String ICON_PITCH_ALIGNMENT_AUTO = "auto";

/**
* Orientation of icon when map is pitched.
*/
@StringDef({
ICON_PITCH_ALIGNMENT_MAP,
ICON_PITCH_ALIGNMENT_VIEWPORT,
ICON_PITCH_ALIGNMENT_AUTO,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ICON_PITCH_ALIGNMENT {}

// TEXT_PITCH_ALIGNMENT: Orientation of text when map is pitched.

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,29 @@ public static <T> PropertyValue<Function<T, Float[]>> iconOffset(Function<T, Flo
return new LayoutPropertyValue<>("icon-offset", function);
}

/**
* Orientation of icon when map is pitched.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> iconPitchAlignment(@Property.ICON_PITCH_ALIGNMENT String value) {
return new LayoutPropertyValue<>("icon-pitch-alignment", value);
}



/**
* Orientation of icon when map is pitched.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @return property wrapper around a String function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> iconPitchAlignment(CameraFunction<Z, String> function) {
return new LayoutPropertyValue<>("icon-pitch-alignment", function);
}

/**
* Orientation of text when map is pitched.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ public PropertyValue<Float[]> getIconOffset() {
return (PropertyValue<Float[]>) new PropertyValue("icon-offset", nativeGetIconOffset());
}

/**
* Get the IconPitchAlignment property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getIconPitchAlignment() {
return (PropertyValue<String>) new PropertyValue("icon-pitch-alignment", nativeGetIconPitchAlignment());
}

/**
* Get the TextPitchAlignment property
*
Expand Down Expand Up @@ -891,6 +901,8 @@ public PropertyValue<String> getTextTranslateAnchor() {

private native Object nativeGetIconOffset();

private native Object nativeGetIconPitchAlignment();

private native Object nativeGetTextPitchAlignment();

private native Object nativeGetTextRotationAlignment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public void setAnchor(@Property.ANCHOR String anchor) {
*
* @return anchor as String
*/
@Property.ANCHOR
public String getAnchor() {
@Property.ANCHOR public String getAnchor() {
return nativeGetAnchor();
}

Expand Down Expand Up @@ -107,7 +106,7 @@ public void setColor(String color) {
*
* @return color as String
*/
public String getColor() {
public String getColor() {
return nativeGetColor();
}

Expand Down Expand Up @@ -143,7 +142,7 @@ public void setIntensity(float intensity) {
*
* @return intensity as Float
*/
public float getIntensity() {
public float getIntensity() {
return nativeGetIntensity();
}

Expand All @@ -166,30 +165,17 @@ public void setIntensityTransition(TransitionOptions options) {
}

private native void nativeSetAnchor(String anchor);

private native String nativeGetAnchor();

private native void nativeSetPosition(Position position);

private native Position nativeGetPosition();

private native TransitionOptions nativeGetPositionTransition();

private native void nativeSetPositionTransition(long duration, long delay);

private native void nativeSetColor(String color);

private native String nativeGetColor();

private native TransitionOptions nativeGetColorTransition();

private native void nativeSetColorTransition(long duration, long delay);

private native void nativeSetIntensity(float intensity);

private native float nativeGetIntensity();

private native TransitionOptions nativeGetIntensityTransition();

private native void nativeSetIntensityTransition(long duration, long delay);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1052,37 +1052,47 @@ public void testCirclePitchAlignmentAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-pitch-alignment");
assertNotNull(layer);
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
@Override
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
assertNotNull(layer);

// Set and Get
layer.setProperties(circlePitchAlignment(CIRCLE_PITCH_ALIGNMENT_MAP));
assertEquals((String) layer.getCirclePitchAlignment().getValue(), (String) CIRCLE_PITCH_ALIGNMENT_MAP);
// Set and Get
layer.setProperties(circlePitchAlignment(CIRCLE_PITCH_ALIGNMENT_MAP));
assertEquals((String) layer.getCirclePitchAlignment().getValue(), (String) CIRCLE_PITCH_ALIGNMENT_MAP);
}
});
}

@Test
public void testCirclePitchAlignmentAsCameraFunction() {
validateTestSetup();
setupLayer();
Timber.i("circle-pitch-alignment");
assertNotNull(layer);

// Set
layer.setProperties(
circlePitchAlignment(
zoom(
interval(
stop(2, circlePitchAlignment(CIRCLE_PITCH_ALIGNMENT_MAP))
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
@Override
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
assertNotNull(layer);

// Set
layer.setProperties(
circlePitchAlignment(
zoom(
interval(
stop(2, circlePitchAlignment(CIRCLE_PITCH_ALIGNMENT_MAP))
)
)
)
)
)
);

// Verify
assertNotNull(layer.getCirclePitchAlignment());
assertNotNull(layer.getCirclePitchAlignment().getFunction());
assertEquals(CameraFunction.class, layer.getCirclePitchAlignment().getFunction().getClass());
assertEquals(IntervalStops.class, layer.getCirclePitchAlignment().getFunction().getStops().getClass());
assertEquals(1, ((IntervalStops) layer.getCirclePitchAlignment().getFunction().getStops()).size());
);

// Verify
assertNotNull(layer.getCirclePitchAlignment());
assertNotNull(layer.getCirclePitchAlignment().getFunction());
assertEquals(CameraFunction.class, layer.getCirclePitchAlignment().getFunction().getClass());
assertEquals(IntervalStops.class, layer.getCirclePitchAlignment().getFunction().getStops().getClass());
assertEquals(1, ((IntervalStops) layer.getCirclePitchAlignment().getFunction().getStops()).size());
}
});
}

@Test
Expand Down
Loading