diff --git a/.gitignore b/.gitignore index 7925e19..8bb26b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ build/ .gradle/ .idea/ -*.iml +/*.iml mapCache/ \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index c689877..88c4647 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,58 +1,77 @@ -import org.jetbrains.compose.compose -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") - `maven-publish` -} - -group = "center.sciptog" -version = "1.0-SNAPSHOT" - -repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + base } val ktorVersion by extra("2.0.3") -kotlin { - jvm { - compilations.all { - kotlinOptions.jvmTarget = "11" - } - withJava() +subprojects { + group = "center.sciprog" + version = "0.1.0-SNAPSHOT" + + repositories { + google() + mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } - sourceSets { - commonMain{ - dependencies{ - api(compose.runtime) - api(compose.foundation) - api(compose.material) - api("io.ktor:ktor-client-core:$ktorVersion") - implementation("io.ktor:ktor-client-cio:$ktorVersion") - implementation("io.github.microutils:kotlin-logging:2.1.23") + + plugins.withId("maven-publish") { + + configure { + val vcs = "https://github.com/mipt-npm/maps-kt" + + // Process each publication we have in this project + publications { + withType { + pom { + name.set(project.name) + description.set(project.description) + url.set(vcs) + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("SPC") + name.set("Scientific programming centre") + organization.set("MIPT") + organizationUrl.set("https://sciprog.center/") + } + } + + scm { + url.set(vcs) + tag.set(project.version.toString()) + } + } + } + } + + val spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven" + val spaceUser: String? = project.findProperty("publishing.space.user") as? String + val spaceToken: String? = project.findProperty("publishing.space.token") as? String + + if (spaceUser != null && spaceToken != null) { + project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]") + + repositories.maven { + name = "space" + url = uri(spaceRepo) + + credentials { + username = spaceUser + password = spaceToken + } + } } } - val jvmMain by getting { - dependencies { - implementation(compose.desktop.currentOs) - implementation("ch.qos.logback:logback-classic:1.2.11") - } - } - val jvmTest by getting } } -compose.desktop { - application { - mainClass = "MainKt" - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "maps-kt-compose" - packageVersion = "1.0.0" - } - } -} + + diff --git a/demo/build.gradle.kts b/demo/build.gradle.kts new file mode 100644 index 0000000..b6738fd --- /dev/null +++ b/demo/build.gradle.kts @@ -0,0 +1,40 @@ +import org.jetbrains.compose.compose +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + kotlin("multiplatform") + id("org.jetbrains.compose") +} + +val ktorVersion: String by rootProject.extra + +kotlin { + jvm { + compilations.all { + kotlinOptions.jvmTarget = "11" + } + withJava() + } + sourceSets { + val jvmMain by getting { + dependencies { + implementation(projects.mapsKtCompose) + implementation(compose.desktop.currentOs) + implementation("io.ktor:ktor-client-cio:$ktorVersion") + implementation("ch.qos.logback:logback-classic:1.2.11") + } + } + val jvmTest by getting + } +} + +compose.desktop { + application { + mainClass = "MainKt" + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "maps-kt-compose" + packageVersion = "1.0.0" + } + } +} diff --git a/src/jvmMain/kotlin/Main.kt b/demo/src/jvmMain/kotlin/Main.kt similarity index 100% rename from src/jvmMain/kotlin/Main.kt rename to demo/src/jvmMain/kotlin/Main.kt diff --git a/gradle.properties b/gradle.properties index 9498324..0802053 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ kotlin.code.style=official kotlin.version=1.6.10 +compose.version=1.1.1 agp.version=4.2.2 -compose.version=1.1.1 \ No newline at end of file +android.useAndroidX=true diff --git a/maps-kt-compose/build.gradle.kts b/maps-kt-compose/build.gradle.kts new file mode 100644 index 0000000..1ec386f --- /dev/null +++ b/maps-kt-compose/build.gradle.kts @@ -0,0 +1,29 @@ +import org.jetbrains.compose.compose +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + kotlin("multiplatform") + id("org.jetbrains.compose") + `maven-publish` +} + +val ktorVersion: String by rootProject.extra + +kotlin { + jvm { + compilations.all { + kotlinOptions.jvmTarget = "11" + } + } + sourceSets { + commonMain{ + dependencies{ + api(projects.mapsKtCore) + api(compose.foundation) + api("io.ktor:ktor-client-core:$ktorVersion") + } + } + val jvmMain by getting + val jvmTest by getting + } +} \ No newline at end of file diff --git a/src/commonMain/kotlin/centre/sciprog/maps/compose/FeatureBuilder.kt b/maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/FeatureBuilder.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/compose/FeatureBuilder.kt rename to maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/FeatureBuilder.kt diff --git a/src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt b/maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt rename to maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt diff --git a/src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt b/maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt rename to maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt diff --git a/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt b/maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt rename to maps-kt-compose/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/LruCache.kt b/maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/LruCache.kt similarity index 100% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/LruCache.kt rename to maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/LruCache.kt diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt b/maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt similarity index 96% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt rename to maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt index 9403e85..f7be32c 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt +++ b/maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt @@ -31,6 +31,17 @@ 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 = GeodeticMapCoordinates.ofRadians( + (focus.latitude + deltaY / scaleFactor).coerceIn( + -MercatorProjection.MAXIMUM_LATITUDE, + MercatorProjection.MAXIMUM_LATITUDE + ), + focus.longitude + deltaX / scaleFactor + ) + return MapViewPoint(newCoordinates, zoom) +} + private val logger = KotlinLogging.logger("MapView") /** diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/OpenStreetMapTileProvider.kt b/maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/OpenStreetMapTileProvider.kt similarity index 100% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/OpenStreetMapTileProvider.kt rename to maps-kt-compose/src/jvmMain/kotlin/centre/sciprog/maps/compose/OpenStreetMapTileProvider.kt diff --git a/maps-kt-core/build.gradle.kts b/maps-kt-core/build.gradle.kts new file mode 100644 index 0000000..7d20ce4 --- /dev/null +++ b/maps-kt-core/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + kotlin("multiplatform") + `maven-publish` +} + +val ktorVersion: String by rootProject.extra + +kotlin { + jvm { + compilations.all { + kotlinOptions.jvmTarget = "11" + } + } + 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/src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt rename to maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt diff --git a/src/commonMain/kotlin/centre/sciprog/maps/GmcBox.kt b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/GmcBox.kt similarity index 84% rename from src/commonMain/kotlin/centre/sciprog/maps/GmcBox.kt rename to maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/GmcBox.kt index c44c9e9..f4c4065 100644 --- a/src/commonMain/kotlin/centre/sciprog/maps/GmcBox.kt +++ b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/GmcBox.kt @@ -1,14 +1,12 @@ package centre.sciprog.maps -import androidx.compose.ui.unit.DpSize -import centre.sciprog.maps.compose.MapFeature import kotlin.math.* class GmcBox(val a: GeodeticMapCoordinates, val b: GeodeticMapCoordinates) fun GmcBox(latitudes: ClosedFloatingPointRange, longitudes: ClosedFloatingPointRange) = GmcBox( - Gmc.ofRadians(latitudes.start, longitudes.start), - Gmc.ofRadians(latitudes.endInclusive, longitudes.endInclusive) + GeodeticMapCoordinates.ofRadians(latitudes.start, longitudes.start), + GeodeticMapCoordinates.ofRadians(latitudes.endInclusive, longitudes.endInclusive) ) val GmcBox.center diff --git a/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt similarity index 73% rename from src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt rename to maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt index 1b27e2d..9579a81 100644 --- a/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt +++ b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt @@ -1,7 +1,6 @@ package centre.sciprog.maps import kotlin.math.pow -import kotlin.math.roundToInt /** * Observable position on the map. Includes observation coordinate and [zoom] factor @@ -13,20 +12,6 @@ data class MapViewPoint( val scaleFactor by lazy { WebMercatorProjection.scaleFactor(zoom) } } -/** - * - */ -internal fun MapViewPoint.move(deltaX: Double, deltaY: Double): MapViewPoint { - val newCoordinates = GeodeticMapCoordinates.ofRadians( - (focus.latitude + deltaY / scaleFactor).coerceIn( - -MercatorProjection.MAXIMUM_LATITUDE, - MercatorProjection.MAXIMUM_LATITUDE - ), - focus.longitude + deltaX / scaleFactor - ) - return MapViewPoint(newCoordinates, zoom) -} - fun MapViewPoint.move(delta: GeodeticMapCoordinates): MapViewPoint { val newCoordinates = GeodeticMapCoordinates.ofRadians( (focus.latitude + delta.latitude).coerceIn( diff --git a/src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt rename to maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt diff --git a/src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt b/maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt similarity index 100% rename from src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt rename to maps-kt-core/src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 374b7cd..18fc3d1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,7 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +rootProject.name = "maps-kt" + +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + pluginManagement { repositories { google() @@ -9,9 +12,17 @@ pluginManagement { plugins { kotlin("multiplatform").version(extra["kotlin.version"] as String) + kotlin("android").version(extra["kotlin.version"] as String) + id("com.android.application").version(extra["agp.version"] as String) + id("com.android.library").version(extra["agp.version"] as String) id("org.jetbrains.compose").version(extra["compose.version"] as String) } } -rootProject.name = "maps-kt" + +include( + ":maps-kt-core", + ":maps-kt-compose", + ":demo" +)