@@ -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