-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* GH-162 handle empty point / shape collection in WKT Signed-off-by: Jeen Broekstra <[email protected]> * Fix GeoJson too. Test round-trip. Co-authored-by: David Smiley <[email protected]>
- Loading branch information
1 parent
5d8bac2
commit 6a43828
Showing
9 changed files
with
87 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/java/org/locationtech/spatial4j/io/WKTWriterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.locationtech.spatial4j.io; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import java.util.ArrayList; | ||
import org.junit.Test; | ||
import org.locationtech.spatial4j.context.SpatialContext; | ||
import org.locationtech.spatial4j.shape.Point; | ||
import org.locationtech.spatial4j.shape.ShapeCollection; | ||
|
||
public class WKTWriterTest { | ||
|
||
private SpatialContext ctx; | ||
|
||
protected WKTWriterTest(SpatialContext ctx) { | ||
this.ctx = ctx; | ||
} | ||
|
||
public WKTWriterTest() { | ||
this(SpatialContext.GEO); | ||
} | ||
|
||
@Test | ||
public void testToStringOnEmptyPoint() throws Exception { | ||
ShapeWriter writer = ctx.getFormats().getWktWriter(); | ||
Point emptyPoint = ctx.makePoint(Double.NaN, Double.NaN); | ||
|
||
assertEquals("POINT EMPTY", writer.toString(emptyPoint)); | ||
} | ||
|
||
@Test | ||
public void testToStringOnEmptyShapeCollection() throws Exception { | ||
ShapeWriter writer = ctx.getFormats().getWktWriter(); | ||
ShapeCollection<Point> emptyCollection = ctx.makeCollection(new ArrayList<Point>()); | ||
|
||
assertEquals("GEOMETRYCOLLECTION EMPTY", writer.toString(emptyCollection)); | ||
} | ||
} |