Skip to content

Commit 69e95a9

Browse files
authored
[GH-2702] Fix ST_LineMerge returning empty collection for LineString input (#2707)
1 parent 8049718 commit 69e95a9

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

common/src/main/java/org/apache/sedona/common/Functions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,9 @@ public static Geometry reducePrecision(Geometry geometry, int precisionScale) {
11961196
}
11971197

11981198
public static Geometry lineMerge(Geometry geometry) {
1199+
if (geometry instanceof LineString) {
1200+
return geometry;
1201+
}
11991202
if (geometry instanceof MultiLineString) {
12001203
MultiLineString multiLineString = (MultiLineString) geometry;
12011204
int numLineStrings = multiLineString.getNumGeometries();

spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,8 @@ class functionTestScala
22462246
("MULTILINESTRING ((-29 -27, -30 -29.7, -45 -33), (-45 -33, -46 -32))"),
22472247
("MULTILINESTRING ((-29 -27, -30 -29.7, -36 -31, -45 -33), (-45.2 -33.2, -46 -32))"),
22482248
("POLYGON ((8 25, 28 22, 15 11, 33 3, 56 30, 47 44, 35 36, 43 19, 24 39, 8 25))"),
2249-
("MULTILINESTRING ((10 160, 60 120), (120 140, 60 120), (120 140, 180 120), (100 180, 120 140))"))
2249+
("MULTILINESTRING ((10 160, 60 120), (120 140, 60 120), (120 140, 180 120), (100 180, 120 140))"),
2250+
("LINESTRING (0 0, 1 1)"))
22502251
.toDF("Geometry")
22512252

22522253
When("Using ST_LineMerge")
@@ -2261,7 +2262,8 @@ class functionTestScala
22612262
"LINESTRING (-29 -27, -30 -29.7, -45 -33, -46 -32)",
22622263
"MULTILINESTRING ((-45.2 -33.2, -46 -32), (-29 -27, -30 -29.7, -36 -31, -45 -33))",
22632264
"GEOMETRYCOLLECTION EMPTY",
2264-
"MULTILINESTRING ((10 160, 60 120, 120 140), (100 180, 120 140), (120 140, 180 120))")
2265+
"MULTILINESTRING ((10 160, 60 120, 120 140), (100 180, 120 140), (120 140, 180 120))",
2266+
"LINESTRING (0 0, 1 1)")
22652267
}
22662268

22672269
it("Should pass ST_LocateAlong") {

0 commit comments

Comments
 (0)