JetBrains / lets-plot-kotlin

Grammar of Graphics for Kotlin
https://lets-plot.org/kotlin/
MIT License
419 stars 36 forks source link

PolygonData ring should contain at least 3 points #243

Closed icuxika closed 2 months ago

icuxika commented 2 months ago

The latest countries data on Natural Earth 1:110m Cultural Vectors Admin 0 – Countries for Africa does not meet the validation criteria of LinesHelper

 require(rings.all { it.size >= 3 }) { "PolygonData ring should contain at least 3 points" }

By debugging you can find two pieces of data when the condition is not met

PathPoint(aes=org.jetbrains.letsPlot.core.plot.base.aes.AestheticsBuilder$MyDataPointAesthetics@232149d3, coord=(48.9482047585, 11.4106172817))
PathPoint(aes=org.jetbrains.letsPlot.core.plot.base.aes.AestheticsBuilder$MyDataPointAesthetics@20a514e1, coord=(48.9482047585, 11.4106172817))

2024-04-27-1093142265

Here is the relevant code

    val polygonParams = hashMapOf<String, String>()
    polygonParams[ShapefileDataStoreFactory.URLP.key] = "file:ne_110m_admin_0_countries.shp"
    val polygonDataStore = ShapefileDataStoreFactory().createDataStore(polygonParams)
    val polygonCollection = polygonDataStore.getFeatureSource(polygonDataStore.names[0]).features
    // [Oceania, Africa, North America, Asia, South America, Europe, Seven seas (open ocean), Antarctica]
    // val polygonSpatialDataset = polygonCollection.subCollection(CQL.toFilter("CONTINENT NOT LIKE 'Africa'")).toSpatialDataset(10)
        val polygonSpatialDataset = polygonCollection.toSpatialDataset(10)

        plotsContainer.children.add(
            createPlotSpecsNode(Dimension(1360, 768)) {
                val p = letsPlot() + geomMap(
                      data = polygonSpatialDataset,
                      color = "white",
                      fill = "#0868ac",
                      alpha = 0.2 
                ) {
                        fill = "CONTINENT"
                  }
                    p.toSpec()
                }
           )

versions

alshan commented 2 months ago

Hi, this specific issue was fixed in lets-plot v4.3.2. Try to upgrade lets-plot-jfx --> 4.3.2 and lets-plot-kotlin-jvm 4.7.2

icuxika commented 2 months ago

Thank you very much, the problem was resolved after upgrading the library