Make elevation optional for Gmc

This commit is contained in:
Alexander Nozik 2023-01-14 20:09:58 +03:00
parent 9a7e086591
commit 82a1260e3f
4 changed files with 7 additions and 4 deletions

View File

@ -8,7 +8,7 @@ plugins {
allprojects {
group = "center.sciprog"
version = "0.2.1-dev-3"
version = "0.2.1-dev-4"
}
ksciencePublish{

View File

@ -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)" }

View File

@ -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)
}
}

View File

@ -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<XY>): ViewPoint<XY> {
val scale = min(
canvasSize.width.value / rectangle.width,