|
22 | 22 |
|
23 | 23 | packagecom.esri.core.geometry; |
24 | 24 |
|
25 | | -importcom.esri.core.geometry.ogc.OGCGeometry; |
26 | | -importcom.esri.core.geometry.ogc.OGCPoint; |
27 | | -importcom.esri.core.geometry.ogc.OGCMultiPoint; |
28 | | -importcom.esri.core.geometry.ogc.OGCLineString; |
29 | | -importcom.esri.core.geometry.ogc.OGCPolygon; |
| 25 | +importcom.esri.core.geometry.ogc.*; |
30 | 26 | importcom.fasterxml.jackson.core.JsonFactory; |
31 | 27 | importcom.fasterxml.jackson.core.JsonParser; |
32 | | -importcom.esri.core.geometry.ogc.OGCConcreteGeometryCollection; |
33 | 28 | importjunit.framework.TestCase; |
34 | 29 | importorg.junit.Test; |
35 | 30 |
|
@@ -161,6 +156,20 @@ public void testOGCLineString() { |
161 | 156 | assertEquals("{\"type\":\"LineString\",\"coordinates\":[[100,0],[101,0],[101,1],[100,1]],\"crs\":null}",result); |
162 | 157 | } |
163 | 158 |
|
| 159 | +@Test |
| 160 | +publicvoidtestOGCMultiLineStringCRS()throwsIOException { |
| 161 | +Polylinep =newPolyline(); |
| 162 | +p.startPath(100.0,0.0); |
| 163 | +p.lineTo(101.0,0.0); |
| 164 | +p.lineTo(101.0,1.0); |
| 165 | +p.lineTo(100.0,1.0); |
| 166 | + |
| 167 | +OGCMultiLineStringmultiLineString =newOGCMultiLineString(p,SpatialReference.create(4326)); |
| 168 | + |
| 169 | +Stringresult =multiLineString.asGeoJson(); |
| 170 | +assertEquals("{\"type\":\"MultiLineString\",\"coordinates\":[[[100,0],[101,0],[101,1],[100,1]]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}",result); |
| 171 | +} |
| 172 | + |
164 | 173 | @Test |
165 | 174 | publicvoidtestPolygon() { |
166 | 175 | Polygonp =newPolygon(); |
@@ -241,6 +250,24 @@ public void testMultiPolygon() throws IOException { |
241 | 250 | assertEquals("{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-100,-100],[100,-100],[100,100],[-100,100],[-100,-100]],[[-90,-90],[90,-90],[-90,90],[90,90],[-90,-90]]],[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]]}",result); |
242 | 251 | } |
243 | 252 |
|
| 253 | +@Test |
| 254 | +publicvoidtestOGCMultiPolygonCRS()throwsIOException { |
| 255 | +JsonFactoryjsonFactory =newJsonFactory(); |
| 256 | + |
| 257 | +StringesriJsonPolygon ="{\"rings\": [[[-100, -100], [-100, 100], [100, 100], [100, -100], [-100, -100]], [[-90, -90], [90, 90], [-90, 90], [90, -90], [-90, -90]], [[-10, -10], [-10, 10], [10, 10], [10, -10], [-10, -10]]]}"; |
| 258 | + |
| 259 | +JsonParserparser =jsonFactory.createParser(esriJsonPolygon); |
| 260 | +MapGeometryparsedPoly =GeometryEngine.jsonToGeometry(parser); |
| 261 | + |
| 262 | +parsedPoly.setSpatialReference(SpatialReference.create(4326)); |
| 263 | +Polygonpoly = (Polygon)parsedPoly.getGeometry(); |
| 264 | +OGCMultiPolygonmultiPolygon =newOGCMultiPolygon(poly,parsedPoly.getSpatialReference()); |
| 265 | + |
| 266 | + |
| 267 | +Stringresult =multiPolygon.asGeoJson(); |
| 268 | +assertEquals("{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-100,-100],[100,-100],[100,100],[-100,100],[-100,-100]],[[-90,-90],[90,-90],[-90,90],[90,90],[-90,-90]]],[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}",result); |
| 269 | +} |
| 270 | + |
244 | 271 |
|
245 | 272 | @Test |
246 | 273 | publicvoidtestEmptyPolygon() { |
@@ -334,6 +361,29 @@ public void testOGCPolygonWithHole() { |
334 | 361 | assertEquals("{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[101,0],[101,1],[100,1],[100,0]],[[100.2,0.2],[100.2,0.8],[100.8,0.8],[100.8,0.2],[100.2,0.2]]],\"crs\":null}",result); |
335 | 362 | } |
336 | 363 |
|
| 364 | +@Test |
| 365 | +publicvoidtestOGCPolygonWithHoleCRS() { |
| 366 | +Polygonp =newPolygon(); |
| 367 | + |
| 368 | +p.startPath(100.0,0.0); |
| 369 | +p.lineTo(100.0,1.0); |
| 370 | +p.lineTo(101.0,1.0); |
| 371 | +p.lineTo(101.0,0.0); |
| 372 | +p.closePathWithLine(); |
| 373 | + |
| 374 | +p.startPath(100.2,0.2); |
| 375 | +p.lineTo(100.8,0.2); |
| 376 | +p.lineTo(100.8,0.8); |
| 377 | +p.lineTo(100.2,0.8); |
| 378 | +p.closePathWithLine(); |
| 379 | + |
| 380 | +SpatialReferencesr =SpatialReference.create(4326); |
| 381 | + |
| 382 | +OGCPolygonogcPolygon =newOGCPolygon(p,sr); |
| 383 | +Stringresult =ogcPolygon.asGeoJson(); |
| 384 | +assertEquals("{\"type\":\"Polygon\",\"coordinates\":[[[100,0],[101,0],[101,1],[100,1],[100,0]],[[100.2,0.2],[100.2,0.8],[100.8,0.8],[100.8,0.2],[100.2,0.2]]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}",result); |
| 385 | +} |
| 386 | + |
337 | 387 | @Test |
338 | 388 | publicvoidtestGeometryCollection() { |
339 | 389 | SpatialReferencesr =SpatialReference.create(4326); |
|