diff --git a/api/android-for-openmobilemaps.api b/api/android-for-openmobilemaps.api index 770ea7a..9e76ef6 100644 --- a/api/android-for-openmobilemaps.api +++ b/api/android-for-openmobilemaps.api @@ -126,6 +126,8 @@ public final class com.mapconductor.openmobilemaps.OpenMobileMapsLayers { public static final int GROUND_IMAGE_INDEX_FIRST; public static final int POLYGON_TILE_INDEX_FIRST; public static final int FIXED_INDEX_FIRST; + public static final int POLYLINE_TILE_INDEX_FIRST; + public static final int POLYLINE_INDEX; public static final int MARKER_TILE_INDEX_FIRST; public static final int ICON_INDEX; public com.mapconductor.openmobilemaps.OpenMobileMapsLayers(); @@ -140,6 +142,7 @@ public final class com.mapconductor.openmobilemaps.OpenMobileMapsLayers { public final io.openmobilemaps.mapscore.shared.map.LayerInterface insertBelowOverlays(io.openmobilemaps.mapscore.shared.map.MapInterface, io.openmobilemaps.mapscore.shared.map.LayerInterface); public final io.openmobilemaps.mapscore.shared.map.LayerInterface insertGroundImage(io.openmobilemaps.mapscore.shared.map.MapInterface, io.openmobilemaps.mapscore.shared.map.LayerInterface); public final io.openmobilemaps.mapscore.shared.map.LayerInterface insertPolygonTile(io.openmobilemaps.mapscore.shared.map.MapInterface, io.openmobilemaps.mapscore.shared.map.LayerInterface); + public final io.openmobilemaps.mapscore.shared.map.LayerInterface insertPolylineTile(io.openmobilemaps.mapscore.shared.map.MapInterface, io.openmobilemaps.mapscore.shared.map.LayerInterface); public final io.openmobilemaps.mapscore.shared.map.LayerInterface insertMarkerTile(io.openmobilemaps.mapscore.shared.map.MapInterface, io.openmobilemaps.mapscore.shared.map.LayerInterface); public final void remove(io.openmobilemaps.mapscore.shared.map.MapInterface, io.openmobilemaps.mapscore.shared.map.LayerInterface); public final void clearAll(); diff --git a/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsLayers.kt b/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsLayers.kt index 2989555..11f42f6 100644 --- a/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsLayers.kt +++ b/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsLayers.kt @@ -75,6 +75,7 @@ class OpenMobileMapsLayers { private val rasterBand = Band(RASTER_INDEX_FIRST, GROUND_IMAGE_INDEX_FIRST) private val groundImageBand = Band(GROUND_IMAGE_INDEX_FIRST, POLYGON_TILE_INDEX_FIRST) private val polygonTileBand = Band(POLYGON_TILE_INDEX_FIRST, FIXED_INDEX_FIRST) + private val polylineTileBand = Band(POLYLINE_TILE_INDEX_FIRST, POLYLINE_INDEX) private val markerTileBand = Band(MARKER_TILE_INDEX_FIRST, ICON_INDEX) private val bandOfLayer = mutableMapOf() @@ -84,7 +85,7 @@ class OpenMobileMapsLayers { polygonOutlineLayer.asLayerInterface() to FIXED_INDEX_FIRST + 1, circleFillLayer.asLayerInterface() to FIXED_INDEX_FIRST + 2, circleOutlineLayer.asLayerInterface() to FIXED_INDEX_FIRST + 3, - polylineLayer.asLayerInterface() to FIXED_INDEX_FIRST + 4, + polylineLayer.asLayerInterface() to POLYLINE_INDEX, iconLayer.asLayerInterface() to ICON_INDEX, ) } @@ -146,6 +147,12 @@ class OpenMobileMapsLayers { layer: LayerInterface, ): LayerInterface = insertInBand(map, layer, polygonTileBand) + /** ポリラインのタイル: ポリラインの帯の一番下(サークルの上、ネイティブのポリラインの下)。 */ + fun insertPolylineTile( + map: MapInterface, + layer: LayerInterface, + ): LayerInterface = insertInBand(map, layer, polylineTileBand) + /** マーカーのタイル: ポリラインの上、マーカー(アイコン)の下。 */ fun insertMarkerTile( map: MapInterface, @@ -203,6 +210,12 @@ class OpenMobileMapsLayers { /** 固定のオーバーレイ 6 種。下の枠を使い切らないよう十分離す。 */ const val FIXED_INDEX_FIRST = 1_000 + /** ポリラインのタイル。サークルの上、ネイティブのポリラインの下。 */ + const val POLYLINE_TILE_INDEX_FIRST = FIXED_INDEX_FIRST + 10 + + /** ネイティブのポリライン(固定)。ポリラインのタイルの上。 */ + const val POLYLINE_INDEX = FIXED_INDEX_FIRST + 50 + /** マーカーのタイル。ポリラインの上、マーカーの下。 */ const val MARKER_TILE_INDEX_FIRST = 1_100 diff --git a/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsMapViewController.kt b/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsMapViewController.kt index da86b27..394693a 100644 --- a/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsMapViewController.kt +++ b/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsMapViewController.kt @@ -22,6 +22,9 @@ import com.mapconductor.core.marker.dispatchGeoMarkerClick import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID import com.mapconductor.core.polygon.PolygonTiler import com.mapconductor.core.polygon.polygonTileRasterLayerState +import com.mapconductor.core.polyline.POLYLINE_TILE_LAYER_ID +import com.mapconductor.core.polyline.PolylineTiler +import com.mapconductor.core.polyline.polylineTileRasterLayerState import com.mapconductor.openmobilemaps.marker.OpenMobileMapsMarkerController import com.mapconductor.openmobilemaps.tile.WebMercatorTileLayerConfig import com.mapconductor.openmobilemaps.zoom.ZoomAltitudeConverter @@ -180,6 +183,18 @@ class OpenMobileMapsMapViewController( } } } + + // Many polylines too: the same raster layer path, in the polyline band. + polylineController.tiler = + PolylineTiler().apply { + onTemplate = { template, tileSize -> + if (template != null) { + rasterLayerController.upsert(polylineTileRasterLayerState(template, tileSize)) + } else { + rasterLayerController.removeById(POLYLINE_TILE_LAYER_ID) + } + } + } } /** diff --git a/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsOverlays.kt b/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsOverlays.kt index 0f0a232..087e6a8 100644 --- a/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsOverlays.kt +++ b/src/main/java/com/mapconductor/openmobilemaps/OpenMobileMapsOverlays.kt @@ -25,6 +25,7 @@ import com.mapconductor.core.marker.MarkerManager import com.mapconductor.core.marker.MarkerOverlayRendererInterface import com.mapconductor.core.polygon.AbstractPolygonOverlayRenderer import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID +import com.mapconductor.core.polyline.POLYLINE_TILE_LAYER_ID import com.mapconductor.core.polygon.PolygonController import com.mapconductor.core.polygon.PolygonEntityInterface import com.mapconductor.core.polygon.PolygonManagerInterface @@ -407,11 +408,18 @@ class OpenMobileMapsPolylineOverlayRenderer( override suspend fun removePolyline(entity: PolylineEntityInterface) = Unit override suspend fun onPostProcess() { - // 帯の中は zIndex の順(同じなら渡された順)。 + // 帯の中は zIndex の順(同じなら渡された順)。タイルで描く線(線の無い entity)は飛ばす。 lineLayer.setLines( - polylineManager.allEntities().sortedBy { it.state.zIndex }.flatMapTo(ArrayList()) { it.polyline.orEmpty() }, + polylineManager + .allEntities() + .sortedBy { it.state.zIndex } + .flatMapTo(ArrayList()) { nativePolylineOf(it).orEmpty() }, ) } + + @Suppress("USELESS_CAST") + private fun nativePolylineOf(entity: PolylineEntityInterface): OpenMobileMapsActualPolyline? = + entity.polyline as OpenMobileMapsActualPolyline? } // ── ポリゴン ────────────────────────────────────────────────────────────── @@ -707,6 +715,9 @@ class OpenMobileMapsRasterLayerOverlayRenderer( } else if (state.id == POLYGON_TILE_LAYER_ID) { // ポリゴンのタイルはポリゴンの帯の一番下(画像になったポリゴンであって、地図の画像ではない)。 layers.insertPolygonTile(holder.map, layer.asLayerInterface()) + } else if (state.id == POLYLINE_TILE_LAYER_ID) { + // ポリラインのタイルはポリラインの帯の一番下(サークルの上、ネイティブのポリラインの下)。 + layers.insertPolylineTile(holder.map, layer.asLayerInterface()) } else { layers.insertBelowOverlays(holder.map, layer.asLayerInterface()) },