fix: guard STEP-113 empty annotation and expose PBF blockers
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -13,6 +13,8 @@ import org.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.maps.MapLibreMap
|
||||
import org.maplibre.android.maps.Style
|
||||
import org.maplibre.android.maps.WeatherRuntime
|
||||
import org.maplibre.android.style.layers.Layer
|
||||
import org.maplibre.android.style.layers.SymbolLayer
|
||||
import org.maplibre.android.style.sources.GeoJsonSource
|
||||
import org.maplibre.android.testapp.BuildConfig
|
||||
import org.maplibre.geojson.Feature
|
||||
@@ -43,11 +45,14 @@ internal class Step113PbfGateScene(
|
||||
private var exportSequence = 0L
|
||||
private var commandResults = JSONObject()
|
||||
private var savedGestures: List<Boolean>? = null
|
||||
private var annotationStyle: Style? = null
|
||||
private var detachedEmptyAnnotationLayer: Layer? = null
|
||||
private val poll = object : Runnable {
|
||||
override fun run() {
|
||||
if (!running || paused) return
|
||||
if (running) {
|
||||
try {
|
||||
checkAnnotationOwnership()
|
||||
// One shared snapshot query per refresh; all UI/log/export uses this copy.
|
||||
val native = JSONObject(map.getRenderSegmentDiagnostics())
|
||||
latest = envelope(native)
|
||||
@@ -63,6 +68,7 @@ internal class Step113PbfGateScene(
|
||||
append("STEP-113 $scenario · ${if (ready) "READY/PARTIAL" else failureReason ?: "LOADING"} · actual=${native.optInt("styleLayerCount")}\n")
|
||||
append("first=$firstFailure seq=${lastFrame?.optLong("sequence")} full=${trace?.optLong("fullRendered")} ")
|
||||
append("window=${trace?.optInt("windowCount")} mismatch=${trace?.optLong("decisionMismatch")}\n")
|
||||
append("Fast=${trace?.optLong("fastRendered")} · 空Annotation调整=${commandResults.optBoolean("emptyBuiltinAnnotationLayerRemoved")}\n")
|
||||
append(rank.joinToString(" / ") { "${it.optString("reason")}=${it.optLong("failures")}" })
|
||||
for (i in 0 until segments.length()) {
|
||||
val s = segments.getJSONObject(i)
|
||||
@@ -138,6 +144,8 @@ internal class Step113PbfGateScene(
|
||||
.put("deviceReferenceSelector", "用户STEP-112:RCRR_PREFIX[0,13)/[13,33)/[33,107)/[107,113)")
|
||||
.put("baseLayerManifest", layerManifest(base)).put("sprite", root.optString("sprite"))
|
||||
.put("glyphs", root.optString("glyphs")).put("vectorSource", JSONObject(source.toString()))
|
||||
.put("productionSources", JSONObject(root.getJSONObject("sources").toString()))
|
||||
.put("internalAnnotationPolicy", "仅STATIC_RC加载时移除空SDK辅助层;后续添加不再移除;原63层及Source原样")
|
||||
val hasField = scenario != Scenario.PBF63
|
||||
if (hasField) {
|
||||
val sources = root.getJSONObject("sources")
|
||||
@@ -176,9 +184,10 @@ internal class Step113PbfGateScene(
|
||||
if (hasField) "当前NavSea源码RC:rn-weather-color" else "基础63层全RETAINED")
|
||||
.put("requestedPlan", JSONObject(plan))
|
||||
commandResults.put("planAccepted", map.setRenderSegmentPlan(plan))
|
||||
map.setStyle(Style.Builder().fromJson(root.toString())) testStyle@ {
|
||||
map.setStyle(Style.Builder().fromJson(root.toString())) testStyle@ { style ->
|
||||
if (!running || epoch != generation) return@testStyle
|
||||
try {
|
||||
if (scenario == Scenario.STATIC_RC) removeEmptyAnnotationLayer(style, ids)
|
||||
map.cameraPosition = CameraPosition.Builder().target(LatLng(33.45, 129.97))
|
||||
.zoom(10.5).bearing(0.0).tilt(0.0).build()
|
||||
if (hasField) initializeFields()
|
||||
@@ -192,6 +201,57 @@ internal class Step113PbfGateScene(
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeEmptyAnnotationLayer(style: Style, baseIds: List<String>) {
|
||||
check(ANNOTATION_LAYER !in baseIds && map.annotations.isEmpty()) {
|
||||
"存在生产同名层或遗留Annotation,禁止移除辅助层"
|
||||
}
|
||||
check(!parity.getJSONObject("productionSources").has(ANNOTATION_SOURCE)) {
|
||||
"生产Style占用内部Annotation Source ID,禁止推断为空SDK依赖"
|
||||
}
|
||||
val layer = style.getLayer(ANNOTATION_LAYER)
|
||||
check(layer is SymbolLayer && layer.sourceId == ANNOTATION_SOURCE) {
|
||||
"内建Annotation层身份不符,保留现场"
|
||||
}
|
||||
check(style.getSource(ANNOTATION_SOURCE) != null) { "内建Annotation Source缺失" }
|
||||
// The object overload preserves the detached wrapper for restoration.
|
||||
check(style.removeLayer(layer)) { "空内建Annotation层移除失败" }
|
||||
annotationStyle = style
|
||||
detachedEmptyAnnotationLayer = layer
|
||||
check(style.getSource(ANNOTATION_SOURCE) != null) { "不得移除内建Source" }
|
||||
commandResults.put("emptyBuiltinAnnotationLayerRemoved", true)
|
||||
.put("annotationInstancesAtRemoval", 0).put("annotationSourcePreserved", true)
|
||||
parity.put("removedInternalLayer", ANNOTATION_LAYER)
|
||||
.put("adjustmentScope", "STATIC_RC一次;仅SDK空辅助层;非生产63层")
|
||||
logRecord("annotation-policy", JSONObject(commandResults.toString()).put("scenario", scenario.name))
|
||||
}
|
||||
|
||||
private fun restoreEmptyAnnotationLayer(reason: String) {
|
||||
val style = annotationStyle
|
||||
val layer = detachedEmptyAnnotationLayer
|
||||
try {
|
||||
if (style != null && layer != null && map.style === style && style.getLayer(ANNOTATION_LAYER) == null) {
|
||||
style.addLayer(layer)
|
||||
}
|
||||
commandResults.put("annotationRemovalEnded", reason)
|
||||
} finally {
|
||||
annotationStyle = null
|
||||
detachedEmptyAnnotationLayer = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkAnnotationOwnership() {
|
||||
val style = annotationStyle ?: return
|
||||
if (map.style !== style) {
|
||||
restoreEmptyAnnotationLayer("style-replaced")
|
||||
fail(IllegalStateException("Style已替换,空层调整停止;新Style图层原样保留"))
|
||||
} else if (map.annotations.isNotEmpty() || style.getLayer(ANNOTATION_LAYER) != null) {
|
||||
// Native AnnotationManager restores the point layer synchronously
|
||||
// at add/update, before Map::onUpdate. Polling only reports revocation.
|
||||
restoreEmptyAnnotationLayer("annotation-or-layer-added")
|
||||
fail(IllegalStateException("Annotation/辅助层已添加,保留内容并撤销STATIC_RC空层验收条件"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun addFields(layers: JSONArray) {
|
||||
layers.put(JSONObject().put("id", COLOR).put("type", "weather-color").put("source", SOURCE)
|
||||
.put("paint", JSONObject().put("weather-color-opacity", 0.62)))
|
||||
@@ -276,6 +336,10 @@ internal class Step113PbfGateScene(
|
||||
.put("build", c.optLong("build")).put("reuse", c.optLong("reuse"))
|
||||
.put("invalidation", c.optLong("invalidation")).put("fallback", c.optLong("fallbackCount"))
|
||||
.put("reason", c.optString("lastFallbackReason")))
|
||||
rs.getJSONObject(rs.length() - 1)
|
||||
.put("missingSourceIds", s.optJSONArray("missingSourceIds") ?: JSONArray())
|
||||
.put("placementCapable", s.optBoolean("placementCapable"))
|
||||
.put("placementGatePassed", s.optBoolean("placementGatePassed"))
|
||||
}
|
||||
return JSONObject().put("schema", "step113-summary").put("schemaVersion", 1).put("scenario", scenario.name)
|
||||
.put("sceneReady", ready).put("blockedReason", failureReason ?: JSONObject.NULL)
|
||||
@@ -291,6 +355,11 @@ internal class Step113PbfGateScene(
|
||||
.put("overwritten", t.optLong("overwritten")).put("decisionMismatch", t.optLong("decisionMismatch"))
|
||||
.put("fullRendered", t.optLong("fullRendered")).put("fastRendered", t.optLong("fastRendered"))
|
||||
.put("gateFailureCounts", counts).put("retained", rs)
|
||||
.put("commands", JSONObject(commandResults.toString()))
|
||||
.put("sources", native.optJSONArray("sources") ?: JSONArray())
|
||||
.put("placementChanged", native.optBoolean("placementChanged"))
|
||||
.put("placementTransitionActive", native.optBoolean("placementTransitionActive"))
|
||||
.put("symbolFadeChange", native.opt("symbolFadeChange") ?: JSONObject.NULL)
|
||||
}
|
||||
|
||||
fun export() {
|
||||
@@ -339,6 +408,8 @@ internal class Step113PbfGateScene(
|
||||
running = false
|
||||
++generation
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
try { restoreEmptyAnnotationLayer("scene-stopped") }
|
||||
catch (error: Exception) { Log.e(TAG, "annotation-layer-restore-failed", error) }
|
||||
runtime?.dispose()
|
||||
runtime = null
|
||||
savedGestures?.let { flags ->
|
||||
@@ -365,6 +436,8 @@ internal class Step113PbfGateScene(
|
||||
private const val PARTICLE = "rn-weather-particles"
|
||||
private const val PROBE_SOURCE = "step113-source-probe"
|
||||
private const val PROBE_LAYER = "step113-source-probe-circle"
|
||||
private const val ANNOTATION_SOURCE = "org.maplibre.annotations"
|
||||
private const val ANNOTATION_LAYER = "org.maplibre.annotations.points"
|
||||
private const val FORECAST_MS = 1786060800000L
|
||||
|
||||
private fun planJson(s: Scenario, finalBaseId: String): String {
|
||||
|
||||
Reference in New Issue
Block a user