Use latest MapLibre Style Spec (#2756)
This commit is contained in:
@@ -70,6 +70,19 @@ jni::Local<jni::Object<>> LocationIndicatorLayer::getBearing(jni::JNIEnv& env) {
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getBearing()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getBearingTransition(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getBearingTransition();
|
||||
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
|
||||
}
|
||||
|
||||
void LocationIndicatorLayer::setBearingTransition(jni::JNIEnv&, jlong duration, jlong delay) {
|
||||
mbgl::style::TransitionOptions options;
|
||||
options.duration.emplace(mbgl::Milliseconds(duration));
|
||||
options.delay.emplace(mbgl::Milliseconds(delay));
|
||||
toLocationIndicatorLayer(layer).setBearingTransition(options);
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> LocationIndicatorLayer::getLocation(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getLocation()));
|
||||
@@ -244,6 +257,8 @@ void LocationIndicatorJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&LocationIndicatorLayer::getShadowImage, "nativeGetShadowImage"),
|
||||
METHOD(&LocationIndicatorLayer::getPerspectiveCompensation, "nativeGetPerspectiveCompensation"),
|
||||
METHOD(&LocationIndicatorLayer::getImageTiltDisplacement, "nativeGetImageTiltDisplacement"),
|
||||
METHOD(&LocationIndicatorLayer::getBearingTransition, "nativeGetBearingTransition"),
|
||||
METHOD(&LocationIndicatorLayer::setBearingTransition, "nativeSetBearingTransition"),
|
||||
METHOD(&LocationIndicatorLayer::getBearing, "nativeGetBearing"),
|
||||
METHOD(&LocationIndicatorLayer::getLocationTransition, "nativeGetLocationTransition"),
|
||||
METHOD(&LocationIndicatorLayer::setLocationTransition, "nativeSetLocationTransition"),
|
||||
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getImageTiltDisplacement(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getBearing(jni::JNIEnv&);
|
||||
void setBearingTransition(jni::JNIEnv&, jlong duration, jlong delay);
|
||||
jni::Local<jni::Object<TransitionOptions>> getBearingTransition(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getLocation(jni::JNIEnv&);
|
||||
void setLocationTransition(jni::JNIEnv&, jlong duration, jlong delay);
|
||||
|
||||
@@ -134,6 +134,27 @@ class LocationIndicatorLayer extends Layer {
|
||||
return (PropertyValue<Double>) new PropertyValue("bearing", nativeGetBearing());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Bearing property transition options
|
||||
*
|
||||
* @return transition options for Double
|
||||
*/
|
||||
@NonNull
|
||||
public TransitionOptions getBearingTransition() {
|
||||
checkThread();
|
||||
return nativeGetBearingTransition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Bearing property transition options
|
||||
*
|
||||
* @param options transition options for Double
|
||||
*/
|
||||
public void setBearingTransition(@NonNull TransitionOptions options) {
|
||||
checkThread();
|
||||
nativeSetBearingTransition(options.getDuration(), options.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Location property
|
||||
*
|
||||
@@ -423,6 +444,13 @@ class LocationIndicatorLayer extends Layer {
|
||||
@Keep
|
||||
private native Object nativeGetBearing();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native TransitionOptions nativeGetBearingTransition();
|
||||
|
||||
@Keep
|
||||
private native void nativeSetBearingTransition(long duration, long delay);
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetLocation();
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.maplibre.android.style.expressions.Expression;
|
||||
import org.maplibre.android.style.layers.TransitionOptions;
|
||||
|
||||
/**
|
||||
* Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles.
|
||||
* Client-side hillshading visualization based on DEM data. The implementation supports Mapbox Terrain RGB, Mapzen Terrarium tiles and custom encodings.
|
||||
*
|
||||
* @see <a href="https://maplibre.org/maplibre-style-spec/#layers-hillshade">The online documentation</a>
|
||||
*/
|
||||
|
||||
@@ -108,23 +108,23 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SYMBOL_PLACEMENT {}
|
||||
|
||||
// SYMBOL_Z_ORDER: Controls the order in which overlapping symbols in the same layer are rendered
|
||||
// SYMBOL_Z_ORDER: Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their y-position relative to the viewport. To control the order and prioritization of symbols otherwise, use `symbol-sort-key`.
|
||||
|
||||
/**
|
||||
* If symbol sort key is set, sort based on that. Otherwise sort symbols by their y-position relative to the viewport.
|
||||
* Sorts symbols by symbol sort key if set. Otherwise, sorts symbols by their y-position relative to the viewport if {@link ICON_ALLOW_OVERLAP} or {@link TEXT_ALLOW_OVERLAP} is set to {@link TRUE} or {@link ICON_IGNORE_PLACEMENT} or {@link TEXT_IGNORE_PLACEMENT} is {@link FALSE}.
|
||||
*/
|
||||
public static final String SYMBOL_Z_ORDER_AUTO = "auto";
|
||||
/**
|
||||
* Symbols will be sorted by their y-position relative to the viewport.
|
||||
* Sorts symbols by their y-position relative to the viewport if {@link ICON_ALLOW_OVERLAP} or {@link TEXT_ALLOW_OVERLAP} is set to {@link TRUE} or {@link ICON_IGNORE_PLACEMENT} or {@link TEXT_IGNORE_PLACEMENT} is {@link FALSE}.
|
||||
*/
|
||||
public static final String SYMBOL_Z_ORDER_VIEWPORT_Y = "viewport-y";
|
||||
/**
|
||||
* Symbols will be rendered in the same order as the source data with no sorting applied.
|
||||
* Sorts symbols by symbol sort key if set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data.
|
||||
*/
|
||||
public static final String SYMBOL_Z_ORDER_SOURCE = "source";
|
||||
|
||||
/**
|
||||
* Controls the order in which overlapping symbols in the same layer are rendered
|
||||
* Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their y-position relative to the viewport. To control the order and prioritization of symbols otherwise, use `symbol-sort-key`.
|
||||
*/
|
||||
@StringDef({
|
||||
SYMBOL_Z_ORDER_AUTO,
|
||||
|
||||
@@ -446,7 +446,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* The color of the icon. This can only be used with sdf icons.
|
||||
* The color of the icon. This can only be used with SDF icons.
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
@@ -456,7 +456,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* The color of the icon. This can only be used with sdf icons.
|
||||
* The color of the icon. This can only be used with SDF icons.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
@@ -466,7 +466,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* The color of the icon. This can only be used with sdf icons.
|
||||
* The color of the icon. This can only be used with SDF icons.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
@@ -506,7 +506,8 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Distance of halo to the icon outline.
|
||||
* Distance of halo to the icon outline.
|
||||
The unit is in density-independent pixels only for SDF sprites that were created with a blur radius of 8, multiplied by the display density. I.e., the radius needs to be 16 for `@2x` sprites, etc.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
@@ -516,7 +517,8 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Distance of halo to the icon outline.
|
||||
* Distance of halo to the icon outline.
|
||||
The unit is in density-independent pixels only for SDF sprites that were created with a blur radius of 8, multiplied by the display density. I.e., the radius needs to be 16 for `@2x` sprites, etc.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
@@ -1406,7 +1408,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fade duration when a new tile is added.
|
||||
* Fade duration when a new tile is added, or when a video is started or its coordinates are updated.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
@@ -1416,7 +1418,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fade duration when a new tile is added.
|
||||
* Fade duration when a new tile is added, or when a video is started or its coordinates are updated.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
@@ -1806,7 +1808,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
|
||||
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like MapLibre GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
|
||||
*
|
||||
* @param value a Boolean value
|
||||
* @return property wrapper around Boolean
|
||||
@@ -1816,7 +1818,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
|
||||
* If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like MapLibre GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.
|
||||
*
|
||||
* @param value a Boolean value
|
||||
* @return property wrapper around Boolean
|
||||
@@ -1846,7 +1848,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the order in which overlapping symbols in the same layer are rendered
|
||||
* Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their y-position relative to the viewport. To control the order and prioritization of symbols otherwise, use {@link PropertyFactory#symbolSortKey}.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
@@ -1856,7 +1858,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the order in which overlapping symbols in the same layer are rendered
|
||||
* Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their y-position relative to the viewport. To control the order and prioritization of symbols otherwise, use {@link PropertyFactory#symbolSortKey}.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
@@ -2046,7 +2048,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of the additional area around the icon bounding box used for detecting symbol collisions.
|
||||
* Size of additional area round the icon bounding box used for detecting symbol collisions.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
@@ -2056,7 +2058,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of the additional area around the icon bounding box used for detecting symbol collisions.
|
||||
* Size of additional area round the icon bounding box used for detecting symbol collisions.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
|
||||
@@ -683,7 +683,7 @@ public class SymbolLayer extends Layer {
|
||||
}
|
||||
|
||||
/**
|
||||
* The color of the icon. This can only be used with sdf icons.
|
||||
* The color of the icon. This can only be used with SDF icons.
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
|
||||
@@ -139,6 +139,18 @@ public class LocationIndicatorLayerTest extends BaseLayerTest {
|
||||
assertEquals(layer.getImageTiltDisplacement().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testBearingTransition() {
|
||||
Timber.i("bearingTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBearingTransition(options);
|
||||
assertEquals(layer.getBearingTransition(), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testBearingAsConstant() {
|
||||
|
||||
265
platform/android/package-lock.json
generated
265
platform/android/package-lock.json
generated
@@ -1,265 +0,0 @@
|
||||
{
|
||||
"name": "@mapbox/mapbox-gl-native-android",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@mapbox/mapbox-gl-native-android",
|
||||
"version": "1.0.0",
|
||||
"license": "BSD-2-Clause",
|
||||
"devDependencies": {
|
||||
"ejs": "^3.1.10",
|
||||
"esm": "~3.2.25",
|
||||
"lodash": "^4.17.21",
|
||||
"pixelmatch": "^5.3.0",
|
||||
"semver": "^7.3.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/async": {
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz",
|
||||
"integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ejs": {
|
||||
"version": "3.1.10",
|
||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
|
||||
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"jake": "^10.8.5"
|
||||
},
|
||||
"bin": {
|
||||
"ejs": "bin/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/esm": {
|
||||
"version": "3.2.25",
|
||||
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz",
|
||||
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/filelist": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
|
||||
"integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"minimatch": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/filelist/node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/filelist/node_modules/minimatch": {
|
||||
"version": "5.1.6",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
|
||||
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/jake": {
|
||||
"version": "10.8.7",
|
||||
"resolved": "https://registry.npmjs.org/jake/-/jake-10.8.7.tgz",
|
||||
"integrity": "sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"async": "^3.2.3",
|
||||
"chalk": "^4.0.2",
|
||||
"filelist": "^1.0.4",
|
||||
"minimatch": "^3.1.2"
|
||||
},
|
||||
"bin": {
|
||||
"jake": "bin/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/pixelmatch": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-5.3.0.tgz",
|
||||
"integrity": "sha512-o8mkY4E/+LNUf6LzX96ht6k6CEDi65k9G2rjMtBe9Oo+VPKSvl+0GKHuH/AlG+GA5LPG/i5hrekkxUc3s2HU+Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"pngjs": "^6.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"pixelmatch": "bin/pixelmatch"
|
||||
}
|
||||
},
|
||||
"node_modules/pngjs": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-6.0.0.tgz",
|
||||
"integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.6.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
|
||||
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "@mapbox/mapbox-gl-native-android",
|
||||
"version": "1.0.0",
|
||||
"description": "Renders map tiles with the Mapbox Maps SDK for Android",
|
||||
"keywords": [
|
||||
"mapbox",
|
||||
"gl"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:mapbox/mapbox-gl-native-android.git"
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"devDependencies": {
|
||||
"ejs": "^3.1.10",
|
||||
"esm": "~3.2.25",
|
||||
"lodash": "^4.17.21",
|
||||
"pixelmatch": "^5.3.0",
|
||||
"semver": "^7.3.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {}
|
||||
}
|
||||
184
platform/android/scripts/android-style-spec-overrides.mjs
Normal file
184
platform/android/scripts/android-style-spec-overrides.mjs
Normal file
@@ -0,0 +1,184 @@
|
||||
import styleSpec from "../../../scripts/style-spec.mjs";
|
||||
|
||||
/** @type {any} */
|
||||
let modifiedReferenceSpec = styleSpec;
|
||||
|
||||
modifiedReferenceSpec.layer.type.values["location-indicator"] = {};
|
||||
modifiedReferenceSpec["layout_location-indicator"] = {
|
||||
"top-image": {
|
||||
"type": "resolvedImage",
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": false,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"doc": "Name of image in sprite to use as the top of the location indicator."
|
||||
},
|
||||
"bearing-image": {
|
||||
"type": "resolvedImage",
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": false,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"doc": "Name of image in sprite to use as the middle of the location indicator."
|
||||
},
|
||||
"shadow-image": {
|
||||
"type": "resolvedImage",
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": false,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"doc": "Name of image in sprite to use as the background of the location indicator."
|
||||
}
|
||||
};
|
||||
|
||||
modifiedReferenceSpec["paint_location-indicator"] = {
|
||||
"perspective-compensation": {
|
||||
"type": "number",
|
||||
"default": "0.85",
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"doc": "The amount of the perspective compensation, between 0 and 1. A value of 1 produces a location indicator of constant width across the screen. A value of 0 makes it scale naturally according to the viewing projection."
|
||||
},
|
||||
"image-tilt-displacement": {
|
||||
"type": "number",
|
||||
"property-type": "data-constant",
|
||||
"default": "0",
|
||||
"units": "pixels",
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"doc": "The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence."
|
||||
},
|
||||
"bearing": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"period": 360,
|
||||
"units": "degrees",
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": false,
|
||||
"parameters": [ ]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The bearing of the location indicator."
|
||||
},
|
||||
"location": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"length": 3,
|
||||
"value": "number",
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": []
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "An array of [latitude, longitude, altitude] position of the location indicator."
|
||||
},
|
||||
"accuracy-radius": {
|
||||
"type": "number",
|
||||
"units": "meters",
|
||||
"default": 0,
|
||||
"property-type": "data-constant",
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The accuracy, in meters, of the position source used to retrieve the position of the location indicator."
|
||||
},
|
||||
"top-image-size": {
|
||||
"type": "number",
|
||||
"units": "factor of the original icon size",
|
||||
"property-type": "data-constant",
|
||||
"default": 1,
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The size of the top image, as a scale factor applied to the size of the specified image."
|
||||
},
|
||||
"bearing-image-size": {
|
||||
"type": "number",
|
||||
"units": "factor of the original icon size",
|
||||
"property-type": "data-constant",
|
||||
"default": 1,
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The size of the bearing image, as a scale factor applied to the size of the specified image."
|
||||
},
|
||||
"shadow-image-size": {
|
||||
"type": "number",
|
||||
"units": "factor of the original icon size",
|
||||
"property-type": "data-constant",
|
||||
"default": 1,
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The size of the shadow image, as a scale factor applied to the size of the specified image."
|
||||
},
|
||||
"accuracy-radius-color": {
|
||||
"type": "color",
|
||||
"property-type": "data-constant",
|
||||
"default": "#ffffff",
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The color for drawing the accuracy radius, as a circle. To adjust transparency, set the alpha component of the color accordingly."
|
||||
|
||||
},
|
||||
"accuracy-radius-border-color": {
|
||||
"type": "color",
|
||||
"property-type": "data-constant",
|
||||
"default": "#ffffff",
|
||||
"expression": {
|
||||
"interpolated": true,
|
||||
"parameters": [
|
||||
"zoom"
|
||||
]
|
||||
},
|
||||
"transition": true,
|
||||
"doc": "The color for drawing the accuracy radius border. To adjust transparency, set the alpha component of the color accordingly."
|
||||
}
|
||||
};
|
||||
|
||||
export default modifiedReferenceSpec;
|
||||
471
platform/android/scripts/generate-style-code.mjs
Normal file
471
platform/android/scripts/generate-style-code.mjs
Normal file
@@ -0,0 +1,471 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import ejs from "ejs";
|
||||
import spec from "./android-style-spec-overrides.mjs";
|
||||
import _ from "lodash";
|
||||
|
||||
import { writeIfModified, camelize, snakeCaseUpper, iff, camelizeWithLeadingLowercase } from "../../../scripts/style-code.mjs";
|
||||
|
||||
if (!import.meta.dirname) throw new Error("import.meta.dirname is undefined");
|
||||
|
||||
function absPath(relativePath) {
|
||||
return path.join(import.meta.dirname, "..", relativePath);
|
||||
}
|
||||
|
||||
function setupGlobalEjsHelpers() {
|
||||
const funcs = {
|
||||
camelize,
|
||||
snakeCaseUpper,
|
||||
iff,
|
||||
camelizeWithLeadingLowercase
|
||||
};
|
||||
for (const [funcName, func] of Object.entries(funcs)) {
|
||||
// @ts-ignore
|
||||
global[funcName] = func;
|
||||
}
|
||||
}
|
||||
|
||||
setupGlobalEjsHelpers();
|
||||
|
||||
// Specification parsing //
|
||||
const lightProperties = Object.keys(spec[`light`]).reduce((memo, name) => {
|
||||
var property = spec[`light`][name];
|
||||
property.name = name;
|
||||
property['light-property'] = true;
|
||||
property.doc = property.doc.replace(/°/g,'°');
|
||||
memo.push(property);
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
// Collect layer types from spec
|
||||
var layers = Object.keys(spec.layer.type.values).map((type) => {
|
||||
const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => {
|
||||
if (name !== 'visibility' && type !== 'location-indicator') {
|
||||
spec[`layout_${type}`][name].name = name;
|
||||
memo.push(spec[`layout_${type}`][name]);
|
||||
}
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => {
|
||||
if (type !== 'location-indicator') {
|
||||
spec[`paint_${type}`][name].name = name;
|
||||
memo.push(spec[`paint_${type}`][name]);
|
||||
}
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
const locationLayoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => {
|
||||
if (name !== 'visibility' && type === 'location-indicator') {
|
||||
spec[`layout_${type}`][name].name = name;
|
||||
memo.push(spec[`layout_${type}`][name]);
|
||||
}
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
const locationPaintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => {
|
||||
if (type === 'location-indicator') {
|
||||
spec[`paint_${type}`][name].name = name;
|
||||
memo.push(spec[`paint_${type}`][name]);
|
||||
}
|
||||
return memo;
|
||||
}, []);
|
||||
|
||||
return {
|
||||
type: type,
|
||||
doc: spec.layer.type.values[type].doc,
|
||||
layoutProperties: layoutProperties,
|
||||
paintProperties: paintProperties,
|
||||
locationLayoutProperties: locationLayoutProperties,
|
||||
locationPaintProperties: locationPaintProperties,
|
||||
properties: layoutProperties.concat(paintProperties).concat(locationLayoutProperties).concat(locationPaintProperties)
|
||||
};
|
||||
});
|
||||
|
||||
// Process all layer properties
|
||||
const uniqueArrayEnum = (prop, enums) => {
|
||||
if (prop.value !== 'enum') return false;
|
||||
const enumsEqual = (val1, val2) => val1.length === val1.length && val1.every((val, i) => val === val2[i]);
|
||||
return enums.filter(e => enumsEqual(Object.keys(prop.values).sort(), Object.keys(e.values).sort())).length == 0;
|
||||
};
|
||||
|
||||
const layoutProperties = _(layers).map('layoutProperties').flatten().value();
|
||||
const paintProperties = _(layers).map('paintProperties').flatten().value();
|
||||
const locationLayoutProperties = _(layers).map('locationLayoutProperties').flatten().value();
|
||||
const locationPaintProperties = _(layers).map('locationPaintProperties').flatten().value();
|
||||
const allProperties = _(layoutProperties).union(paintProperties).union(lightProperties).value();
|
||||
let allEnumProperties = _(allProperties).filter({'type': 'enum'}).value();
|
||||
const uniqueArrayEnumProperties = _(allProperties).filter({'type': 'array'}).filter(prop => uniqueArrayEnum(prop, allEnumProperties)).value();
|
||||
const enumProperties = _(allEnumProperties).union(uniqueArrayEnumProperties).value();
|
||||
|
||||
|
||||
global.propertyType = function propertyType(property) {
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'Boolean';
|
||||
case 'number':
|
||||
if (/bearing$/.test(property.name) &&
|
||||
property.period == 360 &&
|
||||
property.units =='degrees') {
|
||||
return 'Double';
|
||||
}
|
||||
return /location$/.test(property.name) ? 'Double' : 'Float';
|
||||
case 'formatted':
|
||||
return 'Formatted';
|
||||
case 'string':
|
||||
case 'resolvedImage':
|
||||
return 'String';
|
||||
case 'enum':
|
||||
return 'String';
|
||||
case 'color':
|
||||
return 'String';
|
||||
case 'array':
|
||||
return `${propertyType({type:property.value, name: property.name})}[]`;
|
||||
default:
|
||||
throw new Error(`unknown type for ${property.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
global.propertyJavaType = function propertyType(property) {
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'boolean';
|
||||
case 'number':
|
||||
return 'float';
|
||||
case 'formatted':
|
||||
return 'Formatted';
|
||||
case 'string':
|
||||
case 'resolvedImage':
|
||||
return 'String';
|
||||
case 'enum':
|
||||
return 'String';
|
||||
case 'color':
|
||||
return 'String';
|
||||
case 'array':
|
||||
return `${propertyJavaType({type:property.value})}[]`;
|
||||
default:
|
||||
throw new Error(`unknown type for ${property.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
global.propertyJNIType = function propertyJNIType(property) {
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'jboolean';
|
||||
case 'number':
|
||||
return 'jfloat';
|
||||
case 'String':
|
||||
return 'String';
|
||||
case 'enum':
|
||||
return 'String';
|
||||
case 'color':
|
||||
return 'String';
|
||||
case 'array':
|
||||
return `jarray<${propertyType({type:property.value})}[]>`;
|
||||
default:
|
||||
return 'jobject*';
|
||||
}
|
||||
}
|
||||
|
||||
global.propertyNativeType = function (property) {
|
||||
if (/-translate-anchor$/.test(property.name)) {
|
||||
return 'TranslateAnchorType';
|
||||
}
|
||||
if (/-(rotation|pitch|illumination)-alignment$/.test(property.name)) {
|
||||
return 'AlignmentType';
|
||||
}
|
||||
if (/^(text|icon)-anchor$/.test(property.name)) {
|
||||
return 'SymbolAnchorType';
|
||||
}
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'bool';
|
||||
case 'number':
|
||||
return 'float';
|
||||
case 'formatted':
|
||||
case 'string':
|
||||
case 'resolvedImage': // TODO: replace once we implement image expressions
|
||||
return 'std::string';
|
||||
case 'enum':
|
||||
if(property['light-property']){
|
||||
return `Light${camelize(property.name)}Type`;
|
||||
}
|
||||
return `${camelize(property.name)}Type`;
|
||||
case 'color':
|
||||
return `Color`;
|
||||
case 'array':
|
||||
if (property.length) {
|
||||
return `std::array<${propertyType({type: property.value})}, ${property.length}>`;
|
||||
} else {
|
||||
return `std::vector<${propertyType({type: property.value})}>`;
|
||||
}
|
||||
default: throw new Error(`unknown type for ${property.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
global.propertyTypeAnnotation = function propertyTypeAnnotation(property) {
|
||||
switch (property.type) {
|
||||
case 'enum':
|
||||
return `@Property.${snakeCaseUpper(property.name)}`;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
global.defaultExpressionJava = function(property) {
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'boolean';
|
||||
case 'number':
|
||||
return 'number';
|
||||
case 'formatted':
|
||||
return 'format';
|
||||
case 'resolvedImage':
|
||||
return "image";
|
||||
case 'string':
|
||||
case 'image':
|
||||
return "string";
|
||||
case 'enum':
|
||||
return "string";
|
||||
case 'color':
|
||||
return 'toColor';
|
||||
case 'array':
|
||||
return "array";
|
||||
default: return "string";
|
||||
}
|
||||
}
|
||||
|
||||
global.defaultValueJava = function(property) {
|
||||
if(property.name.endsWith("-pattern")) {
|
||||
return '"pedestrian-polygon"';
|
||||
}
|
||||
if(property.name.endsWith("-font")) {
|
||||
return 'new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}';
|
||||
}
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'true';
|
||||
case 'number':
|
||||
if (/bearing$/.test(property.name) &&
|
||||
property.period == 360 &&
|
||||
property.units =='degrees') {
|
||||
return '0.3';
|
||||
}
|
||||
return '0.3f';
|
||||
case 'formatted':
|
||||
return 'new Formatted(new FormattedSection("default"))'
|
||||
case 'string':
|
||||
case 'resolvedImage':
|
||||
return '"' + property['default'] + '"';
|
||||
case 'enum':
|
||||
return snakeCaseUpper(property.name) + "_" + snakeCaseUpper(Object.keys(property.values)[0]);
|
||||
case 'color':
|
||||
return '"rgba(255,128,0,0.7)"';
|
||||
case 'array':
|
||||
switch (property.value) {
|
||||
case 'string':
|
||||
case 'enum':
|
||||
if (property['default'] !== undefined) {
|
||||
return '[' + property['default'] + ']';
|
||||
} else {
|
||||
return 'new String[0]';
|
||||
}
|
||||
case 'number':
|
||||
var isDouble = /location$/.test(property.name)
|
||||
var result = 'new ' + (isDouble ? 'Double' : 'Float') + '[] {';
|
||||
for (var i = 0; i < property.length; i++) {
|
||||
result += isDouble ? '0.0' : '0f';
|
||||
if (i +1 != property.length) {
|
||||
result += ', ';
|
||||
}
|
||||
}
|
||||
return result + '}';
|
||||
}
|
||||
default: throw new Error(`unknown type for ${property.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces documentation for property factory methods
|
||||
*/
|
||||
global.propertyFactoryMethodDoc = function (property) {
|
||||
var replaceIfPixels = function (doc) {
|
||||
return doc.replace('pixels', 'density-independent pixels')
|
||||
}
|
||||
let doc = replaceIfPixels(property.doc);
|
||||
// Match other items in back ticks
|
||||
doc = doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) {
|
||||
if (str.substr(offset - 4, 3) !== 'CSS' && symbol[0].toUpperCase() != symbol[0] && _(enumProperties).filter({'name': symbol}).value().length > 0) {
|
||||
// Property 'enums'
|
||||
symbol = snakeCaseUpper(symbol);
|
||||
return '{@link Property.' + symbol + '}';
|
||||
} else if( _(allProperties).filter({'name': symbol}).value().length > 0) {
|
||||
// Other properties
|
||||
return '{@link PropertyFactory#' + camelizeWithLeadingLowercase(symbol) + '}';
|
||||
} else {
|
||||
// Left overs
|
||||
return '`' + symbol + '`';
|
||||
}
|
||||
});
|
||||
return doc;
|
||||
};
|
||||
|
||||
/**
|
||||
* Produces documentation for property value constants
|
||||
*/
|
||||
global.propertyValueDoc = function (property, value) {
|
||||
|
||||
// Match references to other property names & values.
|
||||
// Requires the format 'When `foo` is set to `bar`,'.
|
||||
let doc = property.values[value].doc.replace(/When `(.+?)` is set to `(.+?)`(?: or `([^`]+?)`)?,/g, function (m, peerPropertyName, propertyValue, secondPropertyValue, offset, str) {
|
||||
let otherProperty = snakeCaseUpper(peerPropertyName);
|
||||
let otherValue = snakeCaseUpper(peerPropertyName) + '_' + snakeCaseUpper(propertyValue);
|
||||
const firstPropertyValue = 'When {@link ' + `${otherProperty}` + '} is set to {@link Property#' + `${otherValue}` + '}';
|
||||
if (secondPropertyValue) {
|
||||
return firstPropertyValue + ` or {@link Property#${snakeCaseUpper(peerPropertyName) + '_' + snakeCaseUpper(secondPropertyValue)}},`;
|
||||
} else {
|
||||
return firstPropertyValue + ',';
|
||||
}
|
||||
});
|
||||
|
||||
// Match references to our own property values.
|
||||
// Requires the format 'is equivalent to `bar`'.
|
||||
doc = doc.replace(/is equivalent to `(.+?)`/g, function(m, propertyValue, offset, str) {
|
||||
propertyValue = snakeCaseUpper(property.name) + '_' + snakeCaseUpper(propertyValue);
|
||||
return 'is equivalent to {@link Property#' + propertyValue + '}';
|
||||
});
|
||||
|
||||
// Match other items in back ticks
|
||||
doc = doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) {
|
||||
if ('values' in property && Object.keys(property.values).indexOf(symbol) !== -1) {
|
||||
// Property values
|
||||
propertyValue = snakeCaseUpper(property.name) + '_' + snakeCaseUpper(symbol);
|
||||
console.log("Transforming", symbol, propertyValue);
|
||||
return '{@link Property#' + `${propertyValue}` + '}';
|
||||
} else if (str.substr(offset - 4, 3) !== 'CSS' && symbol[0].toUpperCase() != symbol[0]) {
|
||||
// Property 'enums'
|
||||
if (symbol === 'symbol-sort-key') {
|
||||
return 'symbol sort key';
|
||||
}
|
||||
|
||||
symbol = snakeCaseUpper(symbol);
|
||||
return '{@link ' + symbol + '}';
|
||||
} else {
|
||||
// Left overs
|
||||
return symbol
|
||||
}
|
||||
});
|
||||
return doc;
|
||||
};
|
||||
|
||||
global.isLightProperty = function (property) {
|
||||
return property['light-property'] === true;
|
||||
};
|
||||
|
||||
global.propertyValueType = function (property) {
|
||||
switch (property['property-type']) {
|
||||
default:
|
||||
return `PropertyValue<${evaluatedType(property)}>`;
|
||||
}
|
||||
};
|
||||
|
||||
global.evaluatedType = function (property) {
|
||||
if (/-translate-anchor$/.test(property.name)) {
|
||||
return 'TranslateAnchorType';
|
||||
}
|
||||
if (/-(rotation|pitch|illumination)-alignment$/.test(property.name)) {
|
||||
return 'AlignmentType';
|
||||
}
|
||||
if (/^(text|icon)-anchor$/.test(property.name)) {
|
||||
return 'SymbolAnchorType';
|
||||
}
|
||||
if (/position/.test(property.name)) {
|
||||
return 'Position';
|
||||
}
|
||||
switch (property.type) {
|
||||
case 'boolean':
|
||||
return 'bool';
|
||||
case 'number':
|
||||
return 'float';
|
||||
case 'formatted':
|
||||
case 'string':
|
||||
case 'image':
|
||||
return 'std::string';
|
||||
case 'enum':
|
||||
return (isLightProperty(property) ? 'Light' : '') + `${camelize(property.name)}Type`;
|
||||
case 'color':
|
||||
return `Color`;
|
||||
case 'array':
|
||||
if (property.length) {
|
||||
return `std::array<${evaluatedType({type: property.value})}, ${property.length}>`;
|
||||
} else {
|
||||
return `std::vector<${evaluatedType({type: property.value})}>`;
|
||||
}
|
||||
default: throw new Error(`unknown type for ${property.name}`)
|
||||
}
|
||||
};
|
||||
|
||||
global.supportsZoomFunction = function (property) {
|
||||
return property.expression && property.expression.parameters.indexOf('zoom') > -1;
|
||||
};
|
||||
|
||||
global.supportsPropertyFunction = function (property) {
|
||||
return property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven';
|
||||
};
|
||||
|
||||
// Template processing //
|
||||
|
||||
// Java + JNI Light (Peer model)
|
||||
const lightJava = ejs.compile(fs.readFileSync(absPath('MapLibreAndroid/src/main/java/org/maplibre/android/style/light/light.java.ejs'), 'utf8'), {strict: true});
|
||||
const lightJavaUnitTests = ejs.compile(fs.readFileSync(absPath('MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/light.junit.ejs'), 'utf8'), {strict: true});
|
||||
writeIfModified(absPath(`MapLibreAndroid/src/main/java/org/maplibre/android/style/light/Light.java`), lightJava({properties: lightProperties}));
|
||||
writeIfModified(absPath(`MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/LightTest.java`), lightJavaUnitTests({properties: lightProperties}));
|
||||
|
||||
// Java
|
||||
const layerJava = ejs.compile(fs.readFileSync(absPath('MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/layer.java.ejs'), 'utf8'), {strict: true});
|
||||
const layerJavaUnitTests = ejs.compile(fs.readFileSync(absPath('MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/layer.junit.ejs'), 'utf8'), {strict: true});
|
||||
|
||||
for (const layer of layers) {
|
||||
var srcDir = 'MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/'
|
||||
var testDir = 'MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/'
|
||||
if (layer.type === 'location-indicator') {
|
||||
srcDir = 'MapLibreAndroid/src/main/java/org/maplibre/android/location/'
|
||||
testDir = 'MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/location/'
|
||||
}
|
||||
|
||||
writeIfModified(absPath(srcDir + `${camelize(layer.type)}Layer.java`), layerJava(layer));
|
||||
writeIfModified(absPath(testDir + `${camelize(layer.type)}LayerTest.java`), layerJavaUnitTests(layer));
|
||||
}
|
||||
|
||||
// Jni
|
||||
const layerHpp = ejs.compile(fs.readFileSync(absPath('MapLibreAndroid/src/cpp/style/layers/layer.hpp.ejs'), 'utf8'), {strict: true});
|
||||
const layerCpp = ejs.compile(fs.readFileSync(absPath('MapLibreAndroid/src/cpp/style/layers/layer.cpp.ejs'), 'utf8'), {strict: true});
|
||||
|
||||
for (const layer of layers) {
|
||||
const layerFileName = layer.type.replace('-', '_');
|
||||
|
||||
writeIfModified(absPath(`MapLibreAndroid/src/cpp/style/layers/${layerFileName}_layer.hpp`), layerHpp(layer));
|
||||
writeIfModified(absPath(`MapLibreAndroid/src/cpp/style/layers/${layerFileName}_layer.cpp`), layerCpp(layer));
|
||||
}
|
||||
|
||||
// Java PropertyFactory
|
||||
const propertyFactoryTemplate = ejs.compile(fs.readFileSync(absPath('MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/property_factory.java.ejs'), 'utf8'), {strict: true});
|
||||
|
||||
const propertyFactorySrcDir = absPath('MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/PropertyFactory.java')
|
||||
writeIfModified(
|
||||
propertyFactorySrcDir,
|
||||
propertyFactoryTemplate({layoutProperties: layoutProperties, paintProperties: paintProperties, locationIndicator: false})
|
||||
);
|
||||
|
||||
const locationPropertyFactorySrcDir = absPath('MapLibreAndroid/src/main/java/org/maplibre/android/location/LocationPropertyFactory.java')
|
||||
writeIfModified(
|
||||
locationPropertyFactorySrcDir,
|
||||
propertyFactoryTemplate({layoutProperties: locationLayoutProperties, paintProperties: locationPaintProperties, locationIndicator: true})
|
||||
);
|
||||
|
||||
// Java Property
|
||||
const enumPropertyJavaTemplate = ejs.compile(fs.readFileSync(absPath('MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/property.java.ejs'), 'utf8'), {strict: true});
|
||||
writeIfModified(
|
||||
absPath(`MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/Property.java`),
|
||||
enumPropertyJavaTemplate({properties: enumProperties})
|
||||
);
|
||||
Reference in New Issue
Block a user