public virtual void testEmptyEnvelope() { com.esri.core.geometry.Envelope e = new com.esri.core.geometry.Envelope(); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(e); NUnit.Framework.Assert.AreEqual("{\"bbox\":null}", result); }
public virtual void testEmptyPoint() { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"Point\",\"coordinates\":null}", result ); }
public virtual void testMultiPoint() { com.esri.core.geometry.MultiPoint mp = new com.esri.core.geometry.MultiPoint(); mp.add(10.0, 20.0); mp.add(20.0, 30.0); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(mp); NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiPoint\",\"coordinates\":[[10.0,20.0],[20.0,30.0]]}" , result); }
public virtual void testPolyline() { com.esri.core.geometry.Polyline p = new com.esri.core.geometry.Polyline(); p.startPath(100.0, 0.0); p.lineTo(101.0, 0.0); p.lineTo(101.0, 1.0); p.lineTo(100.0, 1.0); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"LineString\",\"coordinates\":[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0]]}" , result); }
public virtual void testEmptyPolygon() { com.esri.core.geometry.Polygon p = new com.esri.core.geometry.Polygon(); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":null}", result ); com.esri.core.geometry.MapGeometry imported = com.esri.core.geometry.OperatorImportFromGeoJson .local().execute(0, com.esri.core.geometry.Geometry.Type.Unknown, result, null); NUnit.Framework.Assert.IsTrue(imported.getGeometry().isEmpty()); NUnit.Framework.Assert.IsTrue(imported.getGeometry().getType() == com.esri.core.geometry.Geometry.Type .Polygon); }
public virtual void testMultiPolygon() { org.codehaus.jackson.JsonFactory jsonFactory = new org.codehaus.jackson.JsonFactory (); string geoJsonPolygon = "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-100.0,-100.0],[-100.0,100.0],[100.0,100.0],[100.0,-100.0],[-100.0,-100.0]],[[-90.0,-90.0],[90.0,90.0],[-90.0,90.0],[90.0,-90.0],[-90.0,-90.0]]],[[[-10.0,-10.0],[-10.0,10.0],[10.0,10.0],[10.0,-10.0],[-10.0,-10.0]]]]}"; string esriJsonPolygon = "{\"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]]]}"; org.codehaus.jackson.JsonParser parser = jsonFactory.createJsonParser(esriJsonPolygon ); com.esri.core.geometry.MapGeometry parsedPoly = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); //MapGeometry parsedPoly = GeometryEngine.geometryFromGeoJson(jsonPolygon, 0, Geometry.Type.Polygon); com.esri.core.geometry.Polygon poly = (com.esri.core.geometry.Polygon)parsedPoly. getGeometry(); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); //String result = exporter.execute(parsedPoly.getGeometry()); string result = exporter.execute(poly); NUnit.Framework.Assert.AreEqual(geoJsonPolygon, result); }
public virtual void testPolygonWithHole() { com.esri.core.geometry.Polygon p = new com.esri.core.geometry.Polygon(); //exterior ring - has to be clockwise for Esri p.startPath(100.0, 0.0); p.lineTo(100.0, 1.0); p.lineTo(101.0, 1.0); p.lineTo(101.0, 0.0); p.closePathWithLine(); //hole - counterclockwise for Esri p.startPath(100.2, 0.2); p.lineTo(100.8, 0.2); p.lineTo(100.8, 0.8); p.lineTo(100.2, 0.8); p.closePathWithLine(); com.esri.core.geometry.OperatorExportToGeoJson exporter = (com.esri.core.geometry.OperatorExportToGeoJson )factory.getOperator(com.esri.core.geometry.Operator.Type.ExportToGeoJson); string result = exporter.execute(p); NUnit.Framework.Assert.AreEqual("{\"type\":\"Polygon\",\"coordinates\":[[[100.0,0.0],[100.0,1.0],[101.0,1.0],[101.0,0.0],[100.0,0.0]],[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]}" , result); }