Skip to content

Commit 67469b3

Browse files
committed
[WIP] geotools integration
1 parent 558c217 commit 67469b3

File tree

21 files changed

+324
-130
lines changed

21 files changed

+324
-130
lines changed

build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ plugins {
55
id("space.kscience.gradle.project")
66
}
77

8-
val kmathVersion: String by extra("0.4.0")
9-
108
allprojects {
119
group = "space.kscience"
1210
version = "0.4.0-dev-7"

gradle/libs.versions.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[versions]
2+
3+
kmath = "0.4.2"
4+
geotools = "32.2"
5+
attributes = "0.3.0"
6+
7+
[libraries]
8+
9+
kmath-geometry = { module = "space.kscience:kmath-geometry", version.ref = "kmath" }
10+
gt-geotiff = { module = "org.geotools:gt-geotiff", version.ref = "geotools" }
11+
gt-shapefile = { module = "org.geotools:gt-shapefile", version.ref = "geotools" }
12+
gt-epsg-hsql = { module = "org.geotools:gt-epsg-hsql", version.ref = "geotools" }
13+
attributes-serialization = { module = "space.kscience:attributes-kt-serialization", version.ref = "attributes" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

maps-kt-compose/src/jvmMain/kotlin/space/kscience/maps/compose/mapExport.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ import space.kscience.maps.svg.generateSvg
1818
import java.nio.file.Path
1919
import kotlin.io.path.writeBytes
2020

21+
/**
22+
* Exports the features of a [FeatureSet] to an SVG file.
23+
*
24+
* @param viewPoint The `ViewPoint` providing the spatial context (focus and zoom level) for rendering the SVG.
25+
* @param painterCache A map associating `PainterFeature` instances with their respective `Painter` objects,
26+
* used for rendering the features in the SVG.
27+
* @param size The dimensions (`Size`) of the SVG file to generate.
28+
* @param path The file path where the generated SVG will be saved.
29+
*/
2130
public fun FeatureSet<Gmc>.exportToSvg(
2231
viewPoint: ViewPoint<Gmc>,
2332
painterCache: Map<PainterFeature<Gmc>, Painter>,
@@ -34,7 +43,6 @@ public fun FeatureSet<Gmc>.exportToSvg(
3443
}
3544

3645
public fun FeatureSet<Gmc>.exportToPng(
37-
mapTileProvider: MapTileProvider,
3846
viewPoint: ViewPoint<Gmc>,
3947
painterCache: Map<PainterFeature<Gmc>, Painter>,
4048
textMeasurer: TextMeasurer,

maps-kt-core/src/commonMain/kotlin/space/kscience/maps/coordinates/GmcCurve.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import space.kscience.kmath.geometry.*
44
import kotlin.math.*
55

66
/**
7-
* A directed straight (geodetic) segment on a spheroid with given start, direction, end point and distance.
7+
* A directed straight (geodetic) segment on a spheroid with the given start, direction, end point and distance.
88
* @param forward coordinate of a start point with the forward direction
99
* @param backward coordinate of an end point with the backward direction
1010
*/

maps-kt-features/build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ kscience {
3434
api(compose.foundation)
3535
api(compose.material)
3636
api(compose.ui)
37-
api("io.github.oshai:kotlin-logging:6.0.3")
37+
38+
api(libs.attributes.serialization)
39+
api("io.github.oshai:kotlin-logging:7.0.7")
3840
}
3941

4042
jvmMain{
41-
api("org.jfree:org.jfree.svg:5.0.4")
43+
api("org.jfree:org.jfree.svg:5.0.6")
4244
}
4345
}

maps-kt-features/src/commonMain/kotlin/space/kscience/maps/features/Feature.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import androidx.compose.ui.unit.DpSize
1919
import androidx.compose.ui.unit.dp
2020
import org.jetbrains.skia.Font
2121
import space.kscience.attributes.Attributes
22-
import space.kscience.attributes.NameAttribute
2322
import space.kscience.kmath.geometry.Angle
2423
import space.kscience.kmath.nd.Structure2D
2524

@@ -315,7 +314,7 @@ public data class VectorIconFeature<T : Any>(
315314
/**
316315
* An image that is bound to coordinates and is scaled (and possibly warped) together with them
317316
*
318-
* @param rectangle the size of background in scheme size units. The screen units to scheme units ratio equals scale.
317+
* @param rectangle the size of the image in scheme size units. The screen units to scheme units ratio equals scale.
319318
*/
320319
public data class ScalableImageFeature<T : Any>(
321320
override val space: CoordinateSpace<T>,

maps-kt-features/src/commonMain/kotlin/space/kscience/maps/features/drawFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public fun <T : Any> FeatureDrawScope<T>.drawFeature(
2828
val color = attributes[ColorAttribute] ?: Color.Red
2929
val alpha = attributes[AlphaAttribute] ?: 1f
3030
//avoid drawing invisible features
31-
if(attributes[VisibleAttribute] == false) return
31+
if (attributes[VisibleAttribute] == false) return
3232

3333
when (feature) {
3434
is FeatureSelector -> drawFeature(feature.selector(state.zoom), attributes)

maps-kt-features/src/commonMain/kotlin/space/kscience/maps/features/mapFeatureAttributes.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import androidx.compose.ui.graphics.Color
66
import androidx.compose.ui.graphics.PathEffect
77
import androidx.compose.ui.input.pointer.PointerEvent
88
import androidx.compose.ui.input.pointer.PointerKeyboardModifiers
9+
import kotlinx.serialization.builtins.serializer
910
import space.kscience.attributes.*
11+
import space.kscience.attributes.serialization.SerializableAttribute
12+
13+
public object NameAttribute : SerializableAttribute<String>("name", String.serializer())
1014

1115
public object ZAttribute : Attribute<Float>
1216

maps-kt-features/src/commonTest/kotlin/center/sciprog/attributes/AttributesSerializationTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import kotlinx.serialization.modules.contextual
99
import kotlinx.serialization.protobuf.ProtoBuf
1010
import kotlinx.serialization.serializer
1111
import space.kscience.attributes.Attributes
12-
import space.kscience.attributes.AttributesSerializer
13-
import space.kscience.attributes.NameAttribute
14-
import space.kscience.attributes.SerializableAttribute
12+
import space.kscience.attributes.serialization.AttributesSerializer
13+
import space.kscience.attributes.serialization.SerializableAttribute
14+
import space.kscience.maps.features.NameAttribute
15+
1516
import kotlin.test.Ignore
1617
import kotlin.test.Test
1718
import kotlin.test.assertEquals

0 commit comments

Comments
 (0)