Skip to content

Commit 9df1b8d

Browse files
committed
Test writing with ids
1 parent 194b372 commit 9df1b8d

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

generator/src/test/java/de/westnordost/countryboundaries/GeoJsonWriterTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,34 @@ public class GeoJsonWriterTest
205205
"}]}", write(g));
206206
}
207207

208+
@Test public void writeFeatureWithStringId()
209+
{
210+
Polygon g = factory.createPolygon(
211+
factory.createLinearRing(new Coordinate[]{p(0,0), p(0,4), p(4,0), p(0,0)}),
212+
new LinearRing[]{factory.createLinearRing(new Coordinate[] {p(1,1), p(2,1), p(1,2), p(1,1)})}
213+
);
214+
g.setUserData(Collections.singletonMap("id", "DE"));
215+
assertEquals("{" +
216+
"\"type\":\"Feature\",\"id\":\"DE\",\"properties\":{\"id\":\"DE\"}," +
217+
"\"geometry\":{\"type\":\"Polygon\"," +
218+
"\"coordinates\":[[[0,0],[4,0],[0,4],[0,0]],[[1,1],[1,2],[2,1],[1,1]]]}" +
219+
"}", write(g));
220+
}
221+
222+
@Test public void writeFeatureWithNumericId()
223+
{
224+
Polygon g = factory.createPolygon(
225+
factory.createLinearRing(new Coordinate[]{p(0,0), p(0,4), p(4,0), p(0,0)}),
226+
new LinearRing[]{factory.createLinearRing(new Coordinate[] {p(1,1), p(2,1), p(1,2), p(1,1)})}
227+
);
228+
g.setUserData(Collections.singletonMap("id", 123));
229+
assertEquals("{" +
230+
"\"type\":\"Feature\",\"id\":123,\"properties\":{\"id\":123}," +
231+
"\"geometry\":{\"type\":\"Polygon\"," +
232+
"\"coordinates\":[[[0,0],[4,0],[0,4],[0,0]],[[1,1],[1,2],[2,1],[1,1]]]}" +
233+
"}", write(g));
234+
}
235+
208236
private static String write(Geometry g)
209237
{
210238
return new GeoJsonWriter().write(g);

0 commit comments

Comments
 (0)