Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/android-for-openmobilemaps.api
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LayerInterface, Band>()

Expand All @@ -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,
)
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -407,11 +408,18 @@ class OpenMobileMapsPolylineOverlayRenderer(
override suspend fun removePolyline(entity: PolylineEntityInterface<OpenMobileMapsActualPolyline>) = 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>): OpenMobileMapsActualPolyline? =
entity.polyline as OpenMobileMapsActualPolyline?
}

// ── ポリゴン ──────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -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())
},
Expand Down
Loading