From e60d0328988d737a3e5d8cde075f8491578f031e Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Tue, 10 Nov 2026 16:16:50 -0800 Subject: [PATCH] Support bulk Circles with raster tiles --- .../mapbox/MapboxMapViewController.kt | 15 +++++++++++++++ .../mapconductor/mapbox/MapboxOverlayStacking.kt | 3 +++ .../mapbox/circle/MapboxCircleOverlayRenderer.kt | 2 +- .../raster/MapboxRasterLayerOverlayRenderer.kt | 7 ++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt b/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt index 02e37c8..aedd292 100644 --- a/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt +++ b/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt @@ -1,5 +1,8 @@ package com.mapconductor.mapbox +import com.mapconductor.core.circle.CIRCLE_TILE_LAYER_ID +import com.mapconductor.core.circle.CircleTiler +import com.mapconductor.core.circle.circleTileRasterLayerState import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID import com.mapconductor.core.polygon.PolygonTiler import com.mapconductor.core.polygon.polygonTileRasterLayerState @@ -136,6 +139,18 @@ class MapboxMapViewController internal constructor( } } + // Many circles too: the same raster layer path, in the circle band. + circleController.tiler = + CircleTiler().apply { + onTemplate = { template, tileSize -> + if (template != null) { + rasterLayerController.upsert(circleTileRasterLayerState(template, tileSize)) + } else { + rasterLayerController.removeById(CIRCLE_TILE_LAYER_ID) + } + } + } + // Many polylines too: the same raster layer path, in the polyline band. polylineController.tiler = PolylineTiler().apply { diff --git a/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt b/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt index a850f33..06c1281 100644 --- a/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt +++ b/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt @@ -42,6 +42,9 @@ internal object MapboxOverlayStacking { /** ポリゴンのタイル(ラスター): ポリゴンの帯の一番下。 */ val POLYGON_TILE = key(OverlayKind.Polygon, Int.MIN_VALUE) + /** 円のタイル(ラスター): サークルの帯の一番下(ポリゴンの上、ネイティブの円とポリラインのタイルの下)。 */ + val CIRCLE_TILE = key(OverlayKind.Circle, Int.MIN_VALUE) + /** ポリラインのタイル(ラスター): ポリラインの帯の一番下(サークルの上、ネイティブのポリラインの下)。 */ val POLYLINE_TILE = key(OverlayKind.Polyline, Int.MIN_VALUE) diff --git a/src/main/java/com/mapconductor/mapbox/circle/MapboxCircleOverlayRenderer.kt b/src/main/java/com/mapconductor/mapbox/circle/MapboxCircleOverlayRenderer.kt index f0a7e86..2149b04 100644 --- a/src/main/java/com/mapconductor/mapbox/circle/MapboxCircleOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/mapbox/circle/MapboxCircleOverlayRenderer.kt @@ -65,7 +65,7 @@ class MapboxCircleOverlayRenderer( } override suspend fun onPostProcess() { - val circles = circleManager.allEntities() + val circles = circleManager.nativeEntities().filter { (it.circle as MapboxActualCircle?) != null } coroutine.launch { layer.draw(circles) } diff --git a/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt b/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt index e391bc7..348f341 100644 --- a/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt @@ -3,6 +3,7 @@ package com.mapconductor.mapbox.raster import com.mapbox.maps.extension.style.layers.generated.rasterLayer import com.mapbox.maps.extension.style.sources.addSource import com.mapbox.maps.extension.style.sources.generated.rasterSource +import com.mapconductor.core.circle.CIRCLE_TILE_LAYER_ID import com.mapconductor.core.controller.OverlayKind import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID import com.mapconductor.core.polyline.POLYLINE_TILE_LAYER_ID @@ -31,6 +32,8 @@ class MapboxRasterLayerOverlayRenderer( private fun isPolylineTileRaster(state: RasterLayerState): Boolean = state.id == POLYLINE_TILE_LAYER_ID + private fun isCircleTileRaster(state: RasterLayerState): Boolean = state.id == CIRCLE_TILE_LAYER_ID + /** Mapbox Android はタイル要求を書き換える公開 API を持たない。 */ override suspend fun onAdd( data: List, @@ -181,6 +184,8 @@ class MapboxRasterLayerOverlayRenderer( MapboxOverlayStacking.MARKER_TILE } else if (isPolygonTileRaster(state)) { MapboxOverlayStacking.POLYGON_TILE + } else if (isCircleTileRaster(state)) { + MapboxOverlayStacking.CIRCLE_TILE } else if (isPolylineTileRaster(state)) { MapboxOverlayStacking.POLYLINE_TILE } else { @@ -193,7 +198,7 @@ class MapboxRasterLayerOverlayRenderer( val ordered = stateById.values .asSequence() - .filter { !isMarkerTileRaster(it) && !isPolygonTileRaster(it) && !isPolylineTileRaster(it) } + .filter { !isMarkerTileRaster(it) && !isPolygonTileRaster(it) && !isPolylineTileRaster(it) && !isCircleTileRaster(it) } .sortedBy { it.zIndex } .mapNotNull { state -> handleById[state.id]?.let { handle -> state to handle } } .toList()