Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit091d56e

Browse files
authored
Merge pull request#291 from sllynn/sllynn/geojson-fix
added spatial reference into calls to geojson operator for OGCMultiLi…
2 parentsa1af661 +48149c8 commit091d56e

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

‎src/main/java/com/esri/core/geometry/ogc/OGCMultiLineString.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public String asText() {
6464
publicStringasGeoJson() {
6565
OperatorExportToGeoJsonop = (OperatorExportToGeoJson)OperatorFactoryLocal.getInstance()
6666
.getOperator(Operator.Type.ExportToGeoJson);
67-
returnop.execute(GeoJsonExportFlags.geoJsonExportPreferMultiGeometry,null,getEsriGeometry());
67+
returnop.execute(GeoJsonExportFlags.geoJsonExportPreferMultiGeometry,esriSR,getEsriGeometry());
6868
}
6969

7070
@Override

‎src/main/java/com/esri/core/geometry/ogc/OGCMultiPolygon.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public ByteBuffer asBinary() {
7171
publicStringasGeoJson() {
7272
OperatorExportToGeoJsonop = (OperatorExportToGeoJson)OperatorFactoryLocal
7373
.getInstance().getOperator(Operator.Type.ExportToGeoJson);
74-
returnop.execute(GeoJsonExportFlags.geoJsonExportPreferMultiGeometry,null,getEsriGeometry());
74+
returnop.execute(GeoJsonExportFlags.geoJsonExportPreferMultiGeometry,esriSR,getEsriGeometry());
7575
}
7676
@Override
7777
publicintnumGeometries() {

‎src/test/java/com/esri/core/geometry/TestGeomToGeoJson.java‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@
2222

2323
packagecom.esri.core.geometry;
2424

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.*;
3026
importcom.fasterxml.jackson.core.JsonFactory;
3127
importcom.fasterxml.jackson.core.JsonParser;
32-
importcom.esri.core.geometry.ogc.OGCConcreteGeometryCollection;
3328
importjunit.framework.TestCase;
3429
importorg.junit.Test;
3530

@@ -161,6 +156,20 @@ public void testOGCLineString() {
161156
assertEquals("{\"type\":\"LineString\",\"coordinates\":[[100,0],[101,0],[101,1],[100,1]],\"crs\":null}",result);
162157
}
163158

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+
164173
@Test
165174
publicvoidtestPolygon() {
166175
Polygonp =newPolygon();
@@ -241,6 +250,24 @@ public void testMultiPolygon() throws IOException {
241250
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);
242251
}
243252

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+
244271

245272
@Test
246273
publicvoidtestEmptyPolygon() {
@@ -334,6 +361,29 @@ public void testOGCPolygonWithHole() {
334361
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);
335362
}
336363

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+
337387
@Test
338388
publicvoidtestGeometryCollection() {
339389
SpatialReferencesr =SpatialReference.create(4326);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp