package refactoring

This commit is contained in:
Alexander Nozik 2022-07-23 11:24:37 +03:00
parent cdee88573d
commit 2c87ba7638
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
23 changed files with 60 additions and 53 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<FeatureId, MapFeature> = emptyMap(),

View File

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

View File

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

View File

@ -0,0 +1,11 @@
package center.sciprog.maps.coordinates
/**
* A marker interface for flat coordinates
*/
public interface Coordinates2D
public interface CoordinateBox<T: Coordinates2D>{
public val a: T
public val b :T
}

View File

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

View File

@ -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<GeodeticMapCoordinates>
public fun GmcBox(
latitudes: ClosedFloatingPointRange<Double>,

View File

@ -1,4 +1,4 @@
package center.sciprog.maps
package center.sciprog.maps.coordinates
import kotlin.math.pow

View File

@ -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.*

View File

@ -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.*

View File

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

View File

@ -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<SchemeCoordinates>
val SchemeCoordinateBox.top get() = max(a.y, b.y)
val SchemeCoordinateBox.bottom get() = min(a.y, b.y)

View File

@ -1,4 +1,4 @@
package center.sciprog.scheme
package center.sciprog.maps.scheme
import kotlin.math.pow

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package center.sciprog.scheme
package center.sciprog.maps.scheme
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.drag

View File

Before

Width:  |  Height:  |  Size: 469 KiB

After

Width:  |  Height:  |  Size: 469 KiB

View File

@ -21,10 +21,10 @@ pluginManagement {
include(
":maps-kt-core",
":maps-kt-coordinates",
":maps-kt-compose",
":demo:maps",
":scheme-kt",
":maps-kt-scheme",
":demo:scheme"
)