core: Update Hillshade Algorithms and add Color-Relief Layer support (#3965)
This commit is contained in:
@@ -147,6 +147,8 @@ add_library(maplibre SHARED
|
||||
${PROJECT_SOURCE_DIR}/style/layers/background_layer.hpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/circle_layer.cpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/circle_layer.hpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/color_relief_layer.cpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/color_relief_layer.hpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/custom_layer.cpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/custom_layer.hpp
|
||||
${PROJECT_SOURCE_DIR}/style/layers/fill_extrusion_layer.cpp
|
||||
|
||||
@@ -101,6 +101,17 @@ Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::vect
|
||||
return result;
|
||||
}
|
||||
|
||||
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::vector<Color>>::operator()(
|
||||
jni::JNIEnv& env, const std::vector<Color>& value) const {
|
||||
auto result = jni::Array<jni::String>::New(env, value.size());
|
||||
|
||||
for (std::size_t i = 0; i < value.size(); i++) {
|
||||
result.Set(env, i, jni::Make<jni::String>(env, value.at(i).stringify()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, style::expression::Image>::operator()(
|
||||
jni::JNIEnv& env, const style::expression::Image& value) const {
|
||||
return jni::Make<jni::String>(env, value.id());
|
||||
|
||||
@@ -111,6 +111,11 @@ struct Converter<jni::Local<jni::Object<>>, std::vector<double>> {
|
||||
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<double>& value) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<jni::Local<jni::Object<>>, std::vector<Color>> {
|
||||
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<Color>& value) const;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Converter<jni::Local<jni::Object<>>, T, typename std::enable_if_t<std::is_enum<T>::value>> {
|
||||
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const T& value) const {
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
#include "color_relief_layer.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../conversion/property_value.hpp"
|
||||
#include "../conversion/transition_options.hpp"
|
||||
|
||||
#include <mbgl/style/layer_impl.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
inline mbgl::style::ColorReliefLayer& toColorReliefLayer(mbgl::style::Layer& layer) {
|
||||
return static_cast<mbgl::style::ColorReliefLayer&>(layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an owning peer object (for layers not attached to the map) from the JVM side
|
||||
*/
|
||||
ColorReliefLayer::ColorReliefLayer(jni::JNIEnv& env, jni::String& layerId, jni::String& sourceId)
|
||||
: Layer(std::make_unique<mbgl::style::ColorReliefLayer>(jni::Make<std::string>(env, layerId),
|
||||
jni::Make<std::string>(env, sourceId))) {}
|
||||
|
||||
/**
|
||||
* Creates a non-owning peer object (for layers currently attached to the map)
|
||||
*/
|
||||
ColorReliefLayer::ColorReliefLayer(mbgl::style::ColorReliefLayer& coreLayer)
|
||||
: Layer(coreLayer) {}
|
||||
|
||||
/**
|
||||
* Creates an owning peer object (for layers not attached to the map)
|
||||
*/
|
||||
ColorReliefLayer::ColorReliefLayer(std::unique_ptr<mbgl::style::ColorReliefLayer> coreLayer)
|
||||
: Layer(std::move(coreLayer)) {}
|
||||
|
||||
ColorReliefLayer::~ColorReliefLayer() = default;
|
||||
|
||||
// Property getters
|
||||
|
||||
jni::Local<jni::Object<>> ColorReliefLayer::getColorReliefOpacity(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
auto layer = layerPtr.get();
|
||||
if (!layer) {
|
||||
return std::move(
|
||||
*convert<jni::Local<jni::Object<>>>(env, style::ColorReliefLayer::getDefaultColorReliefOpacity()));
|
||||
}
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toColorReliefLayer(*layer).getColorReliefOpacity()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<TransitionOptions>> ColorReliefLayer::getColorReliefOpacityTransition(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
auto layer = layerPtr.get();
|
||||
if (!layer) {
|
||||
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, mbgl::style::TransitionOptions()));
|
||||
}
|
||||
mbgl::style::TransitionOptions options = toColorReliefLayer(*layer).getColorReliefOpacityTransition();
|
||||
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
|
||||
}
|
||||
|
||||
void ColorReliefLayer::setColorReliefOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay) {
|
||||
auto layer = layerPtr.get();
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
mbgl::style::TransitionOptions options;
|
||||
options.duration.emplace(mbgl::Milliseconds(duration));
|
||||
options.delay.emplace(mbgl::Milliseconds(delay));
|
||||
toColorReliefLayer(*layer).setColorReliefOpacityTransition(options);
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> ColorReliefLayer::getColorReliefColor(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
auto layer = layerPtr.get();
|
||||
if (!layer) {
|
||||
return std::move(
|
||||
*convert<jni::Local<jni::Object<>>>(env, style::ColorReliefLayer::getDefaultColorReliefColor()));
|
||||
}
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toColorReliefLayer(*layer).getColorReliefColor()));
|
||||
}
|
||||
|
||||
// ColorReliefJavaLayerPeerFactory
|
||||
|
||||
ColorReliefJavaLayerPeerFactory::~ColorReliefJavaLayerPeerFactory() = default;
|
||||
|
||||
namespace {
|
||||
jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv& env, Layer* layer) {
|
||||
static auto& javaClass = jni::Class<ColorReliefLayer>::Singleton(env);
|
||||
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
|
||||
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(layer));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
jni::Local<jni::Object<Layer>> ColorReliefJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
|
||||
mbgl::style::Layer& layer) {
|
||||
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
|
||||
return createJavaPeer(env, new ColorReliefLayer(toColorReliefLayer(layer)));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<Layer>> ColorReliefJavaLayerPeerFactory::createJavaLayerPeer(
|
||||
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
|
||||
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
|
||||
return createJavaPeer(env,
|
||||
new ColorReliefLayer(std::unique_ptr<mbgl::style::ColorReliefLayer>(
|
||||
static_cast<mbgl::style::ColorReliefLayer*>(layer.release()))));
|
||||
}
|
||||
|
||||
void ColorReliefJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
|
||||
// Lookup the class
|
||||
static auto& javaClass = jni::Class<ColorReliefLayer>::Singleton(env);
|
||||
|
||||
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
|
||||
|
||||
// Register the peer
|
||||
jni::RegisterNativePeer<ColorReliefLayer>(
|
||||
env,
|
||||
javaClass,
|
||||
"nativePtr",
|
||||
jni::MakePeer<ColorReliefLayer, jni::String&, jni::String&>,
|
||||
"initialize",
|
||||
"finalize",
|
||||
METHOD(&ColorReliefLayer::getColorReliefOpacityTransition, "nativeGetColorReliefOpacityTransition"),
|
||||
METHOD(&ColorReliefLayer::setColorReliefOpacityTransition, "nativeSetColorReliefOpacityTransition"),
|
||||
METHOD(&ColorReliefLayer::getColorReliefOpacity, "nativeGetColorReliefOpacity"),
|
||||
METHOD(&ColorReliefLayer::getColorReliefColor, "nativeGetColorReliefColor"));
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -0,0 +1,52 @@
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "layer.hpp"
|
||||
#include "../transition_options.hpp"
|
||||
#include <mbgl/layermanager/color_relief_layer_factory.hpp>
|
||||
#include <mbgl/style/layers/color_relief_layer.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class ColorReliefLayer : public Layer {
|
||||
public:
|
||||
using SuperTag = Layer;
|
||||
static constexpr auto Name() { return "org/maplibre/android/style/layers/ColorReliefLayer"; };
|
||||
|
||||
ColorReliefLayer(jni::JNIEnv&, jni::String&, jni::String&);
|
||||
|
||||
ColorReliefLayer(mbgl::style::ColorReliefLayer&);
|
||||
|
||||
ColorReliefLayer(std::unique_ptr<mbgl::style::ColorReliefLayer>);
|
||||
|
||||
~ColorReliefLayer();
|
||||
|
||||
// Properties
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getColorReliefOpacity(jni::JNIEnv&);
|
||||
void setColorReliefOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay);
|
||||
jni::Local<jni::Object<TransitionOptions>> getColorReliefOpacityTransition(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getColorReliefColor(jni::JNIEnv&);
|
||||
|
||||
}; // class ColorReliefLayer
|
||||
|
||||
class ColorReliefJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::ColorReliefLayerFactory {
|
||||
public:
|
||||
~ColorReliefJavaLayerPeerFactory() override;
|
||||
|
||||
// JavaLayerPeerFactory overrides.
|
||||
jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv&, mbgl::style::Layer&) final;
|
||||
jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer>) final;
|
||||
|
||||
void registerNative(jni::JNIEnv&) final;
|
||||
|
||||
LayerFactory* getLayerFactory() final { return this; }
|
||||
|
||||
}; // class ColorReliefJavaLayerPeerFactory
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -50,6 +50,17 @@ jni::Local<jni::Object<>> HillshadeLayer::getHillshadeIlluminationDirection(jni:
|
||||
*convert<jni::Local<jni::Object<>>>(env, toHillshadeLayer(*layer).getHillshadeIlluminationDirection()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> HillshadeLayer::getHillshadeIlluminationAltitude(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
auto layer = layerPtr.get();
|
||||
if (!layer) {
|
||||
return std::move(
|
||||
*convert<jni::Local<jni::Object<>>>(env, style::HillshadeLayer::getDefaultHillshadeIlluminationAltitude()));
|
||||
}
|
||||
return std::move(
|
||||
*convert<jni::Local<jni::Object<>>>(env, toHillshadeLayer(*layer).getHillshadeIlluminationAltitude()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> HillshadeLayer::getHillshadeIlluminationAnchor(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
auto layer = layerPtr.get();
|
||||
@@ -185,6 +196,15 @@ void HillshadeLayer::setHillshadeAccentColorTransition(jni::JNIEnv&, jlong durat
|
||||
toHillshadeLayer(*layer).setHillshadeAccentColorTransition(options);
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> HillshadeLayer::getHillshadeMethod(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
auto layer = layerPtr.get();
|
||||
if (!layer) {
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, style::HillshadeLayer::getDefaultHillshadeMethod()));
|
||||
}
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toHillshadeLayer(*layer).getHillshadeMethod()));
|
||||
}
|
||||
|
||||
// HillshadeJavaLayerPeerFactory
|
||||
|
||||
HillshadeJavaLayerPeerFactory::~HillshadeJavaLayerPeerFactory() = default;
|
||||
@@ -226,6 +246,7 @@ void HillshadeJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
|
||||
"initialize",
|
||||
"finalize",
|
||||
METHOD(&HillshadeLayer::getHillshadeIlluminationDirection, "nativeGetHillshadeIlluminationDirection"),
|
||||
METHOD(&HillshadeLayer::getHillshadeIlluminationAltitude, "nativeGetHillshadeIlluminationAltitude"),
|
||||
METHOD(&HillshadeLayer::getHillshadeIlluminationAnchor, "nativeGetHillshadeIlluminationAnchor"),
|
||||
METHOD(&HillshadeLayer::getHillshadeExaggerationTransition, "nativeGetHillshadeExaggerationTransition"),
|
||||
METHOD(&HillshadeLayer::setHillshadeExaggerationTransition, "nativeSetHillshadeExaggerationTransition"),
|
||||
@@ -238,7 +259,8 @@ void HillshadeJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&HillshadeLayer::getHillshadeHighlightColor, "nativeGetHillshadeHighlightColor"),
|
||||
METHOD(&HillshadeLayer::getHillshadeAccentColorTransition, "nativeGetHillshadeAccentColorTransition"),
|
||||
METHOD(&HillshadeLayer::setHillshadeAccentColorTransition, "nativeSetHillshadeAccentColorTransition"),
|
||||
METHOD(&HillshadeLayer::getHillshadeAccentColor, "nativeGetHillshadeAccentColor"));
|
||||
METHOD(&HillshadeLayer::getHillshadeAccentColor, "nativeGetHillshadeAccentColor"),
|
||||
METHOD(&HillshadeLayer::getHillshadeMethod, "nativeGetHillshadeMethod"));
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getHillshadeIlluminationDirection(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getHillshadeIlluminationAltitude(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getHillshadeIlluminationAnchor(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getHillshadeExaggeration(jni::JNIEnv&);
|
||||
@@ -46,6 +48,8 @@ public:
|
||||
void setHillshadeAccentColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
|
||||
jni::Local<jni::Object<TransitionOptions>> getHillshadeAccentColorTransition(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getHillshadeMethod(jni::JNIEnv&);
|
||||
|
||||
}; // class HillshadeLayer
|
||||
|
||||
class HillshadeJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::HillshadeLayerFactory {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "background_layer.hpp"
|
||||
#include "circle_layer.hpp"
|
||||
#include "color_relief_layer.hpp"
|
||||
#include "custom_layer.hpp"
|
||||
#include "fill_extrusion_layer.hpp"
|
||||
#include "fill_layer.hpp"
|
||||
@@ -59,6 +60,11 @@ LayerManagerAndroid::LayerManagerAndroid() {
|
||||
#elif !defined(MBGL_LAYER_HILLSHADE_DISABLE_ALL)
|
||||
addLayerType(std::make_unique<HillshadeJavaLayerPeerFactory>());
|
||||
#endif
|
||||
#if defined(MBGL_LAYER_COLOR_RELIEF_DISABLE_RUNTIME)
|
||||
addLayerTypeCoreOnly(std::make_unique<ColorReliefLayerFactory>());
|
||||
#elif !defined(MBGL_LAYER_COLOR_RELIEF_DISABLE_ALL)
|
||||
addLayerType(std::make_unique<ColorReliefJavaLayerPeerFactory>());
|
||||
#endif
|
||||
#if defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_RUNTIME)
|
||||
addLayerTypeCoreOnly(std::make_unique<FillExtrusionLayerFactory>());
|
||||
#elif !defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_ALL)
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
package org.maplibre.android.style.layers;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import static org.maplibre.android.utils.ColorUtils.rgbaToColor;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.maplibre.android.style.expressions.Expression;
|
||||
import org.maplibre.android.style.layers.TransitionOptions;
|
||||
|
||||
/**
|
||||
* Client-side elevation coloring 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-color-relief">The online documentation</a>
|
||||
*/
|
||||
@UiThread
|
||||
public class ColorReliefLayer extends Layer {
|
||||
|
||||
/**
|
||||
* Creates a ColorReliefLayer.
|
||||
*
|
||||
* @param nativePtr pointer used by core
|
||||
*/
|
||||
@Keep
|
||||
ColorReliefLayer(long nativePtr) {
|
||||
super(nativePtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ColorReliefLayer.
|
||||
*
|
||||
* @param layerId the id of the layer
|
||||
* @param sourceId the id of the source
|
||||
*/
|
||||
public ColorReliefLayer(String layerId, String sourceId) {
|
||||
super();
|
||||
initialize(layerId, sourceId);
|
||||
}
|
||||
|
||||
@Keep
|
||||
protected native void initialize(String layerId, String sourceId);
|
||||
|
||||
/**
|
||||
* Set the source layer.
|
||||
*
|
||||
* @param sourceLayer the source layer to set
|
||||
*/
|
||||
public void setSourceLayer(String sourceLayer) {
|
||||
checkThread();
|
||||
nativeSetSourceLayer(sourceLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source Layer.
|
||||
*
|
||||
* @param sourceLayer the source layer to set
|
||||
* @return This
|
||||
*/
|
||||
@NonNull
|
||||
public ColorReliefLayer withSourceLayer(String sourceLayer) {
|
||||
setSourceLayer(sourceLayer);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source id.
|
||||
*
|
||||
* @return id of the source
|
||||
*/
|
||||
@NonNull
|
||||
public String getSourceId() {
|
||||
checkThread();
|
||||
return nativeGetSourceId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source layer.
|
||||
*
|
||||
* @return sourceLayer the source layer to get
|
||||
*/
|
||||
@NonNull
|
||||
public String getSourceLayer() {
|
||||
checkThread();
|
||||
return nativeGetSourceLayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single expression filter.
|
||||
*
|
||||
* @param filter the expression filter to set
|
||||
*/
|
||||
public void setFilter(@NonNull Expression filter) {
|
||||
checkThread();
|
||||
nativeSetFilter(filter.toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single expression filter.
|
||||
*
|
||||
* @param filter the expression filter to set
|
||||
* @return This
|
||||
*/
|
||||
@NonNull
|
||||
public ColorReliefLayer withFilter(@NonNull Expression filter) {
|
||||
setFilter(filter);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single expression filter.
|
||||
*
|
||||
* @return the expression filter to get
|
||||
*/
|
||||
@Nullable
|
||||
public Expression getFilter() {
|
||||
checkThread();
|
||||
JsonElement jsonElement = nativeGetFilter();
|
||||
if (jsonElement != null) {
|
||||
return Expression.Converter.convert(jsonElement);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
@NonNull
|
||||
public ColorReliefLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Property getters
|
||||
|
||||
/**
|
||||
* Get the ColorReliefOpacity property
|
||||
*
|
||||
* @return property wrapper value around Float
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getColorReliefOpacity() {
|
||||
checkThread();
|
||||
return (PropertyValue<Float>) new PropertyValue("color-relief-opacity", nativeGetColorReliefOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ColorReliefOpacity property transition options
|
||||
*
|
||||
* @return transition options for Float
|
||||
*/
|
||||
@NonNull
|
||||
public TransitionOptions getColorReliefOpacityTransition() {
|
||||
checkThread();
|
||||
return nativeGetColorReliefOpacityTransition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ColorReliefOpacity property transition options
|
||||
*
|
||||
* @param options transition options for Float
|
||||
*/
|
||||
public void setColorReliefOpacityTransition(@NonNull TransitionOptions options) {
|
||||
checkThread();
|
||||
nativeSetColorReliefOpacityTransition(options.getDuration(), options.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ColorReliefColor property
|
||||
*
|
||||
* @return property wrapper value around String
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getColorReliefColor() {
|
||||
checkThread();
|
||||
return (PropertyValue<String>) new PropertyValue("color-relief-color", nativeGetColorReliefColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the color of each pixel based on its elevation. Should be an expression that uses `["elevation"]` as input.
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
*/
|
||||
@ColorInt
|
||||
public int getColorReliefColorAsInt() {
|
||||
checkThread();
|
||||
PropertyValue<String> value = getColorReliefColor();
|
||||
if (value.isValue()) {
|
||||
return rgbaToColor(value.getValue());
|
||||
} else {
|
||||
throw new RuntimeException("color-relief-color was set as a Function");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetColorReliefOpacity();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native TransitionOptions nativeGetColorReliefOpacityTransition();
|
||||
|
||||
@Keep
|
||||
private native void nativeSetColorReliefOpacityTransition(long duration, long delay);
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetColorReliefColor();
|
||||
|
||||
@Override
|
||||
@Keep
|
||||
protected native void finalize() throws Throwable;
|
||||
|
||||
}
|
||||
@@ -97,13 +97,25 @@ public class HillshadeLayer extends Layer {
|
||||
/**
|
||||
* Get the HillshadeIlluminationDirection property
|
||||
*
|
||||
* @return property wrapper value around Float
|
||||
* @return property wrapper value around Float[]
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getHillshadeIlluminationDirection() {
|
||||
public PropertyValue<Float[]> getHillshadeIlluminationDirection() {
|
||||
checkThread();
|
||||
return (PropertyValue<Float>) new PropertyValue("hillshade-illumination-direction", nativeGetHillshadeIlluminationDirection());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("hillshade-illumination-direction", nativeGetHillshadeIlluminationDirection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HillshadeIlluminationAltitude property
|
||||
*
|
||||
* @return property wrapper value around Float[]
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getHillshadeIlluminationAltitude() {
|
||||
checkThread();
|
||||
return (PropertyValue<Float[]>) new PropertyValue("hillshade-illumination-altitude", nativeGetHillshadeIlluminationAltitude());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,36 +166,19 @@ public class HillshadeLayer extends Layer {
|
||||
/**
|
||||
* Get the HillshadeShadowColor property
|
||||
*
|
||||
* @return property wrapper value around String
|
||||
* @return property wrapper value around String[]
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getHillshadeShadowColor() {
|
||||
public PropertyValue<String[]> getHillshadeShadowColor() {
|
||||
checkThread();
|
||||
return (PropertyValue<String>) new PropertyValue("hillshade-shadow-color", nativeGetHillshadeShadowColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that face away from the light source.
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
*/
|
||||
@ColorInt
|
||||
public int getHillshadeShadowColorAsInt() {
|
||||
checkThread();
|
||||
PropertyValue<String> value = getHillshadeShadowColor();
|
||||
if (value.isValue()) {
|
||||
return rgbaToColor(value.getValue());
|
||||
} else {
|
||||
throw new RuntimeException("hillshade-shadow-color was set as a Function");
|
||||
}
|
||||
return (PropertyValue<String[]>) new PropertyValue("hillshade-shadow-color", nativeGetHillshadeShadowColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HillshadeShadowColor property transition options
|
||||
*
|
||||
* @return transition options for String
|
||||
* @return transition options for String[]
|
||||
*/
|
||||
@NonNull
|
||||
public TransitionOptions getHillshadeShadowColorTransition() {
|
||||
@@ -194,7 +189,7 @@ public class HillshadeLayer extends Layer {
|
||||
/**
|
||||
* Set the HillshadeShadowColor property transition options
|
||||
*
|
||||
* @param options transition options for String
|
||||
* @param options transition options for String[]
|
||||
*/
|
||||
public void setHillshadeShadowColorTransition(@NonNull TransitionOptions options) {
|
||||
checkThread();
|
||||
@@ -204,36 +199,19 @@ public class HillshadeLayer extends Layer {
|
||||
/**
|
||||
* Get the HillshadeHighlightColor property
|
||||
*
|
||||
* @return property wrapper value around String
|
||||
* @return property wrapper value around String[]
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getHillshadeHighlightColor() {
|
||||
public PropertyValue<String[]> getHillshadeHighlightColor() {
|
||||
checkThread();
|
||||
return (PropertyValue<String>) new PropertyValue("hillshade-highlight-color", nativeGetHillshadeHighlightColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that faces towards the light source.
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
*/
|
||||
@ColorInt
|
||||
public int getHillshadeHighlightColorAsInt() {
|
||||
checkThread();
|
||||
PropertyValue<String> value = getHillshadeHighlightColor();
|
||||
if (value.isValue()) {
|
||||
return rgbaToColor(value.getValue());
|
||||
} else {
|
||||
throw new RuntimeException("hillshade-highlight-color was set as a Function");
|
||||
}
|
||||
return (PropertyValue<String[]>) new PropertyValue("hillshade-highlight-color", nativeGetHillshadeHighlightColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HillshadeHighlightColor property transition options
|
||||
*
|
||||
* @return transition options for String
|
||||
* @return transition options for String[]
|
||||
*/
|
||||
@NonNull
|
||||
public TransitionOptions getHillshadeHighlightColorTransition() {
|
||||
@@ -244,7 +222,7 @@ public class HillshadeLayer extends Layer {
|
||||
/**
|
||||
* Set the HillshadeHighlightColor property transition options
|
||||
*
|
||||
* @param options transition options for String
|
||||
* @param options transition options for String[]
|
||||
*/
|
||||
public void setHillshadeHighlightColorTransition(@NonNull TransitionOptions options) {
|
||||
checkThread();
|
||||
@@ -301,10 +279,26 @@ public class HillshadeLayer extends Layer {
|
||||
nativeSetHillshadeAccentColorTransition(options.getDuration(), options.getDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HillshadeMethod property
|
||||
*
|
||||
* @return property wrapper value around String
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getHillshadeMethod() {
|
||||
checkThread();
|
||||
return (PropertyValue<String>) new PropertyValue("hillshade-method", nativeGetHillshadeMethod());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetHillshadeIlluminationDirection();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetHillshadeIlluminationAltitude();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetHillshadeIlluminationAnchor();
|
||||
@@ -353,6 +347,10 @@ public class HillshadeLayer extends Layer {
|
||||
@Keep
|
||||
private native void nativeSetHillshadeAccentColorTransition(long duration, long delay);
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetHillshadeMethod();
|
||||
|
||||
@Override
|
||||
@Keep
|
||||
protected native void finalize() throws Throwable;
|
||||
|
||||
@@ -648,6 +648,42 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface HILLSHADE_ILLUMINATION_ANCHOR {}
|
||||
|
||||
// HILLSHADE_METHOD: The hillshade algorithm to use, one of `standard`, `basic`, `combined`, `igor`, or `multidirectional`. 
|
||||
|
||||
/**
|
||||
* The legacy hillshade method.
|
||||
*/
|
||||
public static final String HILLSHADE_METHOD_STANDARD = "standard";
|
||||
/**
|
||||
* Basic hillshade. Uses a simple physics model where the reflected light intensity is proportional to the cosine of the angle between the incident light and the surface normal. Similar to GDAL's {@link GDALDEM} default algorithm.
|
||||
*/
|
||||
public static final String HILLSHADE_METHOD_BASIC = "basic";
|
||||
/**
|
||||
* Hillshade algorithm whose intensity scales with slope. Similar to GDAL's {@link GDALDEM} with -combined option.
|
||||
*/
|
||||
public static final String HILLSHADE_METHOD_COMBINED = "combined";
|
||||
/**
|
||||
* Hillshade algorithm which tries to minimize effects on other map features beneath. Similar to GDAL's {@link GDALDEM} with -igor option.
|
||||
*/
|
||||
public static final String HILLSHADE_METHOD_IGOR = "igor";
|
||||
/**
|
||||
* Hillshade with multiple illumination directions. Uses the basic hillshade model with multiple independent light sources.
|
||||
*/
|
||||
public static final String HILLSHADE_METHOD_MULTIDIRECTIONAL = "multidirectional";
|
||||
|
||||
/**
|
||||
* The hillshade algorithm to use, one of `standard`, `basic`, `combined`, `igor`, or `multidirectional`. 
|
||||
*/
|
||||
@StringDef({
|
||||
HILLSHADE_METHOD_STANDARD,
|
||||
HILLSHADE_METHOD_BASIC,
|
||||
HILLSHADE_METHOD_COMBINED,
|
||||
HILLSHADE_METHOD_IGOR,
|
||||
HILLSHADE_METHOD_MULTIDIRECTIONAL,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface HILLSHADE_METHOD {}
|
||||
|
||||
// ANCHOR: Whether extruded geometries are lit relative to the map or viewport.
|
||||
|
||||
/**
|
||||
|
||||
@@ -507,6 +507,7 @@ public class PropertyFactory {
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -518,6 +519,7 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -1428,17 +1430,17 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
}
|
||||
|
||||
/**
|
||||
* The direction of the light source used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`.
|
||||
* The direction of the light source(s) used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`. Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
* @param value a Float[] value
|
||||
* @return property wrapper around Float[]
|
||||
*/
|
||||
public static PropertyValue<Float> hillshadeIlluminationDirection(Float value) {
|
||||
public static PropertyValue<Float[]> hillshadeIlluminationDirection(Float[] value) {
|
||||
return new PaintPropertyValue<>("hillshade-illumination-direction", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The direction of the light source used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`.
|
||||
* The direction of the light source(s) used to generate the hillshading with 0 as the top of the viewport if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `viewport` and due north if {@link Property.HILLSHADE_ILLUMINATION_ANCHOR} is set to `map`. Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
@@ -1447,6 +1449,26 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
return new PaintPropertyValue<>("hillshade-illumination-direction", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* The altitude of the light source(s) used to generate the hillshading with 0 as sunset and 90 as noon. Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param value a Float[] value
|
||||
* @return property wrapper around Float[]
|
||||
*/
|
||||
public static PropertyValue<Float[]> hillshadeIlluminationAltitude(Float[] value) {
|
||||
return new PaintPropertyValue<>("hillshade-illumination-altitude", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The altitude of the light source(s) used to generate the hillshading with 0 as sunset and 90 as noon. Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
*/
|
||||
public static PropertyValue<Expression> hillshadeIlluminationAltitude(Expression expression) {
|
||||
return new PaintPropertyValue<>("hillshade-illumination-altitude", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Direction of light source when map is rotated.
|
||||
*
|
||||
@@ -1488,27 +1510,17 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that face away from the light source.
|
||||
* The shading color of areas that face away from the light source(s). Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
* @param value a String[] value
|
||||
* @return property wrapper around String[]
|
||||
*/
|
||||
public static PropertyValue<String> hillshadeShadowColor(@ColorInt int value) {
|
||||
return new PaintPropertyValue<>("hillshade-shadow-color", colorToRgbaString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that face away from the light source.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
*/
|
||||
public static PropertyValue<String> hillshadeShadowColor(String value) {
|
||||
public static PropertyValue<String[]> hillshadeShadowColor(String[] value) {
|
||||
return new PaintPropertyValue<>("hillshade-shadow-color", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that face away from the light source.
|
||||
* The shading color of areas that face away from the light source(s). Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
@@ -1518,27 +1530,17 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that faces towards the light source.
|
||||
* The shading color of areas that faces towards the light source(s). Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
* @param value a String[] value
|
||||
* @return property wrapper around String[]
|
||||
*/
|
||||
public static PropertyValue<String> hillshadeHighlightColor(@ColorInt int value) {
|
||||
return new PaintPropertyValue<>("hillshade-highlight-color", colorToRgbaString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that faces towards the light source.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
*/
|
||||
public static PropertyValue<String> hillshadeHighlightColor(String value) {
|
||||
public static PropertyValue<String[]> hillshadeHighlightColor(String[] value) {
|
||||
return new PaintPropertyValue<>("hillshade-highlight-color", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The shading color of areas that faces towards the light source.
|
||||
* The shading color of areas that faces towards the light source(s). Only when {@link Property.HILLSHADE_METHOD} is set to `multidirectional` can you specify multiple light sources.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
@@ -1577,6 +1579,76 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
return new PaintPropertyValue<>("hillshade-accent-color", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* The hillshade algorithm to use, one of `standard`, `basic`, `combined`, `igor`, or `multidirectional`. 
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
*/
|
||||
public static PropertyValue<String> hillshadeMethod(@Property.HILLSHADE_METHOD String value) {
|
||||
return new PaintPropertyValue<>("hillshade-method", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The hillshade algorithm to use, one of `standard`, `basic`, `combined`, `igor`, or `multidirectional`. 
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
*/
|
||||
public static PropertyValue<Expression> hillshadeMethod(Expression expression) {
|
||||
return new PaintPropertyValue<>("hillshade-method", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* The opacity at which the color-relief will be drawn.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
*/
|
||||
public static PropertyValue<Float> colorReliefOpacity(Float value) {
|
||||
return new PaintPropertyValue<>("color-relief-opacity", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The opacity at which the color-relief will be drawn.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
*/
|
||||
public static PropertyValue<Expression> colorReliefOpacity(Expression expression) {
|
||||
return new PaintPropertyValue<>("color-relief-opacity", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the color of each pixel based on its elevation. Should be an expression that uses `["elevation"]` as input.
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
*/
|
||||
public static PropertyValue<String> colorReliefColor(@ColorInt int value) {
|
||||
return new PaintPropertyValue<>("color-relief-color", colorToRgbaString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the color of each pixel based on its elevation. Should be an expression that uses `["elevation"]` as input.
|
||||
*
|
||||
* @param value a String value
|
||||
* @return property wrapper around String
|
||||
*/
|
||||
public static PropertyValue<String> colorReliefColor(String value) {
|
||||
return new PaintPropertyValue<>("color-relief-color", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the color of each pixel based on its elevation. Should be an expression that uses `["elevation"]` as input.
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
*/
|
||||
public static PropertyValue<Expression> colorReliefColor(Expression expression) {
|
||||
return new PaintPropertyValue<>("color-relief-color", expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* The color with which the background will be drawn.
|
||||
*
|
||||
@@ -2228,7 +2300,7 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
}
|
||||
|
||||
/**
|
||||
* Font stack to use for displaying text.
|
||||
* Fonts to use for displaying text. If the `glyphs` root property is specified, this array is joined together and interpreted as a font stack name. Otherwise, it is interpreted as a cascading fallback list of local font names.
|
||||
*
|
||||
* @param value a String[] value
|
||||
* @return property wrapper around String[]
|
||||
@@ -2238,7 +2310,7 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
}
|
||||
|
||||
/**
|
||||
* Font stack to use for displaying text.
|
||||
* Fonts to use for displaying text. If the `glyphs` root property is specified, this array is joined together and interpreted as a font stack name. Otherwise, it is interpreted as a cascading fallback list of local font names.
|
||||
*
|
||||
* @param value a String[] value
|
||||
* @return property wrapper around String[]
|
||||
@@ -2395,7 +2467,9 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
When present, this property takes precedence over {@link Property.TEXT_ANCHOR}, {@link PropertyFactory#textVariableAnchor}, {@link PropertyFactory#textOffset}, and {@link PropertyFactory#textRadialOffset}.
|
||||
|
||||
```json
|
||||
|
||||
{ "text-variable-anchor-offset": ["top", [0, 4], "left", [3,0], "bottom", [1, 1]] }
|
||||
|
||||
```
|
||||
|
||||
When the renderer chooses the `top` anchor, `[0, 4]` will be used for {@link PropertyFactory#textOffset}; the text will be shifted down by 4 ems.
|
||||
@@ -2417,7 +2491,9 @@ The unit is in density-independent pixels only for SDF sprites that were created
|
||||
When present, this property takes precedence over {@link Property.TEXT_ANCHOR}, {@link PropertyFactory#textVariableAnchor}, {@link PropertyFactory#textOffset}, and {@link PropertyFactory#textRadialOffset}.
|
||||
|
||||
```json
|
||||
|
||||
{ "text-variable-anchor-offset": ["top", [0, 4], "left", [3,0], "bottom", [1, 1]] }
|
||||
|
||||
```
|
||||
|
||||
When the renderer chooses the `top` anchor, `[0, 4]` will be used for {@link PropertyFactory#textOffset}; the text will be shifted down by 4 ems.
|
||||
|
||||
@@ -3,9 +3,10 @@ package org.maplibre.android.integration
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import org.junit.Ignore
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.maplibre.android.testapp.activity.fragment.ViewPagerActivity
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -19,6 +20,17 @@ class ViewPagerScrollTest : BaseIntegrationTest() {
|
||||
@get:Rule
|
||||
var activityRule: ActivityTestRule<ViewPagerActivity> = ActivityTestRule(ViewPagerActivity::class.java)
|
||||
|
||||
@Before
|
||||
override fun beforeTest() {
|
||||
super.beforeTest()
|
||||
// Wait for the initial page tab to be visible before starting the test
|
||||
// This ensures the ViewPager and PagerTabStrip are fully laid out
|
||||
val initialTabVisible = device.wait(Until.hasObject(By.text("Page 0")), TIMEOUT_LONG)
|
||||
if (!initialTabVisible) {
|
||||
throw AssertionError("ViewPager tabs not visible after ${TIMEOUT_LONG}ms - Page 0 not found")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@LargeTest
|
||||
fun scrollViewPager() {
|
||||
@@ -32,6 +44,19 @@ class ViewPagerScrollTest : BaseIntegrationTest() {
|
||||
}
|
||||
|
||||
private fun clickTab(index: Int) {
|
||||
device.findObject(UiSelector().text("Page $index")).click()
|
||||
val text = "Page $index"
|
||||
val found = device.wait(Until.hasObject(By.text(text)), TIMEOUT_UI_SEARCH_WAIT)
|
||||
if (!found) {
|
||||
throw AssertionError("Tab '$text' not found after ${TIMEOUT_UI_SEARCH_WAIT}ms")
|
||||
}
|
||||
val tab = device.findObject(By.text(text))
|
||||
?: throw AssertionError("Tab '$text' was detected but findObject returned null")
|
||||
tab.click()
|
||||
// Small delay to allow ViewPager to settle after tab click
|
||||
device.waitForIdle(500)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TIMEOUT_LONG = 15000L
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class LocationIndicatorLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Double[] propertyValue = new Double[] {0.0, 0.0, 0.0};
|
||||
layer.setProperties(location(propertyValue));
|
||||
assertEquals(layer.getLocation().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getLocation().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -386,7 +386,7 @@ public class CircleLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(circleTranslate(propertyValue));
|
||||
assertEquals(layer.getCircleTranslate().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getCircleTranslate().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
package org.maplibre.android.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
|
||||
|
||||
import org.maplibre.geojson.LineString;
|
||||
import org.maplibre.geojson.MultiLineString;
|
||||
import org.maplibre.geojson.MultiPoint;
|
||||
import org.maplibre.geojson.MultiPolygon;
|
||||
import org.maplibre.geojson.Point;
|
||||
import org.maplibre.geojson.Polygon;
|
||||
import org.maplibre.android.maps.BaseLayerTest;
|
||||
import org.junit.Before;
|
||||
import timber.log.Timber;
|
||||
|
||||
import org.maplibre.android.style.expressions.Expression;
|
||||
import org.maplibre.android.style.layers.ColorReliefLayer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.maplibre.android.style.expressions.Expression.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.maplibre.android.style.layers.Property.*;
|
||||
import static org.maplibre.android.style.layers.PropertyFactory.*;
|
||||
|
||||
import org.maplibre.android.style.layers.TransitionOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for ColorReliefLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4ClassRunner.class)
|
||||
public class ColorReliefLayerTest extends BaseLayerTest {
|
||||
|
||||
private ColorReliefLayer layer;
|
||||
private final List<Point> pointsList = new ArrayList<Point>() {
|
||||
{
|
||||
add(Point.fromLngLat(55.30122473231012, 25.26476622289597));
|
||||
add(Point.fromLngLat(55.29743486255916, 25.25827212207261));
|
||||
add(Point.fromLngLat(55.28978863411328, 25.251356725509737));
|
||||
add(Point.fromLngLat(55.300027931336984, 25.246425506635504));
|
||||
add(Point.fromLngLat(55.307474692951274, 25.244200378933655));
|
||||
add(Point.fromLngLat(55.31212891895635, 25.256408010450187));
|
||||
add(Point.fromLngLat(55.30774064871093, 25.26266169122738));
|
||||
add(Point.fromLngLat(55.301357710197806, 25.264946609615492));
|
||||
add(Point.fromLngLat(55.30122473231012, 25.26476622289597));
|
||||
}
|
||||
};
|
||||
|
||||
@Before
|
||||
@UiThreadTest
|
||||
public void beforeTest(){
|
||||
super.before();
|
||||
layer = new ColorReliefLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
setupLayer(layer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSourceId() {
|
||||
Timber.i("SourceId");
|
||||
assertNotNull(layer);
|
||||
assertEquals(layer.getSourceId(), "composite");
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSetVisibility() {
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSourceLayer() {
|
||||
Timber.i("SourceLayer");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testFilter() {
|
||||
Timber.i("Filter");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getFilter(), null);
|
||||
|
||||
// Set
|
||||
Expression filter = eq(get("undefined"), literal(1.0));
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
|
||||
// Set constant
|
||||
filter = literal(true);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testFilterDistance() {
|
||||
Timber.i("FilterDistance");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getFilter(), null);
|
||||
|
||||
// distance with Point
|
||||
Expression filter = lt(distance(Point.fromLngLat(1.0, 1.0)), 50);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
|
||||
// distance with LineString
|
||||
filter = lt(distance(LineString.fromLngLats(pointsList)), 50);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
|
||||
// distance with MultiPoint
|
||||
filter = lt(distance(MultiPoint.fromLngLats(pointsList)), 50);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
|
||||
// distance with MultiPoint
|
||||
filter = lt(distance(MultiLineString.fromLngLats(Collections.singletonList(pointsList))), 50);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
|
||||
// distance with Polygon
|
||||
filter = lt(distance(Polygon.fromLngLats(Collections.singletonList(pointsList))), 50);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
|
||||
// distance with MultiPolygon
|
||||
filter = lt(distance(MultiPolygon.fromLngLats(Collections
|
||||
.singletonList(Collections.singletonList(pointsList)))), 50);
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testFilterWithin() {
|
||||
Timber.i("FilterWithin");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getFilter(), null);
|
||||
|
||||
Expression filter = within(Polygon.fromLngLats(Collections.singletonList(pointsList)));
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testColorReliefOpacityTransition() {
|
||||
Timber.i("color-relief-opacityTransitionOptions");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setColorReliefOpacityTransition(options);
|
||||
assertEquals(layer.getColorReliefOpacityTransition(), options);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testColorReliefOpacityAsConstant() {
|
||||
Timber.i("color-relief-opacity");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getColorReliefOpacity().getValue());
|
||||
|
||||
// Set and Get
|
||||
Float propertyValue = 0.3f;
|
||||
layer.setProperties(colorReliefOpacity(propertyValue));
|
||||
assertEquals(layer.getColorReliefOpacity().getValue(), propertyValue);
|
||||
}
|
||||
}
|
||||
@@ -271,7 +271,7 @@ public class FillExtrusionLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(fillExtrusionTranslate(propertyValue));
|
||||
assertEquals(layer.getFillExtrusionTranslate().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getFillExtrusionTranslate().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -372,7 +372,7 @@ public class FillLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(fillTranslate(propertyValue));
|
||||
assertEquals(layer.getFillTranslate().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getFillTranslate().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -92,9 +92,22 @@ public class HillshadeLayerTest extends BaseLayerTest {
|
||||
assertNull(layer.getHillshadeIlluminationDirection().getValue());
|
||||
|
||||
// Set and Get
|
||||
Float propertyValue = 0.3f;
|
||||
Float[] propertyValue = new Float[] {1.0f, 2.0f};
|
||||
layer.setProperties(hillshadeIlluminationDirection(propertyValue));
|
||||
assertEquals(layer.getHillshadeIlluminationDirection().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getHillshadeIlluminationDirection().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testHillshadeIlluminationAltitudeAsConstant() {
|
||||
Timber.i("hillshade-illumination-altitude");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getHillshadeIlluminationAltitude().getValue());
|
||||
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {1.0f, 2.0f};
|
||||
layer.setProperties(hillshadeIlluminationAltitude(propertyValue));
|
||||
assertArrayEquals(layer.getHillshadeIlluminationAltitude().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,20 +168,9 @@ public class HillshadeLayerTest extends BaseLayerTest {
|
||||
assertNull(layer.getHillshadeShadowColor().getValue());
|
||||
|
||||
// Set and Get
|
||||
String propertyValue = "rgba(255,128,0,0.7)";
|
||||
String[] propertyValue = new String[] {"rgba(255,0,0,1)", "rgba(0,0,255,1)"};
|
||||
layer.setProperties(hillshadeShadowColor(propertyValue));
|
||||
assertEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testHillshadeShadowColorAsIntConstant() {
|
||||
Timber.i("hillshade-shadow-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeShadowColor(Color.argb(127, 255, 127, 0)));
|
||||
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.argb(127, 255, 127, 0));
|
||||
assertArrayEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,20 +193,9 @@ public class HillshadeLayerTest extends BaseLayerTest {
|
||||
assertNull(layer.getHillshadeHighlightColor().getValue());
|
||||
|
||||
// Set and Get
|
||||
String propertyValue = "rgba(255,128,0,0.7)";
|
||||
String[] propertyValue = new String[] {"rgba(255,0,0,1)", "rgba(0,0,255,1)"};
|
||||
layer.setProperties(hillshadeHighlightColor(propertyValue));
|
||||
assertEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testHillshadeHighlightColorAsIntConstant() {
|
||||
Timber.i("hillshade-highlight-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeHighlightColor(Color.argb(127, 255, 127, 0)));
|
||||
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.argb(127, 255, 127, 0));
|
||||
assertArrayEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -242,4 +233,17 @@ public class HillshadeLayerTest extends BaseLayerTest {
|
||||
layer.setProperties(hillshadeAccentColor(Color.argb(127, 255, 127, 0)));
|
||||
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.argb(127, 255, 127, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testHillshadeMethodAsConstant() {
|
||||
Timber.i("hillshade-method");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getHillshadeMethod().getValue());
|
||||
|
||||
// Set and Get
|
||||
String propertyValue = HILLSHADE_METHOD_STANDARD;
|
||||
layer.setProperties(hillshadeMethod(propertyValue));
|
||||
assertEquals(layer.getHillshadeMethod().getValue(), propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ public class LineLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(lineTranslate(propertyValue));
|
||||
assertEquals(layer.getLineTranslate().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getLineTranslate().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -552,7 +552,7 @@ public class LineLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {};
|
||||
layer.setProperties(lineDasharray(propertyValue));
|
||||
assertEquals(layer.getLineDasharray().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getLineDasharray().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -356,7 +356,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f, 0f, 0f};
|
||||
layer.setProperties(iconTextFitPadding(propertyValue));
|
||||
assertEquals(layer.getIconTextFitPadding().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getIconTextFitPadding().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -424,11 +424,11 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = {2.0f, 2.0f, 2.0f, 2.0f};
|
||||
layer.setProperties(iconPadding(propertyValue));
|
||||
assertEquals(layer.getIconPadding().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getIconPadding().getValue(), propertyValue);
|
||||
// Single number value can be used too for backward compatibility
|
||||
Float number = propertyValue[0] + 1.0f;
|
||||
layer.setProperties(iconPadding(number));
|
||||
assertEquals(layer.getIconPadding().getValue(), new Float[]{number, number, number, number});
|
||||
assertArrayEquals(layer.getIconPadding().getValue(), new Float[]{number, number, number, number});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -467,7 +467,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(iconOffset(propertyValue));
|
||||
assertEquals(layer.getIconOffset().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getIconOffset().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -576,7 +576,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
String[] propertyValue = new String[]{"Open Sans Regular", "Arial Unicode MS Regular"};
|
||||
layer.setProperties(textFont(propertyValue));
|
||||
assertEquals(layer.getTextFont().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getTextFont().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -719,7 +719,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
String[] propertyValue = new String[0];
|
||||
layer.setProperties(textVariableAnchor(propertyValue));
|
||||
assertEquals(layer.getTextVariableAnchor().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getTextVariableAnchor().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -732,7 +732,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Object[] propertyValue = new Object[] {"top", new Float[]{1f, 2f}};
|
||||
layer.setProperties(textVariableAnchorOffset(propertyValue));
|
||||
assertEquals(layer.getTextVariableAnchorOffset().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getTextVariableAnchorOffset().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -784,7 +784,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
String[] propertyValue = new String[0];
|
||||
layer.setProperties(textWritingMode(propertyValue));
|
||||
assertEquals(layer.getTextWritingMode().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getTextWritingMode().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -875,7 +875,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(textOffset(propertyValue));
|
||||
assertEquals(layer.getTextOffset().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getTextOffset().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1164,7 +1164,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(iconTranslate(propertyValue));
|
||||
assertEquals(layer.getIconTranslate().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getIconTranslate().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1414,7 +1414,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
// Set and Get
|
||||
Float[] propertyValue = new Float[] {0f, 0f};
|
||||
layer.setProperties(textTranslate(propertyValue));
|
||||
assertEquals(layer.getTextTranslate().getValue(), propertyValue);
|
||||
assertArrayEquals(layer.getTextTranslate().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -231,12 +231,12 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
|
||||
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
|
||||
<% } -%>
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
|
||||
<%- propertyType(property).endsWith('[]') ? 'assertArrayEquals' : 'assertEquals' %>(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
|
||||
<% if (property.type === 'padding') { -%>
|
||||
// Single number value can be used too for backward compatibility
|
||||
Float number = propertyValue[0] + 1.0f;
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(number));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), new Float[]{number, number, number, number});
|
||||
assertArrayEquals(layer.get<%- camelize(property.name) %>().getValue(), new Float[]{number, number, number, number});
|
||||
<% } -%>
|
||||
<% if (property.tokens) { -%>
|
||||
|
||||
|
||||
@@ -23,7 +23,11 @@ class ViewPagerActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityViewpagerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.viewPager.adapter = MapFragmentAdapter(this, supportFragmentManager)
|
||||
val adapter = MapFragmentAdapter(this, supportFragmentManager)
|
||||
binding.viewPager.adapter = adapter
|
||||
// Ensure all pages are instantiated so their titles are available to UI tests immediately
|
||||
// This keeps all 5 fragments in memory so PagerTabStrip shows all titles
|
||||
binding.viewPager.offscreenPageLimit = adapter.count
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
|
||||
@@ -119,6 +119,10 @@ global.propertyType = function propertyType(property) {
|
||||
return 'String';
|
||||
case 'color':
|
||||
return 'String';
|
||||
case 'numberArray':
|
||||
return 'Float[]';
|
||||
case 'colorArray':
|
||||
return 'String[]';
|
||||
case 'padding':
|
||||
return 'Float[]';
|
||||
case 'variableAnchorOffsetCollection':
|
||||
@@ -145,6 +149,10 @@ global.propertyJavaType = function propertyType(property) {
|
||||
return 'String';
|
||||
case 'color':
|
||||
return 'String';
|
||||
case 'numberArray':
|
||||
return 'float[]';
|
||||
case 'colorArray':
|
||||
return 'String[]';
|
||||
case 'array':
|
||||
return `${propertyJavaType({type:property.value})}[]`;
|
||||
default:
|
||||
@@ -164,6 +172,10 @@ global.propertyJNIType = function propertyJNIType(property) {
|
||||
return 'String';
|
||||
case 'color':
|
||||
return 'String';
|
||||
case 'numberArray':
|
||||
return 'jarray<jfloat>';
|
||||
case 'colorArray':
|
||||
return 'jarray<jstring>';
|
||||
case 'array':
|
||||
return `jarray<${propertyType({type:property.value})}[]>`;
|
||||
default:
|
||||
@@ -197,6 +209,10 @@ global.propertyNativeType = function (property) {
|
||||
return `${camelize(property.name)}Type`;
|
||||
case 'color':
|
||||
return `Color`;
|
||||
case 'numberArray':
|
||||
return 'std::vector<float>';
|
||||
case 'colorArray':
|
||||
return 'std::vector<Color>';
|
||||
case 'padding':
|
||||
return 'Padding';
|
||||
case 'variableAnchorOffsetCollection':
|
||||
@@ -237,6 +253,10 @@ global.defaultExpressionJava = function(property) {
|
||||
return "string";
|
||||
case 'color':
|
||||
return 'toColor';
|
||||
case 'numberArray':
|
||||
return 'array';
|
||||
case 'colorArray':
|
||||
return 'array';
|
||||
case 'padding':
|
||||
return 'toPadding';
|
||||
case 'array':
|
||||
@@ -271,6 +291,10 @@ global.defaultValueJava = function(property) {
|
||||
return snakeCaseUpper(property.name) + "_" + snakeCaseUpper(Object.keys(property.values)[0]);
|
||||
case 'color':
|
||||
return '"rgba(255,128,0,0.7)"';
|
||||
case 'numberArray':
|
||||
return 'new Float[] {1.0f, 2.0f}';
|
||||
case 'colorArray':
|
||||
return 'new String[] {"rgba(255,0,0,1)", "rgba(0,0,255,1)"}';
|
||||
case 'padding':
|
||||
return '{2.0f, 2.0f, 2.0f, 2.0f}';
|
||||
case 'variableAnchorOffsetCollection':
|
||||
@@ -409,6 +433,10 @@ global.evaluatedType = function (property) {
|
||||
return (isLightProperty(property) ? 'Light' : '') + `${camelize(property.name)}Type`;
|
||||
case 'color':
|
||||
return `Color`;
|
||||
case 'numberArray':
|
||||
return 'std::vector<float>';
|
||||
case 'colorArray':
|
||||
return 'std::vector<Color>';
|
||||
case 'array':
|
||||
if (property.length) {
|
||||
return `std::array<${evaluatedType({type: property.value})}, ${property.length}>`;
|
||||
|
||||
Reference in New Issue
Block a user