All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jawg.geojson.PolygonValidator.kt Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
package io.jawg.geojson

internal object PolygonValidator {

  fun validate(coordinates: PolygonCoordinates) {
    require(coordinates.isNotEmpty()) { "Polygon coordinates must have at least one linear ring" }

    coordinates.forEach { linearRing ->
      require(linearRing.size >= 4) { "Polygon linear ring must have at least 4 coordinates" }
      require(linearRing.first() == linearRing.last()) {
        "Polygon linear ring first element must be equal to last element"
      }
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy