Skip to content

Geo update #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ import org.jetbrains.kotlinx.dataframe.api.with
* @property crs The coordinate reference system associated with the data, if any.
*/
class GeoDataFrame<T : WithGeometry>(val df: DataFrame<T>, val crs: CoordinateReferenceSystem?) {

/**
* Creates a new `GeoDataFrame` with the modified underlying DataFrame.
* Creates a new [GeoDataFrame] by applying transformations to the underlying [DataFrame].
*
* This function opens a modification scope where the current [DataFrame] can be transformed using
* [Kotlin DataFrame operations](https://kotlin.github.io/dataframe/operations.html). The transformation block
* receives the original [DataFrame] both as a receiver and as an explicit argument, allowing flexible modifications.
*
* The Coordinate Reference System (CRS) remains unchanged.
*
* @param block The block defining the transformations to be applied to the DataFrame.
* @return A new `GeoDataFrame` instance with updated dataframe and the same CRS.
* @param block A lambda defining the transformations to apply to the DataFrame.
* @return A new [GeoDataFrame] instance with the modified DataFrame while preserving the original CRS.
*/
inline fun modify(block: DataFrame<T>.() -> DataFrame<T>): GeoDataFrame<T> = GeoDataFrame(df.block(), crs)
inline fun modify(block: DataFrame<T>.(DataFrame<T>) -> DataFrame<T>): GeoDataFrame<T> =
GeoDataFrame(df.block(df), crs)

/**
* Transforms the geometries to a specified Coordinate Reference System (CRS).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ internal class IntegrationGeo : JupyterIntegration() {
import("org.jetbrains.kotlinx.dataframe.geo.geotools.*")
import("org.jetbrains.kotlinx.dataframe.geo.geocode.*")
import("org.geotools.referencing.CRS")
import("org.locationtech.jts.geom.*")

import("org.locationtech.jts.geom.Geometry")
import("org.locationtech.jts.geom.Point")
import("org.locationtech.jts.geom.MultiPoint")
import("org.locationtech.jts.geom.LineString")
import("org.locationtech.jts.geom.MultiLineString")
import("org.locationtech.jts.geom.Polygon")
import("org.locationtech.jts.geom.MultiPolygon")
import("org.locationtech.jts.geom.Envelope")

onLoaded {
useSchema<WithGeometry>()
useSchema<WithPolygonGeometry>()
Expand All @@ -44,6 +53,7 @@ internal class IntegrationGeo : JupyterIntegration() {
useSchema<WithLineStringGeometry>()
useSchema<WithMultiLineStringGeometry>()
}

val replCodeGeneratorImpl = ReplCodeGeneratorImpl()
replCodeGeneratorImpl.process(WithGeometry::class)
replCodeGeneratorImpl.process(WithPolygonGeometry::class)
Expand Down
Loading