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

@@ -301,6 +301,14 @@ public final class MapLibreMap {
return nativeMapView.setRasterParticleColors(layerId, particleColor, trailColor);
}
public boolean setRasterParticleColor(String layerId, float[] particleColor) {
return nativeMapView.setRasterParticleColor(layerId, particleColor);
}
public boolean setRasterParticleTrailColor(String layerId, float[] trailColor) {
return nativeMapView.setRasterParticleTrailColor(layerId, trailColor);
}
/** Installs a validated WeatherColor speed ramp without changing particle style. */
public boolean setWeatherColorStops(String layerId, float[] speedsMps, float[] rgbaStops) {
return nativeMapView.setWeatherColorStops(layerId, speedsMps, rgbaStops);

View File

@@ -145,6 +145,10 @@ interface NativeMap {
boolean setRasterParticleColors(String layerId, float[] particleColor, float[] trailColor);
boolean setRasterParticleColor(String layerId, float[] particleColor);
boolean setRasterParticleTrailColor(String layerId, float[] trailColor);
boolean setWeatherColorStops(String layerId, float[] speedsMps, float[] rgbaStops);
int getWeatherColorStopCapacity();

View File

@@ -964,6 +964,14 @@ final class NativeMapView implements NativeMap {
return !checkState("setRasterParticleColors") && nativeSetRasterParticleColors(layerId, particleColor, trailColor);
}
public boolean setRasterParticleColor(String layerId, float[] particleColor) {
return !checkState("setRasterParticleColor") && nativeSetRasterParticleColor(layerId, particleColor);
}
public boolean setRasterParticleTrailColor(String layerId, float[] trailColor) {
return !checkState("setRasterParticleTrailColor") && nativeSetRasterParticleTrailColor(layerId, trailColor);
}
public boolean setWeatherColorStops(String layerId, float[] speedsMps, float[] rgbaStops) {
return !checkState("setWeatherColorStops") && nativeSetWeatherColorStops(layerId, speedsMps, rgbaStops);
}
@@ -1745,6 +1753,8 @@ final class NativeMapView implements NativeMap {
@Keep private native boolean nativeSetStyleLayerVisibility(String layerId, boolean visible);
@Keep private native boolean nativeSetRasterParticleColors(String layerId, float[] particleColor, float[] trailColor);
@Keep private native boolean nativeSetRasterParticleColor(String layerId, float[] particleColor);
@Keep private native boolean nativeSetRasterParticleTrailColor(String layerId, float[] trailColor);
@Keep private native boolean nativeSetWeatherColorStops(String layerId, float[] speedsMps, float[] rgbaStops);
@Keep private native int nativeGetWeatherColorStopCapacity();

View File

@@ -91,6 +91,15 @@ public final class WeatherRuntime {
public CommandResult setTrailOpacity(float opacity) { return setParticleFloat("raster-particle-trail-opacity", opacity); }
public CommandResult setTrailFade(float fade) { return setParticleFloat("raster-particle-trail-fade", fade); }
public CommandResult setParticleSpeedColorEnabled(boolean enabled) { return setParticleFloat("raster-particle-speed-color-enabled", enabled ? 1f : 0f); }
/** Sets only the particle RGBA; trail color and WeatherColor ramp are unchanged. */
public CommandResult setParticleColor(float red, float green, float blue, float alpha) {
return result(map.setRasterParticleColor(config.particleLayerId, new float[]{red, green, blue, alpha}));
}
/** Sets only the trail RGBA; particle color and WeatherColor ramp are unchanged. */
public CommandResult setTrailColor(float red, float green, float blue, float alpha) {
return result(map.setRasterParticleTrailColor(config.particleLayerId, new float[]{red, green, blue, alpha}));
}
/** Compatibility helper for existing callers; new Host code should use the independent setters. */
public CommandResult setParticleColors(float red, float green, float blue, float alpha, float trailRed, float trailGreen, float trailBlue, float trailAlpha) {
return result(map.setRasterParticleColors(config.particleLayerId, new float[]{red, green, blue, alpha}, new float[]{trailRed, trailGreen, trailBlue, trailAlpha}));
}