fix: finalize WeatherRuntime host API boundary

This commit is contained in:
OpenAI Codex
2026-09-07 14:10:06 +08:00
parent 01295df4b8
commit 544e4aee3a
8 changed files with 94 additions and 6 deletions

View File

@@ -1194,6 +1194,30 @@ jni::jboolean NativeMapView::setRasterParticleColors(JNIEnv& env,
return true;
}
jni::jboolean NativeMapView::setRasterParticleColor(JNIEnv& env,
const jni::String& layerId,
const jni::Array<jni::jfloat>& particle) {
auto* layer = dynamic_cast<mbgl::style::RasterParticleLayer*>(map->getStyle().getLayer(jni::Make<std::string>(env, layerId)));
if (!layer || particle.Length(env) != 4) return false;
std::array<float, 4> color;
particle.GetRegion(env, 0, color);
if (!mbgl::style::validWeatherRGBA(color)) return false;
layer->setParticleColor(color);
return true;
}
jni::jboolean NativeMapView::setRasterParticleTrailColor(JNIEnv& env,
const jni::String& layerId,
const jni::Array<jni::jfloat>& trail) {
auto* layer = dynamic_cast<mbgl::style::RasterParticleLayer*>(map->getStyle().getLayer(jni::Make<std::string>(env, layerId)));
if (!layer || trail.Length(env) != 4) return false;
std::array<float, 4> color;
trail.GetRegion(env, 0, color);
if (!mbgl::style::validWeatherRGBA(color)) return false;
layer->setTrailColor(color);
return true;
}
jni::jboolean NativeMapView::setWeatherColorStops(JNIEnv& env,
const jni::String& layerId,
const jni::Array<jni::jfloat>& speeds,
@@ -1695,6 +1719,8 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::setStyleLayerFloatProperty, "nativeSetStyleLayerFloatProperty"),
METHOD(&NativeMapView::setStyleLayerVisibility, "nativeSetStyleLayerVisibility"),
METHOD(&NativeMapView::setRasterParticleColors, "nativeSetRasterParticleColors"),
METHOD(&NativeMapView::setRasterParticleColor, "nativeSetRasterParticleColor"),
METHOD(&NativeMapView::setRasterParticleTrailColor, "nativeSetRasterParticleTrailColor"),
METHOD(&NativeMapView::setWeatherColorStops, "nativeSetWeatherColorStops"),
METHOD(&NativeMapView::getWeatherColorStopCapacity, "nativeGetWeatherColorStopCapacity"),
METHOD(&NativeMapView::advanceRasterArraySourceFieldWindow, "nativeAdvanceRasterArraySourceFieldWindow"),