diff --git a/demo/maps/src/jvmMain/kotlin/Main.kt b/demo/maps/src/jvmMain/kotlin/Main.kt index 2c7ce6e..c32de21 100644 --- a/demo/maps/src/jvmMain/kotlin/Main.kt +++ b/demo/maps/src/jvmMain/kotlin/Main.kt @@ -10,8 +10,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.window.Window import androidx.compose.ui.window.application import center.sciprog.maps.compose.* -import center.sciprog.maps.GeodeticMapCoordinates -import center.sciprog.maps.MapViewPoint +import center.sciprog.maps.coordinates.GeodeticMapCoordinates +import center.sciprog.maps.coordinates.MapViewPoint import io.ktor.client.HttpClient import io.ktor.client.engine.cio.CIO import kotlinx.coroutines.delay diff --git a/demo/scheme/build.gradle.kts b/demo/scheme/build.gradle.kts index 0222e52..2e64e6d 100644 --- a/demo/scheme/build.gradle.kts +++ b/demo/scheme/build.gradle.kts @@ -18,7 +18,7 @@ kotlin { sourceSets { val jvmMain by getting { dependencies { - implementation(projects.schemeKt) + implementation(projects.mapsKtScheme) implementation(compose.desktop.currentOs) implementation("ch.qos.logback:logback-classic:1.2.11") } diff --git a/demo/scheme/src/jvmMain/kotlin/Main.kt b/demo/scheme/src/jvmMain/kotlin/Main.kt index 98757de..8803fea 100644 --- a/demo/scheme/src/jvmMain/kotlin/Main.kt +++ b/demo/scheme/src/jvmMain/kotlin/Main.kt @@ -7,7 +7,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.window.Window import androidx.compose.ui.window.application -import center.sciprog.scheme.* +import center.sciprog.maps.scheme.* @Composable @Preview diff --git a/maps-kt-compose/build.gradle.kts b/maps-kt-compose/build.gradle.kts index 1ec386f..ff95d07 100644 --- a/maps-kt-compose/build.gradle.kts +++ b/maps-kt-compose/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.compose.compose -import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { kotlin("multiplatform") @@ -10,17 +9,19 @@ plugins { val ktorVersion: String by rootProject.extra kotlin { + explicitApi = org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Warning jvm { compilations.all { kotlinOptions.jvmTarget = "11" } } sourceSets { - commonMain{ - dependencies{ - api(projects.mapsKtCore) + commonMain { + dependencies { + api(projects.mapsKtCoordinates) api(compose.foundation) api("io.ktor:ktor-client-core:$ktorVersion") + api("io.github.microutils:kotlin-logging:2.1.23") } } val jvmMain by getting diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/FeatureBuilder.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/FeatureBuilder.kt index 75df7ee..21920e4 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/FeatureBuilder.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/FeatureBuilder.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp -import center.sciprog.maps.GeodeticMapCoordinates +import center.sciprog.maps.coordinates.GeodeticMapCoordinates typealias FeatureId = String diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt index d80ac3d..76a4396 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapFeature.kt @@ -1,8 +1,6 @@ package center.sciprog.maps.compose import androidx.compose.runtime.Composable -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.drawscope.DrawScope @@ -12,9 +10,9 @@ import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp -import center.sciprog.maps.GeodeticMapCoordinates -import center.sciprog.maps.GmcBox -import center.sciprog.maps.wrapAll +import center.sciprog.maps.coordinates.GeodeticMapCoordinates +import center.sciprog.maps.coordinates.GmcBox +import center.sciprog.maps.coordinates.wrapAll //TODO replace zoom range with zoom-based representation change sealed class MapFeature(val zoomRange: IntRange) { diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt index 1f1019e..7907875 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt @@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.DpSize -import center.sciprog.maps.* +import center.sciprog.maps.coordinates.* import kotlin.math.PI import kotlin.math.log2 import kotlin.math.min @@ -60,7 +60,7 @@ internal fun GmcBox.computeViewPoint(mapTileProvider: MapTileProvider): (canvasS } @Composable -fun MapView( +public fun MapView( mapTileProvider: MapTileProvider, box: GmcBox, features: Map = emptyMap(), diff --git a/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt b/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt index 5fb3bb6..d3e41e7 100644 --- a/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt +++ b/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt @@ -16,7 +16,7 @@ import androidx.compose.ui.graphics.nativeCanvas import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.input.pointer.* import androidx.compose.ui.unit.* -import center.sciprog.maps.* +import center.sciprog.maps.coordinates.* import kotlinx.coroutines.CancellationException import kotlinx.coroutines.launch import mu.KotlinLogging @@ -33,7 +33,7 @@ private fun Color.toPaint(): Paint = Paint().apply { private fun IntRange.intersect(other: IntRange) = max(first, other.first)..min(last, other.last) internal fun MapViewPoint.move(deltaX: Double, deltaY: Double): MapViewPoint { - val newCoordinates = center.sciprog.maps.GeodeticMapCoordinates.ofRadians( + val newCoordinates = center.sciprog.maps.coordinates.GeodeticMapCoordinates.ofRadians( (focus.latitude + deltaY / scaleFactor).coerceIn( -MercatorProjection.MAXIMUM_LATITUDE, MercatorProjection.MAXIMUM_LATITUDE diff --git a/maps-kt-core/build.gradle.kts b/maps-kt-coordinates/build.gradle.kts similarity index 59% rename from maps-kt-core/build.gradle.kts rename to maps-kt-coordinates/build.gradle.kts index ce2a413..5ca05d2 100644 --- a/maps-kt-core/build.gradle.kts +++ b/maps-kt-coordinates/build.gradle.kts @@ -15,13 +15,4 @@ kotlin { js(IR) { browser() } - sourceSets { - commonMain { - dependencies { - api("io.github.microutils:kotlin-logging:2.1.23") - } - } - val jvmMain by getting - val jvmTest by getting - } } \ No newline at end of file diff --git a/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/Coordinates2D.kt b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/Coordinates2D.kt new file mode 100644 index 0000000..4466edd --- /dev/null +++ b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/Coordinates2D.kt @@ -0,0 +1,11 @@ +package center.sciprog.maps.coordinates + +/** + * A marker interface for flat coordinates + */ +public interface Coordinates2D + +public interface CoordinateBox{ + public val a: T + public val b :T +} \ No newline at end of file diff --git a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/GeodeticMapCoordinates.kt b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt similarity index 90% rename from maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/GeodeticMapCoordinates.kt rename to maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt index bd8152b..0ce9a71 100644 --- a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/GeodeticMapCoordinates.kt +++ b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/GeodeticMapCoordinates.kt @@ -1,11 +1,14 @@ -package center.sciprog.maps +package center.sciprog.maps.coordinates import kotlin.math.PI /** * Geodetic coordinated */ -public class GeodeticMapCoordinates private constructor(public val latitude: Double, public val longitude: Double) { +public class GeodeticMapCoordinates private constructor( + public val latitude: Double, + public val longitude: Double, +): Coordinates2D { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -43,9 +46,6 @@ public class GeodeticMapCoordinates private constructor(public val latitude: Dou } } -internal typealias Gmc = GeodeticMapCoordinates - - //public interface GeoToScreenConversion { // public fun getScreenX(gmc: GeodeticMapCoordinates): Double // public fun getScreenY(gmc: GeodeticMapCoordinates): Double diff --git a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/GmcBox.kt b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/GmcBox.kt similarity index 87% rename from maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/GmcBox.kt rename to maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/GmcBox.kt index 5b5297b..aef5db5 100644 --- a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/GmcBox.kt +++ b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/GmcBox.kt @@ -1,10 +1,13 @@ -package center.sciprog.maps +package center.sciprog.maps.coordinates import kotlin.math.abs import kotlin.math.max import kotlin.math.min -public class GmcBox(public val a: GeodeticMapCoordinates, public val b: GeodeticMapCoordinates) +public data class GmcBox( + public override val a: GeodeticMapCoordinates, + public override val b: GeodeticMapCoordinates, +) : CoordinateBox public fun GmcBox( latitudes: ClosedFloatingPointRange, diff --git a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/MapViewPoint.kt b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/MapViewPoint.kt similarity index 96% rename from maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/MapViewPoint.kt rename to maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/MapViewPoint.kt index 43a6836..022338f 100644 --- a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/MapViewPoint.kt +++ b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/MapViewPoint.kt @@ -1,4 +1,4 @@ -package center.sciprog.maps +package center.sciprog.maps.coordinates import kotlin.math.pow diff --git a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/MercatorProjection.kt b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/MercatorProjection.kt similarity index 97% rename from maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/MercatorProjection.kt rename to maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/MercatorProjection.kt index 3155480..d018993 100644 --- a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/MercatorProjection.kt +++ b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/MercatorProjection.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package center.sciprog.maps +package center.sciprog.maps.coordinates import kotlin.math.* diff --git a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/WebMercatorProjection.kt b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/WebMercatorProjection.kt similarity index 98% rename from maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/WebMercatorProjection.kt rename to maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/WebMercatorProjection.kt index 952e7da..4273080 100644 --- a/maps-kt-core/src/commonMain/kotlin/center/sciprog/maps/WebMercatorProjection.kt +++ b/maps-kt-coordinates/src/commonMain/kotlin/center/sciprog/maps/coordinates/WebMercatorProjection.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package center.sciprog.maps +package center.sciprog.maps.coordinates import kotlin.math.* diff --git a/scheme-kt/build.gradle.kts b/maps-kt-scheme/build.gradle.kts similarity index 91% rename from scheme-kt/build.gradle.kts rename to maps-kt-scheme/build.gradle.kts index 285b7ab..bbeeec0 100644 --- a/scheme-kt/build.gradle.kts +++ b/maps-kt-scheme/build.gradle.kts @@ -1,6 +1,5 @@ import org.jetbrains.compose.compose import org.jetbrains.compose.desktop.application.dsl.TargetFormat -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("multiplatform") @@ -24,8 +23,9 @@ kotlin { withJava() } sourceSets { - commonMain{ - dependencies{ + commonMain { + dependencies { + api(projects.mapsKtCoordinates) api("io.github.microutils:kotlin-logging:2.1.23") api(compose.foundation) } diff --git a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeCoordinates.kt b/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/SchemeCoordinates.kt similarity index 69% rename from scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeCoordinates.kt rename to maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/SchemeCoordinates.kt index 122cdeb..652ab63 100644 --- a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeCoordinates.kt +++ b/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/SchemeCoordinates.kt @@ -1,12 +1,17 @@ -package center.sciprog.scheme +package center.sciprog.maps.scheme +import center.sciprog.maps.coordinates.CoordinateBox +import center.sciprog.maps.coordinates.Coordinates2D import kotlin.math.abs import kotlin.math.max import kotlin.math.min -data class SchemeCoordinates(val x: Float, val y: Float) +data class SchemeCoordinates(val x: Float, val y: Float) : Coordinates2D -data class SchemeCoordinateBox(val a: SchemeCoordinates, val b: SchemeCoordinates) +data class SchemeCoordinateBox( + override val a: SchemeCoordinates, + override val b: SchemeCoordinates, +) : CoordinateBox val SchemeCoordinateBox.top get() = max(a.y, b.y) val SchemeCoordinateBox.bottom get() = min(a.y, b.y) diff --git a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeViewPoint.kt b/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/SchemeViewPoint.kt similarity index 95% rename from scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeViewPoint.kt rename to maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/SchemeViewPoint.kt index 4e60dee..b57926d 100644 --- a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeViewPoint.kt +++ b/maps-kt-scheme/src/commonMain/kotlin/center/sciprog/maps/scheme/SchemeViewPoint.kt @@ -1,4 +1,4 @@ -package center.sciprog.scheme +package center.sciprog.maps.scheme import kotlin.math.pow diff --git a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/FeatureBuilder.kt b/maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/FeatureBuilder.kt similarity index 97% rename from scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/FeatureBuilder.kt rename to maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/FeatureBuilder.kt index b7d85dd..0f08595 100644 --- a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/FeatureBuilder.kt +++ b/maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/FeatureBuilder.kt @@ -1,4 +1,4 @@ -package center.sciprog.scheme +package center.sciprog.maps.scheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateMapOf @@ -10,7 +10,7 @@ import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp -import center.sciprog.scheme.SchemeFeature.Companion.defaultScaleRange +import center.sciprog.maps.scheme.SchemeFeature.Companion.defaultScaleRange typealias FeatureId = String diff --git a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeFeature.kt b/maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/SchemeFeature.kt similarity index 95% rename from scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeFeature.kt rename to maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/SchemeFeature.kt index 475bdf2..8362531 100644 --- a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeFeature.kt +++ b/maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/SchemeFeature.kt @@ -1,4 +1,4 @@ -package center.sciprog.scheme +package center.sciprog.maps.scheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color @@ -10,7 +10,7 @@ import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp -import center.sciprog.scheme.SchemeFeature.Companion.defaultScaleRange +import center.sciprog.maps.scheme.SchemeFeature.Companion.defaultScaleRange internal typealias FloatRange = ClosedFloatingPointRange @@ -19,8 +19,6 @@ sealed class SchemeFeature(val scaleRange: FloatRange) { companion object { val defaultScaleRange = 0f..Float.MAX_VALUE - const val DEFAULT_RENDERING_ORDER = 0 - const val BACKGROUND_RENDERING_ORDER = 1000 } } diff --git a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeView.kt b/maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/SchemeView.kt similarity index 99% rename from scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeView.kt rename to maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/SchemeView.kt index 25ce1c8..a05f56a 100644 --- a/scheme-kt/src/jvmMain/kotlin/center/sciprog/scheme/SchemeView.kt +++ b/maps-kt-scheme/src/jvmMain/kotlin/center/sciprog/maps/scheme/SchemeView.kt @@ -1,4 +1,4 @@ -package center.sciprog.scheme +package center.sciprog.maps.scheme import androidx.compose.foundation.Canvas import androidx.compose.foundation.gestures.drag diff --git a/scheme-kt/src/jvmMain/resources/middle-earth.jpg b/maps-kt-scheme/src/jvmMain/resources/middle-earth.jpg similarity index 100% rename from scheme-kt/src/jvmMain/resources/middle-earth.jpg rename to maps-kt-scheme/src/jvmMain/resources/middle-earth.jpg diff --git a/settings.gradle.kts b/settings.gradle.kts index a321853..e81ffc7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,10 +21,10 @@ pluginManagement { include( - ":maps-kt-core", + ":maps-kt-coordinates", ":maps-kt-compose", ":demo:maps", - ":scheme-kt", + ":maps-kt-scheme", ":demo:scheme" )