Skip to content

Commit

Permalink
get rid of all the remaining jvm tests and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Dec 18, 2023
1 parent b5a0d12 commit d48d061
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 92 deletions.
11 changes: 0 additions & 11 deletions build.gradle.kts
Expand Up @@ -64,17 +64,6 @@ kotlin {
dependencies {
runtimeOnly("org.junit.jupiter:junit-jupiter:_")
implementation(kotlin("test-junit"))

implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:_")
implementation("com.fasterxml.jackson.core:jackson-annotations:_")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:_")

// kotlintest runner needs this to enable logging
implementation("org.slf4j:slf4j-api:_")
implementation("org.slf4j:jcl-over-slf4j:_")
implementation("org.slf4j:log4j-over-slf4j:_")
implementation("org.slf4j:jul-to-slf4j:_")
implementation("ch.qos.logback:logback-classic:_")
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/com/jillesvangurp/geo/mgrs.kt
Expand Up @@ -195,9 +195,9 @@ fun MgrsCoordinate.toUtm(): UtmCoordinate {
// FIXME check if ups or utm, this implementation is for utm
val bandConstants = latitudeBandConstants[latitudeZoneLetter]!!

val utmEasting = eastingArray.withIndex().first { (i, letters) ->
val utmEasting = eastingArray.withIndex().first { (_, letters) ->
firstLetter in letters
}.let { (i, letters) ->
}.let { (i, _) ->
(i * HUNDRED_KM + easting).toDouble()
}

Expand Down
50 changes: 49 additions & 1 deletion src/commonTest/kotlin/com/jillesvangurp/geojson/GeojsonTest.kt
@@ -1,15 +1,19 @@
package com.jillesvangurp.geojson

import com.jillesvangurp.geo.GeoGeometry
import com.jillesvangurp.geo.GeoHashUtils
import com.jillesvangurp.geogeometry.bergstr16Berlin
import com.jillesvangurp.geogeometry.json
import io.kotest.matchers.collections.shouldContainInOrder
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.matchers.string.shouldInclude
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.cbor.Cbor
import kotlinx.serialization.json.Json
import kotlin.test.Test

internal class GeojsonKtTest {
class GeojsonKtTest {

@Test
fun shouldCalculateZoomLevel() {
Expand Down Expand Up @@ -75,4 +79,48 @@ internal class GeojsonKtTest {
println(decoded)
decoded shouldBe p
}

@Test
fun shouldCoverBerlinWithGeohashes() {
val berlin = json.decodeFromString(Geometry.serializer(), berlinGeoJson) as Geometry.MultiPolygon

val hashes = GeoHashUtils.geoHashesForMultiPolygon(
coordinates = berlin.coordinates ?: throw IllegalArgumentException("coordinates missing"),
includePartial = true,
maxLength = 6
)
FeatureCollection.fromGeoHashes(hashes)
val json = json.encodeToString(
FeatureCollection.serializer(),
//hashesCollection +
FeatureCollection(listOf(berlin.asFeature()))
)
// make sure we serialize these fields; they are required.
json shouldInclude """"type":"Feature""""
json shouldInclude """"type":"FeatureCollection""""
// you can copy paste this to geojson.io
println(
json
)
}

@Test
fun equalsTestForGeometry() {
val berlin = json.decodeFromString(Geometry.serializer(), berlinGeoJson) as Geometry.MultiPolygon

berlin.shouldBe(berlin)
berlin.shouldBe(berlin.copy())
berlin shouldNotBe berlin.copy(coordinates = null)
berlin.copy(coordinates = null) shouldNotBe berlin
val reversed = berlin.coordinates?.copyOf()
reversed?.reverse()
berlin.copy(coordinates = reversed) shouldNotBe berlin

Geometry.Point(null) shouldBe Geometry.Point(null)
Geometry.Point(doubleArrayOf(0.1, 0.1)) shouldNotBe Geometry.Point(null)
Geometry.Point(null) shouldNotBe Geometry.Point(doubleArrayOf(0.1, 0.1))
Geometry.Point(doubleArrayOf(0.1, 0.1)) shouldNotBe Geometry.Point(doubleArrayOf(0.9, 0.9))
Geometry.Point(doubleArrayOf(0.1, 0.1)) shouldBe Geometry.Point(doubleArrayOf(0.1, 0.1))
}

}
@@ -1,3 +1,6 @@
package com.jillesvangurp.geojson

val berlinGeoJson = """
{
"type": "MultiPolygon",
"coordinates": [
Expand Down Expand Up @@ -5872,4 +5875,4 @@
]
]
}

""".trimIndent()
70 changes: 0 additions & 70 deletions src/jvmTest/kotlin/com/jillesvangurp/geojson/GeoJsonJvmTest.kt

This file was deleted.

12 changes: 5 additions & 7 deletions versions.properties
Expand Up @@ -7,14 +7,8 @@
#### suppress inspection "SpellCheckingInspection" for whole file
#### suppress inspection "UnusedProperty" for whole file

version.ch.qos.logback..logback-classic=1.4.14

version.com.fasterxml.jackson.core..jackson-annotations=2.16.0

version.com.fasterxml.jackson.datatype..jackson-datatype-jsr310=2.16.0

version.com.fasterxml.jackson.module..jackson-module-kotlin=2.16.0

## unused
version.junit.jupiter=5.10.1

version.kotest=5.8.0
Expand All @@ -25,10 +19,14 @@ version.kotlin=1.9.21

version.kotlinx.serialization=1.6.2

## unused
version.org.slf4j..jcl-over-slf4j=2.0.9

## unused
version.org.slf4j..jul-to-slf4j=2.0.9

## unused
version.org.slf4j..log4j-over-slf4j=2.0.9

## unused
version.org.slf4j..slf4j-api=2.0.9

0 comments on commit d48d061

Please sign in to comment.