diff --git a/.gitignore b/.gitignore index c47b037e11..1a9924f264 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ .kotlin build .ipynb_checkpoints +local.properties diff --git a/build.gradle.kts b/build.gradle.kts index 2a8e5b572e..127298d7cf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -155,7 +155,7 @@ kotlin { val modulesUsingJava11 = with(projects) { setOf( dataframeJupyter, - dataframeGeo, + dataframeGeoJupyter, examples.ideaExamples.titanic, tests, plugins.dataframeGradlePlugin, diff --git a/dataframe-geo-jupyter/build.gradle.kts b/dataframe-geo-jupyter/build.gradle.kts new file mode 100644 index 0000000000..7880d10b43 --- /dev/null +++ b/dataframe-geo-jupyter/build.gradle.kts @@ -0,0 +1,59 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + with(libs.plugins) { + alias(kotlin.jvm) + alias(publisher) + alias(jupyter.api) + alias(ktlint) + alias(dataframe) + alias(ksp) + } +} + +group = "org.jetbrains.kotlinx" + +repositories { + // geo repository should come before Maven Central + maven("https://repo.osgeo.org/repository/release") + mavenCentral() + mavenLocal() +} + +// https://stackoverflow.com/questions/26993105/i-get-an-error-downloading-javax-media-jai-core1-1-3-from-maven-central +// jai core dependency should be excluded from geotools dependencies and added separately +fun ExternalModuleDependency.excludeJaiCore() = exclude("javax.media", "jai_core") + +dependencies { + implementation(projects.dataframeGeo) + implementation(projects.dataframeJupyter) + + implementation(libs.geotools.referencing) { excludeJaiCore() } + + // logger, need it for geotools + implementation(libs.log4j.core) + implementation(libs.log4j.api) + + testImplementation(kotlin("test")) +} + +tasks.withType().configureEach { + friendPaths.from(project(projects.core.path).projectDir) +} + +kotlinPublications { + publication { + publicationName = "dataframeGeoJupyter" + artifactId = project.name + description = "GeoDataFrame API" + packageName = artifactId + } +} + +tasks.processJupyterApiResources { + libraryProducers = listOf("org.jetbrains.kotlinx.dataframe.jupyter.IntegrationGeo") +} + +tasks.test { + useJUnitPlatform() +} diff --git a/dataframe-geo/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt b/dataframe-geo-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt similarity index 95% rename from dataframe-geo/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt rename to dataframe-geo-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt index 45e0c5bbec..4cab016e38 100644 --- a/dataframe-geo/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt +++ b/dataframe-geo-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/IntegrationGeo.kt @@ -54,6 +54,11 @@ internal class IntegrationGeo : JupyterIntegration() { useSchema() } + render> { + println("GeoDataFrame with ${it.crs?.name?.code} CRS and inner dataframe:") + it.df + } + val replCodeGeneratorImpl = ReplCodeGeneratorImpl() replCodeGeneratorImpl.process(WithGeometry::class) replCodeGeneratorImpl.process(WithPolygonGeometry::class) @@ -67,7 +72,7 @@ internal class IntegrationGeo : JupyterIntegration() { val generatedDf = execute( codeWithTypeCastGenerator = replCodeGeneratorImpl.process(geo.df, kProperty), expression = "(${kProperty.name}.df as DataFrame<*>)", - ) + ).let { "`$it`" } val name = execute("GeoDataFrame($generatedDf, ${kProperty.name}.crs)").name name } diff --git a/dataframe-geo/build.gradle.kts b/dataframe-geo/build.gradle.kts index c5c4b4c8d1..8af196d432 100644 --- a/dataframe-geo/build.gradle.kts +++ b/dataframe-geo/build.gradle.kts @@ -4,7 +4,6 @@ plugins { with(libs.plugins) { alias(kotlin.jvm) alias(publisher) - alias(jupyter.api) alias(ktlint) alias(dataframe) alias(ksp) @@ -14,7 +13,7 @@ plugins { group = "org.jetbrains.kotlinx" repositories { - // geo repository should come before Maven Central + // osgeo repository should come before Maven Central maven("https://repo.osgeo.org/repository/release") mavenCentral() mavenLocal() @@ -26,19 +25,22 @@ fun ExternalModuleDependency.excludeJaiCore() = exclude("javax.media", "jai_core dependencies { api(projects.core) - implementation(projects.dataframeJupyter) + // Geotools implementation(libs.geotools.main) { excludeJaiCore() } implementation(libs.geotools.shapefile) { excludeJaiCore() } implementation(libs.geotools.geojson) { excludeJaiCore() } implementation(libs.geotools.referencing) { excludeJaiCore() } implementation(libs.geotools.epsg.hsql) { excludeJaiCore() } + // JAI implementation(libs.jai.core) + // JTS implementation(libs.jts.core) implementation(libs.jts.io.common) + // Ktor implementation(libs.ktor.client.core) implementation(libs.ktor.client.cio) implementation(libs.ktor.client.content.negotiation) @@ -54,16 +56,12 @@ tasks.withType().configureEach { kotlinPublications { publication { publicationName = "dataframeGeo" - artifactId = "dataframe-geo" + artifactId = project.name description = "GeoDataFrame API" packageName = artifactId } } -tasks.processJupyterApiResources { - libraryProducers = listOf("org.jetbrains.kotlinx.dataframe.jupyter.IntegrationGeo") -} - tasks.test { useJUnitPlatform() } diff --git a/dataframe-jupyter/build.gradle.kts b/dataframe-jupyter/build.gradle.kts index afeecc3ade..82542c51cd 100644 --- a/dataframe-jupyter/build.gradle.kts +++ b/dataframe-jupyter/build.gradle.kts @@ -20,8 +20,13 @@ repositories { dependencies { api(projects.dataframe) + // logger, need it for apache poi + implementation(libs.log4j.core) + implementation(libs.log4j.api) + testImplementation(libs.junit) testImplementation(libs.serialization.json) + // experimental testImplementation(projects.dataframeOpenapiGenerator) testImplementation(projects.dataframeOpenapi) diff --git a/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt b/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt index 9b8a1ce916..16d1f8b390 100644 --- a/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt +++ b/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt @@ -68,8 +68,8 @@ internal class Integration(private val notebook: Notebook, private val options: // TODO temporary settings while these experimental modules are being developed private val enableExperimentalCsv = options["enableExperimentalCsv"] - private val enableExperimentalGeo = options["enableExperimentalGeo"] private val enableExperimentalOpenApi = options["enableExperimentalOpenApi"] + private val enableExperimentalGeo = options["enableExperimentalGeo"] private fun KotlinKernelHost.updateImportDataSchemaVariable( importDataSchema: ImportDataSchema, @@ -170,9 +170,7 @@ internal class Integration(private val notebook: Notebook, private val options: println("CSV module is already enabled by default now.") } if (enableExperimentalGeo?.toBoolean() == true) { - println("Enabling experimental Geo module: dataframe-geo") - repositories("https://repo.osgeo.org/repository/release") - dependencies("org.jetbrains.kotlinx:dataframe-geo:$version") + println("dataframe-geo module was extracted into separate descriptor: %use dataframe-geo") } if (enableExperimentalOpenApi?.toBoolean() == true) { println("Enabling experimental OpenAPI 3.0.0 module: dataframe-openapi") diff --git a/settings.gradle.kts b/settings.gradle.kts index 8476b955c9..704317504e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,6 +21,7 @@ include("dataframe-jdbc") include("dataframe-csv") include("dataframe-jupyter") include("dataframe-geo") +include("dataframe-geo-jupyter") include("dataframe-openapi-generator") include("core") include("dataframe-compiler-plugin-core")