Repository navigation
Draw large polygon sets as raster tiles (PolygonTiler) - #35
Merged
Merged
Conversation
pointOnSegment compared the dot product (p-a)·(p-b), a quantity in square degrees, with eps = 1e-6, so any tap within about 0.001° (~100 m) of the middle of a short edge counted as on that edge. With building footprints the first nearby building in the list was returned instead of the tapped one. Now it is the plain distance to the segment, within 1e-6° (~0.1 m).
The counterpart of js-sdk-core's polygon tiling, in the same shape: PolygonTilingOptions (2,000 polygons or 50,000 vertices), PolygonTiler (route / update / clear, onTemplate, POLYGON_TILE_LAYER_ID, polygonTileRasterLayerState) and PolygonTileSet (route on the local tile server, version in the URL, in-place changes drawn together after 16 ms). PolygonTileRenderer draws as tile-sw.js does: polygons in Web Mercator with the outline wound against the holes so a nonzero fill needs no hole union, a grid index of bounding boxes, a simplified copy per zoom (pixel grid, repeats dropped, Douglas-Peucker at half a pixel, a polygon under a pixel as one pixel), outlines only on polygons of 4 px or more. PNG through the Rust encoder. An in-place change drops only the cached tiles it overlaps; the rest come back from the cache under the new version. A tile the map abandons mid-draw fails rather than coming back empty. PolygonController gets a tiler: tiled polygons stay in PolygonManager for taps, against their original shapes, and the renderer never sees them. The bookkeeping for a city of polygons runs off the main thread. Also skip the quadratic hole union when no two holes cross, touch or nest (checked on a grid in linear time), still returning holes clockwise.
…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.
With exactly 2,000 parcels, the one that moved to native drawing left 1,999 tileable ones, so handing the same list back put them all on the native path (the add path's decision, as intended), and the test read that as a failure.
# Conflicts: # src/main/java/com/mapconductor/core/polygon/PolygonController.kt
…hread Same as TilePngEncoder: renderTile runs on Google's tile-overlay threads, which outlive their map, and a ThreadLocal<Bitmap> left a tile bitmap (native memory) on each of them. (cherry picked from commit 4c9ccdd2a655fcdd6a298227b10ccdf35bebcedd)
The disjoint check had a grid of its own (and ringBox, a copy of ringBounds). It now files the hole edges in the EdgeGrid the union uses, padded by MEET_PAD, the reach of intersectionPoints, and tests each edge only against the edges of other rings near it. The old grid padded by EPS, less than that reach, so it could miss a pair the union would have seen meet.
…Set.remove Also EdgeGrid and IntArrayList from the hole union (private classes, which the apiCheck dump lists as package-private, like Edge).
# Conflicts: # api/android-sdk-core.api
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.
何をするか
多数のポリゴン(既定: 2,000 個以上または頂点 50,000 以上)を、ネイティブの図形ではなくラスタータイルとして描きます(
PolygonTilingOptions/PolygonTiler)。web・Android・iOS で同じ設計です。このリポジトリで変えたこと
PolygonTilingOptions/PolygonTiler/PolygonTileSet/PolygonTileRenderer(タイル描画)。PolygonController.tilerでタイル側のポリゴンは PolygonManager に残し、ネイティブの図形は作りません。タイルにできなくなった変更が入ったらネイティブ描画へ移します。コントローラ破棄でタイルを解放します。holesAreDisjoint(穴が離れていれば結合を飛ばす近道)を、develop の穴の結合(穴の結合で、近くにある穴の面積を失わないようにし、速くする #33)のEdgeGridとringBounds/MEET_PADに乗せ換え、独自の格子を消しました。PolygonController.clear()/destroy()は develop の順番に、タイル側の片付けを加えました。develop の取り込み
このブランチは push 済みだったので、rebase せず
origin/developを merge commit で取り込みました。testDebugUnitTest: core 350 件ほか全部 pass(OMM は develop から引き継いだ 1 件の失敗のみ。android.util.Log.isLoggableがテストでモックされていない)。apiCheck: 全モジュール ok(増えた API はベースラインに追加)。マージの順番
この機能は複数のリポジトリにまたがります。android-sdk-core → android-sdk-compose(feat/polygons)→ 各 android-for- → android-sdk(親)* の順にマージが要ります。
この PR は大きな機能なので、マージするかはレビューのうえで判断してください。