diff --git a/src/main/java/com/mapconductor/googlemaps/polygon/GoogleMapPolygonOverlayRenderer.kt b/src/main/java/com/mapconductor/googlemaps/polygon/GoogleMapPolygonOverlayRenderer.kt index d579143..c7bedf5 100644 --- a/src/main/java/com/mapconductor/googlemaps/polygon/GoogleMapPolygonOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/googlemaps/polygon/GoogleMapPolygonOverlayRenderer.kt @@ -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 @@ -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 @@ -54,7 +55,9 @@ internal class GoogleMapPolygonOverlayRenderer( ): List = 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(