Repository navigation
Draw many polylines as raster tiles (PolylineTiler) - #34
Merged
Merged
Conversation
MarkerState, CircleState, PolylineState, PolygonState, GroundImageState and RasterLayerState get an optional onAdded, called with the state each time the overlay goes from not being on the map to being on it: after the renderer's onAdd returned for a native overlay, after the tile layer's URL template was handed to the map for a tiled one (the tile images may still be loading). It is not called for in-place changes, for a move between native drawing and tiles, on clear or when the map goes away, and is called again after a remove and a later add. Always on the main actor. Like onClick it is not part of the id, the fingerprint, == or the hash, and replacing it redraws nothing. The record of what is on the map lives in OverlayAddedTracker, one per core controller, apart from the entity managers: providers clear those on a style reload and re-create everything, which is not the app adding anything. PolygonController admits tiled polygons after PolygonTiler.route, which returns once the provider's raster upsert has. MarkerIngestionEngine gets an SPI overload that takes the tracker, notifies the natively drawn markers and returns the newly tiled ones for the provider to admit after its tile layer. The Boston sample hid its loading overlay two frames after handing the list over, then showed an empty map for about 4.7 s on an iPad while the SDK unioned holes and tiled the parcels; this gives it something to wait for.
… on the map Registering 100,000 tiled entities for taps (each computes its fingerprint) takes about a second after PolygonTiler.route returns. On an iPad the tiles were already showing under the loading overlay while onAdded waited for that bookkeeping.
…ge makes it untileable Whether a polygon is tiled was decided only on add. Setting geodesic on a tiled polygon in place, or giving it points that span half the world or fewer than three, kept it in the tiles, drawn with straight edges. update() now checks canTile: a polygon that fails it leaves the tiles (its slot in the renderer is emptied, so only the tiles it was in are drawn again) and is handed to the renderer. It stays on the map, so this is not an add. The reverse is left alone: a native polygon that could now be tiled already looks right. Same as js-sdk-core.
# Conflicts: # Tests/MapConductorCoreTests/PolygonTilingInPlaceTests.swift
… lines by their box The tolerance is the finger (tapTolerance) plus half the line's width, both pt x screen scale as before, so a wide road is hit at its edge. Each entity records its vertex box and width when registered; a tap first checks those flat boxes and reads the points of nearby lines only (50,000 lines no longer read 230,000 points per tap). The result is unchanged: the nearest line, at the closest point on it.
PolylineTilingOptions (public, same shape and defaults as PolygonTilingOptions), PolylineTileSet / PolylineTiler (layerId "mc-polyline-tiles") and PolylineController.tiler, following PolygonController's tiler path: tiled lines stay in PolylineManager for taps with a nil native polyline, an in-place change redraws only the tiles it touches, and a line that becomes geodesic (or under 2 points, or half the world wide) moves to native drawing without onAdded. The polygon tile set and renderer now sit on shared internals: ShapeTileSet (route, URL version, 16 ms coalescing, removal slots, teardown), ShapeTiler (routing) and ShapeTileRenderer (grid index, per-zoom simplification, tile cache, dropTilesIn, PNG). An open path is snapped, deduplicated and thinned with both ends kept; it is stroked with round caps and joins at its on-screen width, overhanging the tile, and drawn as a dot when it collapses to a point. MapViewContent.polylineTilingOptions and the PolylineTiling element set it per map (tracked like markerTilingOptions). OverlayStacking puts the polyline tiles at the bottom of the polyline band: over circles, under native polylines and markers. The public API grows by additions only.
Contributor
Author
|
向け先を |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
ポリゴンと同じように、ポリラインも数万本を渡せるようにするためです。ボストン市内の道路(54,645 本・234,765 頂点)をネイティブの線で描くと、iOS の Google で全 onAdded まで 114 秒・1.5 GB、Android の Google は Java ヒープが尽きて落ちます。ポリゴンのタイル化(
feat/polygon-tiling)と同じ仕組みで、多数のポリラインをラスタータイルとして描きます。設計の要点(web・Android・iOS で同じ)
Polylines(states):Polygonsと同じ形のまとめて渡す部品。そのインスタンスが足した id だけを足し引きするので、複数のPolylines/Polylineが同じ地図で共存できます(iOS は既存のPolylines(_:)のまま)。PolylineTilingOptions/PolylineTileSet/PolylineTiler/PolylineController.tiler: 名前と既定値(2,000 本以上または頂点 50,000 以上)はポリゴンと 1 対 1。レイヤー id はmc-polyline-tiles。ShapeTileSet/ShapeTiler/ShapeTileRendererに移し、Polygon*はその上の薄い層になりました。公開 API は追加のみです。polylineTilingOptions、Android は compose のPolylineTiling(options)、iOS はMapViewContent.polylineTilingOptions/PolylineTiling要素。このリポジトリで変えたこと
PolylineTilingOptions(public、ポリゴンと同じ形と既定値)、PolylineTileSet/PolylineTiler(layerIdmc-polyline-tiles)、PolylineController.tiler。PolygonControllerの tiler の経路をそのまま写し、タイルの線はタップ用にPolylineManagerに残る(ネイティブの polyline は nil)。その場の変更は触れたタイルだけ描き直し、geodesic になった線などは onAdded なしでネイティブへ移る。ShapeTileSet/ShapeTiler/ShapeTileRendererに移した。MapViewContent.polylineTilingOptionsとPolylineTiling要素(markerTilingOptionsと同じ作り)。OverlayStacking: ポリラインのタイルはポリラインの帯の最下段。PolylineManager: 指の大きさ+線幅の半分であたる。各 entity の外接矩形と線幅を登録時に記録し、近い線の点だけ読む(5 万本で毎タップ 23 万点を読まない)。検証(iOS、追従後の 4ea1d59)
scripts/api-surface.sh check): core と googlemaps 以外の 10 プロバイダ ok。core は +18 / -0(PolylineTiling・MapViewContent.polylineTilingOptions・PolylineTilingOptionsほか)、プロバイダは変化なし。挙動の変わる所
PolylineManager.find、タイルでもネイティブでも同じ)。許容距離 = 既存の指の大きさ(tapTolerance)+ 線幅 / 2。太い線は縁から指の大きさ以内であたります。複数あたれば最も近い線。外接矩形で先に候補を絞るので、5 万本でも毎タップ全点をなめません。返す位置(線上の最近点)は今までどおりです。OverlayStacking.rasterKey(styleLayerId:))。追加の順に関係なく、ポリラインのタイルがネイティブのポリラインの下に入ります。SDK の制約で重なり順を守れないもの
確認できていないもの
OutOfMemoryErrorで落ちます(GoogleMap.addPolyline→PolylineOptions.writeToParcel、Java ヒープが上限 512 MB に到達)。1 本ずつ Parcel に詰めて GMS に渡すためで、タイル化ありなら落ちません。このため Google のタイル化あり/なしの時間は並べられていません。OpenMobileMapsDriverConformanceTest1 件(develop のLog.isLoggableがモックされていない)、iOS ArcGIS・TomTom の単体テスト各 1 件、iOS Google のテストターゲットのビルド(GoogleMaps が iOS 17 を要求)。base について
ポリラインの差分だけをレビューできるように、base は
feat/overlay-on-added(feat/polygon-tiling+ onAdded + ボストンのサンプル。そのリポジトリに無い場合は develop)にしています。feat/polygon-tilingは develop にマージ済みなので、feat/overlay-on-addedが develop に入ったら、この PR の base を develop に付け替えてください。追従は rebase せず merge commit で行いました(
origin/feat/polygon-tiling→feat/overlay-on-added→feat/polyline-tiling)。マージの順番
各リポジトリの
feat/overlay-on-added→(base を develop に付け替えて)ios-sdk-core → 各プロバイダ → 親。プロバイダは ios-sdk-core のPolylineTiler/ 重なり順を使うので core が先です。マージはレビューのうえで判断してください(この PR はまだマージしていません)。親の PR: MapConductor/ios-sdk#18