Skip to content

Commit

Permalink
make altitude nullable and don't use 0 meters as a replacement for null
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Nov 15, 2021
1 parent 49eb2d3 commit 2b0243a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/commonMain/kotlin/com/jillesvangurp/geojson/geojson.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ fun BoundingBox.isValid(): Boolean {
return this.westLongitude <= this.eastLongitude && this.southLatitude <= this.northLatitude
}

fun PointCoordinates.ensureHasAltitude() =
if (this.size == 3) this else doubleArrayOf(this.longitude, this.latitude, 0.0)
// fun MultiPointCoordinates.ensureHasAltitude() =

val PointCoordinates.latitude: Double
get() = this[1]

Expand All @@ -93,8 +89,8 @@ val Degree.eastOrWest: CompassDirection get() = if (this >= 0) CompassDirection.
fun PointCoordinates.humanReadable(): String {
return """${latitude.degree}° ${latitude.minutes}' ${latitude.seconds}" ${latitude.northOrSouth.letter}, ${longitude.degree}° ${longitude.minutes}' ${longitude.seconds}" ${longitude.eastOrWest.letter}"""
}
val PointCoordinates.altitude: Double
get() = if (this.size == 3) this[2] else 0.0
val PointCoordinates.altitude: Double?
get() = if (this.size == 3) this[2] else null

val BoundingBox.southLatitude: Double
get() = this[1]
Expand Down

0 comments on commit 2b0243a

Please sign in to comment.