Repository navigation
Extend core PolygonController for polygons (drop hand-copied conductor) - #12
Merged
Merged
Conversation
MapplsPolygonConductor implemented SlottedOverlayController by hand because it drives two renderers (fill + a polyline per outline, since a fill layer cannot draw a stroke wider than 1 px). Every change to core's PolygonController had to be copied over, and it was missed twice. Replace it with MapplsPolygonController, which extends core's PolygonController, and MapplsPolygonCompositeRenderer, which presents the existing fill and outline renderers as one renderer. The fill renderer's onRemove now redraws without the removed polygons, since core's clear() does not call onPostProcess.
The conductor that develop's teardown change touched is gone here; its destroy() cleared the polygon and outline managers. Core's PolygonController now clears the polygon manager on destroy, and this controller clears the outline renderer's manager on top.
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.
なぜ
MapLibre / Mapbox / Mappls の fill レイヤーは幅のない 1 px の輪郭しか描けません。
strokeWidthを守るため、これら 3 プロバイダはポリゴンの外周を別のポリライン(outline-<id>)としてポリラインレンダラで描いています。コントローラが 2 つのレンダラを動かす必要があり、コアのPolygonControllerはレンダラを 1 つしか受け取らないので、MapplsPolygonConductorはSlottedOverlayControllerを自前で実装していました。その結果、コアの
PolygonControllerに入った変更はすべて手で写す必要があり、実際に 2 回漏れています。hasを写し忘れ、hasPolygonが常に false になってポリゴン単体の状態更新が黙って捨てられていたMapTiler はコアの
PolygonControllerを継承しており、これが本来の形です。何を変えたか
MapplsPolygonConductorを削除し、コアのPolygonControllerを継承するMapplsPolygonControllerに置き換えました。差分計算(指紋による変更なしのスキップを含む)、has/find、クリックカスケード(resolveTap/dispatchClick/setClickListenerAny)、update、clear、destroyはすべてコアの実装になります。zIndex = 2は従来の値を維持しています。MapplsPolygonCompositeRendererを追加しました。既存のMapplsPolygonOverlayRenderer(塗り)とMapplsPolylineOverlayRenderer(輪郭)を包み、コアには 1 つのレンダラとして見せます。onAdd/onChangeは塗りに渡したうえで、成功したポリゴンについて輪郭ポリラインを作り直します。onRemoveは輪郭を外し、両方のソースを描き直します。onPostProcessは両方を描き直します。輪郭のステート(外周を閉じたもの、idoutline-<id>、strokeColor/Width、geodesic、zIndex、extra)は従来と同じです。穴の輪郭を描かない点も同じです。MapplsPolygonOverlayRenderer.onRemoveは、消えたポリゴンを除いた残りを描くようにしました。コアのclear()はonPostProcessを呼ばず、onRemoveの後でエンティティを忘れます。従来の onRemove(スタイルが有ればマネージャ全体を遅延で描き直す)は描き直しのタイミング次第で消えたポリゴンを描いてしまうことがあり、clear の後に残る可能性がありました。getPolygonController、ViewController、スタイル設定)はpolygonController.renderer.fill/.renderer.outline/.polygonManagerを参照するように変えました。コアには変更を入れていません(android-sdk-core の PR はありません)。
細かな挙動差(意図したもの)
add()は毎回すべてのポリゴンを作り直していましたが、今後はコアと同じく指紋が変わらないポリゴンを描き直しません(描画結果は同じです)。createMapplsPolygonsが空)は輪郭も描きません。従来は輪郭だけが登録され、二度と消えないまま残っていました。検証
develop の各リポジトリ(core / compose / 他プロバイダ / example-app は origin/develop の worktree)に対して、3 プロバイダだけをこのブランチに差し替えた init script で
:example-appをビルドしました。MapplsMarkerController$Companion.getTILE_REFRESH_COALESCEの追加(この PR と無関係)で失敗しており、この行は .api に含めていません。それ以外の差分はありません。update経路)→ 2 A の頂点と穴を書き換え → 3 B を外す → 4 全部外す → 5 作り直すpolygon:A、A∩B →polygon:B(zIndex が上)、A の穴 → 地図クリック、C →polygon:C、外側 → 地図クリック、マーカー → マーカーのクリック。develop / このブランチとも 6 件すべて同じ結果でしたAPI 差分(
api/android-for-mappls.api)プロバイダ内部のクラスを置き換えたことによる差分です。
com.mapconductor.mappls.polygon.MapplsPolygonConductor(とメンバー無しのMapplsPolygonConductorKt)MapplsPolygonController(PolygonController<…>を継承。コンストラクタ引数はMapplsPolygonCompositeRenderer、getRenderer()/getZIndex())、MapplsPolygonCompositeRenderer(PolygonOverlayRendererInterface<…>を実装。getFill()/getOutline()/onAdd/onChange/onRemove/onPostProcess)、メンバー無しのMapplsPolygonCompositeRendererKtgetPolygonController(…)の戻り値と、MapplsViewControllerのコンストラクタの polygonController 引数の型がMapplsPolygonConductorからMapplsPolygonControllerに変わりました。いずれもプロバイダ内部の配線用で、アプリが直接使う API(
MapplsMapViewやPolygonState)には影響しません。