commonMain.jetbrains.datalore.base.spatial.SimpleFeature.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lets-plot-common Show documentation
Show all versions of lets-plot-common Show documentation
Lets-Plot JVM package without rendering part
/*
* Copyright (c) 2020. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.base.spatial
import jetbrains.datalore.base.typedGeometry.*
object SimpleFeature {
interface GeometryConsumer {
fun onPoint(point: Vec): Unit = error("Point isn't supported")
fun onLineString(lineString: LineString): Unit = error("LineString isn't supported")
fun onPolygon(polygon: Polygon): Unit = error("Polygon isn't supported")
fun onMultiPoint(multiPoint: MultiPoint): Unit = error("MultiPoint isn't supported")
fun onMultiLineString(multiLineString: MultiLineString): Unit = error("MultiLineString isn't supported")
fun onMultiPolygon(multipolygon: MultiPolygon): Unit = error("MultiPolygon isn't supported")
}
class Consumer(
var onPoint: (Vec) -> Unit = { error("Point isn't supported") },
var onLineString: (LineString) -> Unit = { error("LineString isn't supported") },
var onPolygon: (Polygon) -> Unit = { error("Polygon isn't supported") },
var onMultiPoint: (MultiPoint) -> Unit = { error("MultiPoint isn't supported") },
var onMultiLineString: (MultiLineString) -> Unit = { error("MultiLineString isn't supported") },
var onMultiPolygon: (MultiPolygon) -> Unit = { error("MultiPolygon isn't supported") }
) : GeometryConsumer {
override fun onPoint(point: Vec): Unit = (onPoint)(point)
override fun onLineString(lineString: LineString): Unit = (onLineString)(lineString)
override fun onPolygon(polygon: Polygon): Unit = (onPolygon)(polygon)
override fun onMultiPoint(multiPoint: MultiPoint): Unit = (onMultiPoint)(multiPoint)
override fun onMultiLineString(multiLineString: MultiLineString): Unit = (onMultiLineString)(multiLineString)
override fun onMultiPolygon(multipolygon: MultiPolygon): Unit = (onMultiPolygon)(multipolygon)
}
enum class GeometryType {
POINT,
LINE_STRING,
POLYGON,
MULTI_POINT,
MULTI_LINE_STRING,
MULTI_POLYGON,
GEOMETRY_COLLECTION;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy