Skip to content

Commit 63142c8

Browse files
add toMulti extensions
1 parent d127dc7 commit 63142c8

File tree

1 file changed

+41
-0
lines changed
  • dataframe-geo/src/main/kotlin/org/jetbrains/kotlinx/dataframe/geo/jts

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.jetbrains.kotlinx.dataframe.geo.jts
2+
3+
import org.locationtech.jts.geom.LineString
4+
import org.locationtech.jts.geom.MultiLineString
5+
import org.locationtech.jts.geom.MultiPoint
6+
import org.locationtech.jts.geom.MultiPolygon
7+
import org.locationtech.jts.geom.Point
8+
import org.locationtech.jts.geom.Polygon
9+
10+
/**
11+
* Converts a [Polygon] to a [MultiPolygon] by wrapping it in a MultiPolygon.
12+
*
13+
* @receiver Polygon to be converted.
14+
* @return A MultiPolygon containing the original Polygon.
15+
*/
16+
fun Polygon.toMultiPolygon(): MultiPolygon {
17+
val geometryFactory = this.factory
18+
return geometryFactory.createMultiPolygon(arrayOf(this))
19+
}
20+
21+
/**
22+
* Converts a [Point] to a [MultiPoint] by wrapping it in a MultiPoint.
23+
*
24+
* @receiver Point to be converted.
25+
* @return A MultiPoint containing the original Point.
26+
*/
27+
fun Point.toMultiPoint(): MultiPoint {
28+
val geometryFactory = this.factory
29+
return geometryFactory.createMultiPoint(arrayOf(this))
30+
}
31+
32+
/**
33+
* Converts a [LineString] to a [MultiLineString] by wrapping it in a MultiLineString.
34+
*
35+
* @receiver LineString to be converted.
36+
* @return A MultiLineString containing the original LineString.
37+
*/
38+
fun LineString.toMultiLineString(): MultiLineString {
39+
val geometryFactory = this.factory
40+
return geometryFactory.createMultiLineString(arrayOf(this))
41+
}

0 commit comments

Comments
 (0)