From 82a1260e3f425a06d4c5ac5e920fe2b0978c6840 Mon Sep 17 00:00:00 2001 From: darksnake Date: Sat, 14 Jan 2023 20:09:58 +0300 Subject: [PATCH] Make elevation optional for Gmc --- build.gradle.kts | 2 +- .../center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt | 4 +++- .../kotlin/center/sciprog/maps/geojson/GeoJsonGeometry.kt | 4 ++-- .../kotlin/center/sciprog/maps/scheme/XYViewScope.kt | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9f1e43b..260de07 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { allprojects { group = "center.sciprog" - version = "0.2.1-dev-3" + version = "0.2.1-dev-4" } ksciencePublish{ diff --git a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt b/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt index 4de1689..5065188 100644 --- a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt +++ b/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt @@ -2,11 +2,13 @@ package center.sciprog.maps.coordinates /** * Geodetic coordinated + * + * @param elevation is optional */ public class GeodeticMapCoordinates( public val latitude: Angle, public val longitude: Angle, - public val elevation: Distance = 0.kilometers, + public val elevation: Distance? = null, ) { init { require(latitude in (-Angle.piDiv2)..(Angle.piDiv2)) { "Latitude $latitude is not in (-PI/2)..(PI/2)" } diff --git a/maps-kt-geojson/src/commonMain/kotlin/center/sciprog/maps/geojson/GeoJsonGeometry.kt b/maps-kt-geojson/src/commonMain/kotlin/center/sciprog/maps/geojson/GeoJsonGeometry.kt index e926f3a..75087e8 100644 --- a/maps-kt-geojson/src/commonMain/kotlin/center/sciprog/maps/geojson/GeoJsonGeometry.kt +++ b/maps-kt-geojson/src/commonMain/kotlin/center/sciprog/maps/geojson/GeoJsonGeometry.kt @@ -37,8 +37,8 @@ internal fun JsonElement.toGmc() = jsonArray.run { internal fun Gmc.toJsonArray(): JsonArray = buildJsonArray { add(longitude.degrees.value) add(latitude.degrees.value) - if (elevation.kilometers != 0.0) { - add(elevation.meters) + elevation?.let { + add(it.meters) } } diff --git a/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/XYViewScope.kt b/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/XYViewScope.kt index a1b0071..6454b8a 100644 --- a/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/XYViewScope.kt +++ b/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/XYViewScope.kt @@ -24,6 +24,7 @@ class XYViewScope( (canvasSize.width / 2 + (x.dp - viewPoint.focus.x.dp) * viewPoint.zoom), (canvasSize.height / 2 + (viewPoint.focus.y.dp - y.dp) * viewPoint.zoom) ) + override fun computeViewPoint(rectangle: Rectangle): ViewPoint { val scale = min( canvasSize.width.value / rectangle.width,