Skip to content

Conversation

@AndreiKingsley
Copy link
Collaborator

No description provided.

import org.jetbrains.kotlinx.kandy.ir.data.TableData
import org.jetbrains.letsPlot.spatial.SpatialDataset

public interface GeoSpatialData: TableData {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, generate and fill KDocs

import org.locationtech.jts.geom.MultiPolygon
import org.locationtech.jts.operation.union.CascadedPolygonUnion


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line and add some KDocs, great that exception is raised? Could we throw IllegalArgumentException in other situation which I commented?

) {
geometry().forEach {
if (it !is Polygonal) {
error("Not a polygon geometry: $it")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it somewhere IllegalArgumentException, somewhere error? could it be unified through the PR?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also KDocs required

import org.locationtech.jts.geom.Puntal
import kotlin.reflect.typeOf

// TODO add ColumnAccessor & String api
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add KDocs

import org.jetbrains.kotlinx.kandy.dsl.internal.LayerCreatorScope
import org.jetbrains.kotlinx.kandy.dsl.internal.MultiLayerPlotBuilder

public class GeoDataFrameScope<T : WithGeometry>(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDocs please

override fun toSpatialDataset(): SpatialDataset {
with(geoDataFrame) {
// TODO encoding precision
val geojson = GeometryJSON(10)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic Constant - should be extracted and explained

with(geoDataFrame) {
// TODO encoding precision
val geojson = GeometryJSON(10)
return SpatialDataset.withGEOJSON(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to rename to withGeoJson to be more Kotlinish?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not our API

val friendModules = listOf(project(":kandy-api"), project(":kandy-lets-plot"))
val jarTasks = friendModules.map { it.tasks.getByName("jar") as Jar }
val jarPaths = jarTasks.map { it.archiveFile.get().asFile.absolutePath }
(this as BaseKotlinCompile).friendPaths.from(jarPaths)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could please add some note or explanation about why do we need friend modules here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreiKingsley
add a comment with motivation "what's happened here? and why we did this?"

in this tasks.withType snippet

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did

// jai core dependency should be excluded from geotools dependencies and added separately
fun ExternalModuleDependency.excludeJaiCore() = exclude("javax.media", "jai_core")


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank lines

Copy link

@zaleslaw zaleslaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It requires more work on KDocs and some questions should be answered also

*
* This interface extends the `TableData` interface, providing specific capabilities for handling geospatial data.
*
* @property dataFrame The data frame containing the geospatial data.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DataFrame (to refer on class), don't use data frame

if (crs == null || crs.isWGS84() == true) {
(this as LayerCreatorScope).plotBuilder.coordinatesTransformation = CoordinatesTransformation.mercator()
} else {
//TODO handling other CRS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a ticket and describe a list of "other CRS" - could be an umbrella ticket

val geometryColumn = geometry named "geometry"
val geoDataFrame = if (columnRowsCount != datasetBuilderRowsCount) {
// override dataset if datasetBuilder size doesn't match
dataFrameOf(geometryColumn).toGeo(null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this code dataFrameOf(geometryColumn).toGeo(null)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new dataframe with single column and casting to GeoDataFrame (witn null crs)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite in Kotlin style. You can define a copy method with changing parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link

@zaleslaw zaleslaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some moments a little bit unclear, please clarify them

Copy link
Collaborator

@devcrocod devcrocod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments
Unfortunately, I don't have the opportunity to look more closely later, but overall I approved this

val rowsCount = group.rowsCount()
val keyColumns = keyNames.filter { it !in group.columnNames() }.map { keyName ->
DataColumn.create(keyName, List(rowsCount) { key[keyName] }, Infer.Type)
DataColumn.Companion.createByType(keyName, List(rowsCount) { key[keyName] }, Infer.Type)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why specify Companion?


companion object {
// TODO lets-plot default, encoding precision customization
const val DEFAULT_PRECISION = 10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to change this?
Why is it in a companion object and a constant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's temporary, will design better way to specify it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add an issue

val geometryColumn = geometry named "geometry"
val geoDataFrame = if (columnRowsCount != datasetBuilderRowsCount) {
// override dataset if datasetBuilder size doesn't match
dataFrameOf(geometryColumn).toGeo(null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite in Kotlin style. You can define a copy method with changing parameters

block: PolygonBuilder.() -> Unit = {}
) {
geometry().forEach {
if (it !is Polygonal) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to check

}

// TODO add ColumnAccessor & String api
@JvmName("geoRectanglesGeometry")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need JvmName? Is there a conflict somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes:

Platform declaration clash: The following declarations have the same JVM signature (geoRectangles(Lorg/jetbrains/kotlinx/kandy/dsl/internal/LayerCreatorScope;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)V):
    fun LayerCreatorScope.geoRectangles(geometry: Iterable<Envelope>, block: (RectanglesBuilder) -> Unit = ...): Unit defined in org.jetbrains.kotlinx.kandy.letsplot.geo.layers
    fun LayerCreatorScope.geoRectangles(geometry: Iterable<Geometry>, block: (RectanglesBuilder) -> Unit = ...): Unit defined in org.jetbrains.kotlinx.kandy.letsplot.geo.layers
    

@AndreiKingsley AndreiKingsley merged commit 6231892 into dev Dec 13, 2024
@AndreiKingsley AndreiKingsley deleted the geo branch December 13, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants