Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import com.google.android.gms.maps.model.PolygonOptions
import com.mapconductor.core.ResourceProvider
import com.mapconductor.core.features.GeoPoint
import com.mapconductor.core.features.GeoPointInterface
import com.mapconductor.core.geometry.densifyPolygonRing
import com.mapconductor.core.polygon.AbstractPolygonOverlayRenderer
import com.mapconductor.core.polygon.PolygonEntityInterface
import com.mapconductor.core.polygon.PolygonState
import com.mapconductor.core.polygon.unionHoles
import com.mapconductor.core.spherical.Planar
import com.mapconductor.core.spherical.WGS84Geodesic
import com.mapconductor.googlemaps.AdaptiveInterpolation
import com.mapconductor.googlemaps.GoogleMapActualPolygon
import com.mapconductor.googlemaps.GoogleMapViewHolder
Expand Down Expand Up @@ -42,7 +41,9 @@ internal class GoogleMapPolygonOverlayRenderer(
val key = AdaptiveInterpolation.cacheKey(AdaptiveInterpolation.pointsHash(statePoints), maxSegmentLength)
interpolationCache.get(key)?.let { return it }

val geoPoints = WGS84Geodesic.createInterpolatePoints(statePoints, maxSegmentLength = maxSegmentLength)
// リングの閉じる辺(末尾 → 先頭)も大圏で補間する。隣り合う点の間だけを補間すると、閉じる辺が
// 直線の弦になり、塗りも輪郭(同じネイティブポリゴンの stroke)もそこだけ直線になる。
val geoPoints = densifyPolygonRing(statePoints, geodesic = true, maxSegmentLength = maxSegmentLength)
val points = geoPoints.map { GeoPoint.from(it).toLatLng() }
interpolationCache.put(key, points)
return points
Expand All @@ -54,7 +55,9 @@ internal class GoogleMapPolygonOverlayRenderer(
): List<LatLng> =
when (geodesic) {
true -> geodesicPoints(statePoints)
false -> Planar.createInterpolatePoints(statePoints).map { GeoPoint.from(it).toLatLng() }
// geodesic=false も閉じる辺を緯度経度で線形補間する(輪郭のポリラインと同じ線。補間しないと
// 閉じる辺だけメルカトルの直線になる)。
false -> densifyPolygonRing(statePoints, geodesic = false).map { GeoPoint.from(it).toLatLng() }
}

private fun toLatLngHoles(
Expand Down
Loading