summaryrefslogtreecommitdiff
path: root/android-app/app/src/main
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-01 06:39:35 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-01 06:39:35 +0000
commit51ba800e5bb11e5c16b0deabcaa6479be2eef6ca (patch)
tree85de28f8b2e7c45d333f05add98fc2df222feb99 /android-app/app/src/main
parent9ec663b4aa79c48829cc3796be90dc130fa5f097 (diff)
fix(layers): TSS string constants + close openRawResource stream
Diffstat (limited to 'android-app/app/src/main')
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/ui/MapHandler.kt16
1 files changed, 10 insertions, 6 deletions
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/MapHandler.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/MapHandler.kt
index 02c9fca..f753335 100644
--- a/android-app/app/src/main/kotlin/org/terst/nav/ui/MapHandler.kt
+++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/MapHandler.kt
@@ -104,6 +104,10 @@ class MapHandler(private val maplibreMap: MapLibreMap) {
private val ATON_LABELS_ID = "aton-labels"
private var atonSource: GeoJsonSource? = null
+ private val TSS_SOURCE_ID = "tss-source"
+ private val TSS_LANES_ID = "tss-lanes-layer"
+ private val TSS_SEP_ID = "tss-sep-layer"
+
private val FISHING_LINE_SOURCE_ID = "fishing-line-source"
private val FISHING_LINE_LAYER_ID = "fishing-line-layer"
private var fishingLineSource: GeoJsonSource? = null
@@ -553,11 +557,11 @@ class MapHandler(private val maplibreMap: MapLibreMap) {
*/
fun setupTssLayer(style: Style, context: Context, visible: Boolean) {
val json = context.resources.openRawResource(R.raw.pacific_tss)
- .bufferedReader().readText()
- val src = GeoJsonSource("tss-source", FeatureCollection.fromJson(json))
+ .bufferedReader().use { it.readText() }
+ val src = GeoJsonSource(TSS_SOURCE_ID, FeatureCollection.fromJson(json))
style.addSource(src)
val v = if (visible) "visible" else "none"
- style.addLayer(FillLayer("tss-lanes-layer", "tss-source").apply {
+ style.addLayer(FillLayer(TSS_LANES_ID, TSS_SOURCE_ID).apply {
setFilter(Expression.neq(
Expression.get("type"), Expression.literal("separation_zone")))
setProperties(
@@ -574,7 +578,7 @@ class MapHandler(private val maplibreMap: MapLibreMap) {
PropertyFactory.visibility(v)
)
})
- style.addLayer(FillLayer("tss-sep-layer", "tss-source").apply {
+ style.addLayer(FillLayer(TSS_SEP_ID, TSS_SOURCE_ID).apply {
setFilter(Expression.eq(
Expression.get("type"), Expression.literal("separation_zone")))
setProperties(
@@ -588,8 +592,8 @@ class MapHandler(private val maplibreMap: MapLibreMap) {
/** Shows or hides the TSS lanes and separation zone layers on a live style. */
fun setTssLayerVisible(style: Style, visible: Boolean) {
val v = if (visible) "visible" else "none"
- style.getLayer("tss-lanes-layer")?.setProperties(PropertyFactory.visibility(v))
- style.getLayer("tss-sep-layer")?.setProperties(PropertyFactory.visibility(v))
+ style.getLayer(TSS_LANES_ID)?.setProperties(PropertyFactory.visibility(v))
+ style.getLayer(TSS_SEP_ID)?.setProperties(PropertyFactory.visibility(v))
}
/** Clears all tack markers. */