/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testCR181369() { // CR181369 bool bAnswer = true; string jsonStringPointAndWKT = "{\"x\":10.0,\"y\":20.0,\"spatialReference\":{\"wkt\" : \"PROJCS[\\\"NAD83_UTM_zone_15N\\\",GEOGCS[\\\"GCS_North_American_1983\\\",DATUM[\\\"D_North_American_1983\\\",SPHEROID[\\\"GRS_1980\\\",6378137.0,298.257222101]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433]],PROJECTION[\\\"Transverse_Mercator\\\"],PARAMETER[\\\"false_easting\\\",500000.0],PARAMETER[\\\"false_northing\\\",0.0],PARAMETER[\\\"central_meridian\\\",-93.0],PARAMETER[\\\"scale_factor\\\",0.9996],PARAMETER[\\\"latitude_of_origin\\\",0.0],UNIT[\\\"Meter\\\",1.0]]\"} }"; org.codehaus.jackson.JsonParser jsonParserPointAndWKT = factory.createJsonParser( jsonStringPointAndWKT); com.esri.core.geometry.MapGeometry mapGeom2 = com.esri.core.geometry.GeometryEngine .jsonToGeometry(jsonParserPointAndWKT); string jsonStringPointAndWKT2 = com.esri.core.geometry.GeometryEngine.geometryToJson (mapGeom2.getSpatialReference(), mapGeom2.getGeometry()); org.codehaus.jackson.JsonParser jsonParserPointAndWKT2 = factory.createJsonParser (jsonStringPointAndWKT2); com.esri.core.geometry.MapGeometry mapGeom3 = com.esri.core.geometry.GeometryEngine .jsonToGeometry(jsonParserPointAndWKT2); NUnit.Framework.Assert.IsTrue(((com.esri.core.geometry.Point)mapGeom2.getGeometry ()).getX() == ((com.esri.core.geometry.Point)mapGeom3.getGeometry()).getX()); NUnit.Framework.Assert.IsTrue(((com.esri.core.geometry.Point)mapGeom2.getGeometry ()).getY() == ((com.esri.core.geometry.Point)mapGeom3.getGeometry()).getY()); string s1 = mapGeom2.getSpatialReference().getText(); string s2 = mapGeom3.getSpatialReference().getText(); NUnit.Framework.Assert.IsTrue(s1.Equals(s2)); int id2 = mapGeom2.getSpatialReference().getID(); int id3 = mapGeom3.getSpatialReference().getID(); NUnit.Framework.Assert.IsTrue(id2 == id3); if (!checkResultSpatialRef(mapGeom3, mapGeom2.getSpatialReference().getID(), 0)) { bAnswer = false; } return(bAnswer); }
internal virtual bool checkResultSpatialRef(com.esri.core.geometry.MapGeometry mapGeometry , int expectWki1, int expectWki2) { com.esri.core.geometry.SpatialReference sr = mapGeometry.getSpatialReference(); string Wkt = sr.getText(); int wki1 = sr.getLatestID(); if (!(wki1 == expectWki1 || wki1 == expectWki2)) { return(false); } if (!(Wkt != null && Wkt.Length > 0)) { return(false); } com.esri.core.geometry.SpatialReference sr2 = com.esri.core.geometry.SpatialReference .create(Wkt); int wki2 = sr2.getID(); if (expectWki2 > 0) { if (!(wki2 == expectWki1 || wki2 == expectWki2)) { return(false); } } else { if (!(wki2 == expectWki1)) { return(false); } } return(true); }
public virtual void testOnlyWKI() { string jsonStringSR = "{\"wkid\" : 4326}"; org.codehaus.jackson.JsonParser jsonParserSR = factory.createJsonParser(jsonStringSR ); jsonParserSR.nextToken(); com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine .jsonToGeometry(jsonParserSR); com.esri.core.geometry.Utils.showProjectedGeometryInfo(mapGeom); com.esri.core.geometry.SpatialReference sr = mapGeom.getSpatialReference(); NUnit.Framework.Assert.IsTrue(sr == null); }
public virtual void testMP2onCR175871() { com.esri.core.geometry.Polygon pg = new com.esri.core.geometry.Polygon(); pg.startPath(-50, 10); pg.lineTo(-50, 12); pg.lineTo(-45, 12); pg.lineTo(-45, 10); com.esri.core.geometry.Polygon pg1 = new com.esri.core.geometry.Polygon(); pg1.startPath(-45, 10); pg1.lineTo(-40, 10); pg1.lineTo(-40, 8); pg.add(pg1, false); try { string jSonStr = com.esri.core.geometry.GeometryEngine.geometryToJson(4326, pg); org.codehaus.jackson.JsonFactory jf = new org.codehaus.jackson.JsonFactory(); org.codehaus.jackson.JsonParser jp = jf.createJsonParser(jSonStr); jp.nextToken(); com.esri.core.geometry.MapGeometry mg = com.esri.core.geometry.GeometryEngine.jsonToGeometry (jp); com.esri.core.geometry.Geometry gm = mg.getGeometry(); NUnit.Framework.Assert.AreEqual(com.esri.core.geometry.Geometry.Type.Polygon, gm. getType()); com.esri.core.geometry.Polygon pgNew = (com.esri.core.geometry.Polygon)gm; NUnit.Framework.Assert.AreEqual(pgNew.getPathCount(), pg.getPathCount()); NUnit.Framework.Assert.AreEqual(pgNew.getPointCount(), pg.getPointCount()); NUnit.Framework.Assert.AreEqual(pgNew.getSegmentCount(), pg.getSegmentCount()); NUnit.Framework.Assert.AreEqual(pg.getPoint(0).getX(), 0.000000001, pgNew.getPoint (0).getX()); NUnit.Framework.Assert.AreEqual(pg.getPoint(1).getX(), 0.000000001, pgNew.getPoint (1).getX()); NUnit.Framework.Assert.AreEqual(pg.getPoint(2).getX(), 0.000000001, pgNew.getPoint (2).getX()); NUnit.Framework.Assert.AreEqual(pg.getPoint(3).getX(), 0.000000001, pgNew.getPoint (3).getX()); NUnit.Framework.Assert.AreEqual(pg.getPoint(0).getY(), 0.000000001, pgNew.getPoint (0).getY()); NUnit.Framework.Assert.AreEqual(pg.getPoint(1).getY(), 0.000000001, pgNew.getPoint (1).getY()); NUnit.Framework.Assert.AreEqual(pg.getPoint(2).getY(), 0.000000001, pgNew.getPoint (2).getY()); NUnit.Framework.Assert.AreEqual(pg.getPoint(3).getY(), 0.000000001, pgNew.getPoint (3).getY()); } catch (System.Exception ex) { string err = ex.Message; System.Console.Out.Write(err); throw; } }
public static void testContainsFailureCR186456() { string str = "{\"rings\":[[[406944.399999999,287461.450000001],[406947.750000011,287462.299999997],[406946.44999999,287467.450000001],[406943.050000005,287466.550000005],[406927.799999992,287456.849999994],[406926.949999996,287456.599999995],[406924.800000005,287455.999999998],[406924.300000007,287455.849999999],[406924.200000008,287456.099999997],[406923.450000011,287458.449999987],[406922.999999987,287459.800000008],[406922.29999999,287462.099999998],[406921.949999991,287463.449999992],[406921.449999993,287465.050000011],[406920.749999996,287466.700000004],[406919.800000001,287468.599999996],[406919.050000004,287469.99999999],[406917.800000009,287471.800000008],[406916.04999999,287473.550000001],[406915.449999993,287473.999999999],[406913.700000001,287475.449999993],[406913.300000002,287475.899999991],[406912.050000008,287477.250000011],[406913.450000002,287478.150000007],[406915.199999994,287478.650000005],[406915.999999991,287478.800000005],[406918.300000007,287479.200000003],[406920.649999997,287479.450000002],[406923.100000013,287479.550000001],[406925.750000001,287479.450000002],[406928.39999999,287479.150000003],[406929.80000001,287478.950000004],[406932.449999998,287478.350000006],[406935.099999987,287477.60000001],[406938.699999998,287476.349999989],[406939.649999994,287473.949999999],[406939.799999993,287473.949999999],[406941.249999987,287473.75],[406942.700000007,287473.250000002],[406943.100000005,287473.100000003],[406943.950000001,287472.750000004],[406944.799999998,287472.300000006],[406944.999999997,287472.200000007],[406946.099999992,287471.200000011],[406946.299999991,287470.950000012],[406948.00000001,287468.599999996],[406948.10000001,287468.399999997],[406950.100000001,287465.050000011],[406951.949999993,287461.450000001],[406952.049999993,287461.300000001],[406952.69999999,287459.900000007],[406953.249999987,287458.549999987],[406953.349999987,287458.299999988],[406953.650000012,287457.299999992],[406953.900000011,287456.349999996],[406954.00000001,287455.300000001],[406954.00000001,287454.750000003],[406953.850000011,287453.750000008],[406953.550000012,287452.900000011],[406953.299999987,287452.299999988],[406954.500000008,287450.299999996],[406954.00000001,287449.000000002],[406953.399999987,287447.950000006],[406953.199999988,287447.550000008],[406952.69999999,287446.850000011],[406952.149999992,287446.099999988],[406951.499999995,287445.499999991],[406951.149999996,287445.249999992],[406950.449999999,287444.849999994],[406949.600000003,287444.599999995],[406949.350000004,287444.549999995],[406948.250000009,287444.499999995],[406947.149999987,287444.699999994],[406946.849999989,287444.749999994],[406945.899999993,287444.949999993],[406944.999999997,287445.349999991],[406944.499999999,287445.64999999],[406943.650000003,287446.349999987],[406942.900000006,287447.10000001],[406942.500000008,287447.800000007],[406942.00000001,287448.700000003],[406941.600000011,287449.599999999],[406941.350000013,287450.849999994],[406941.350000013,287451.84999999],[406941.450000012,287452.850000012],[406941.750000011,287453.850000007],[406941.800000011,287454.000000007],[406942.150000009,287454.850000003],[406942.650000007,287455.6],[406943.150000005,287456.299999997],[406944.499999999,287457.299999992],[406944.899999997,287457.599999991],[406945.299999995,287457.949999989],[406944.399999999,287461.450000001],[406941.750000011,287461.999999998],[406944.399999999,287461.450000001]],[[406944.399999999,287461.450000001],[406947.750000011,287462.299999997],[406946.44999999,287467.450000001],[406943.050000005,287466.550000005],[406927.799999992,287456.849999994],[406944.399999999,287461.450000001]]]}"; org.codehaus.jackson.JsonFactory jsonFactory = new org.codehaus.jackson.JsonFactory (); org.codehaus.jackson.JsonParser jsonParser = jsonFactory.createJsonParser(str); com.esri.core.geometry.MapGeometry mg = com.esri.core.geometry.GeometryEngine.jsonToGeometry (jsonParser); bool res = com.esri.core.geometry.GeometryEngine.contains(mg.getGeometry(), mg.getGeometry (), null); NUnit.Framework.Assert.IsTrue(res); }
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 testPolygonWithEmptyWKT_NoWKI() { string jsonStringPg = "{ \"rings\" :[ [ [-97.06138,32.837], [-97.06133,32.836], " + "[-97.06124,32.834], [-97.06127,32.832], [-97.06138,32.837] ], " + "[ [-97.06326,32.759], [-97.06298,32.755], [-97.06153,32.749], [-97.06326,32.759] ]], " + "\"spatialReference\" : {\"wkt\" : \"\"}}"; org.codehaus.jackson.JsonParser jsonParserPg = factory.createJsonParser(jsonStringPg ); jsonParserPg.nextToken(); com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine .jsonToGeometry(jsonParserPg); com.esri.core.geometry.Utils.showProjectedGeometryInfo(mapGeom); com.esri.core.geometry.SpatialReference sr = mapGeom.getSpatialReference(); NUnit.Framework.Assert.IsTrue(sr == null); }
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 static void testDistanceWithNullSpatialReference() { // There was a bug that distance op did not work with null Spatial // Reference. string str1 = "{\"paths\":[[[-117.138791850991,34.017492675023],[-117.138762336971,34.0174925550462]]]}"; string str2 = "{\"paths\":[[[-117.138867827972,34.0174854109623],[-117.138850197027,34.0174929160126],[-117.138791850991,34.017492675023]]]}"; org.codehaus.jackson.JsonFactory jsonFactory = new org.codehaus.jackson.JsonFactory (); org.codehaus.jackson.JsonParser jsonParser1 = jsonFactory.createJsonParser(str1); org.codehaus.jackson.JsonParser jsonParser2 = jsonFactory.createJsonParser(str2); com.esri.core.geometry.MapGeometry geom1 = com.esri.core.geometry.GeometryEngine. jsonToGeometry(jsonParser1); com.esri.core.geometry.MapGeometry geom2 = com.esri.core.geometry.GeometryEngine. jsonToGeometry(jsonParser2); double distance = com.esri.core.geometry.GeometryEngine.distance(geom1.getGeometry (), geom2.getGeometry(), null); NUnit.Framework.Assert.IsTrue(distance == 0); }
public virtual void testWKB2() { // JSON -> GEOM -> WKB // String strPolygon1 = // "{\"xmin\":-1.16605115291E7,\"ymin\":4925189.941699997,\"xmax\":-1.16567772126E7,\"ymax\":4928658.771399997,\"spatialReference\":{\"wkid\":102100}}"; string strPolygon1 = "{\"rings\" : [ [ [-1.16605115291E7,4925189.941699997], [-1.16567772126E7,4925189.941699997], [-1.16567772126E7,4928658.771399997], [-1.16605115291E7,4928658.771399997], [-1.16605115291E7,4925189.941699997] ] ], \"spatialReference\" : {\"wkid\" : 102100}}"; org.codehaus.jackson.JsonFactory factory = new org.codehaus.jackson.JsonFactory(); org.codehaus.jackson.JsonParser parser = factory.createJsonParser(strPolygon1); parser.nextToken(); com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Geometry geom = mapGeom.getGeometry(); // simplifying geom com.esri.core.geometry.OperatorSimplify operatorSimplify = (com.esri.core.geometry.OperatorSimplify )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type .Simplify); com.esri.core.geometry.SpatialReference sr = com.esri.core.geometry.SpatialReference .create(102100); geom = operatorSimplify.execute(geom, sr, true, null); com.esri.core.geometry.OperatorExportToWkb operatorExport = (com.esri.core.geometry.OperatorExportToWkb )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type .ExportToWkb); java.nio.ByteBuffer byteBuffer = operatorExport.execute(0, geom, null); byte[] wkb = ((byte[])byteBuffer.array()); // // checking WKB correctness // WKBReader jtsReader = new WKBReader(); // com.vividsolutions.jts.geom.Geometry jtsGeom = jtsReader.read(wkb); // System.out.println("jtsGeom = " + jtsGeom); // WKB -> GEOM -> JSON com.esri.core.geometry.OperatorImportFromWkb operatorImport = (com.esri.core.geometry.OperatorImportFromWkb )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type .ImportFromWkb); geom = operatorImport.execute(0, com.esri.core.geometry.Geometry.Type.Polygon, java.nio.ByteBuffer .wrap(wkb), null); NUnit.Framework.Assert.IsTrue(!geom.isEmpty()); }
public virtual void testWKB() { try { // JSON -> GEOM -> WKB string strPolygon1 = "{\"xmin\":-1.1663479012889031E7,\"ymin\":4919777.494405342,\"xmax\":-1.1658587043078788E7,\"ymax\":4924669.464215587,\"spatialReference\":{\"wkid\":102100}}"; // String strPolygon1 = // "{\"rings\":[[[-119.152450421001,38.4118009590513],[-119.318825070203,38.5271086243914],[-119.575687062955,38.7029101298904],[-119.889341639399,38.9222515603984],[-119.995254694357,38.9941061536377],[-119.995150114198,39.0634913594691],[-119.994541258334,39.1061318056708],[-119.995527335641,39.1587132866355],[-119.995304181493,39.3115454332125],[-119.996011479298,39.4435009764511],[-119.996165311172,39.7206108077274],[-119.996324660047,41.1775662656441],[-119.993459369715,41.9892049531992],[-119.351692186077,41.9888529749781],[-119.3109421304,41.9891353872811],[-118.185316829038,41.9966370981387],[-117.018864363596,41.9947941808341],[-116.992313337997,41.9947945094663],[-115.947544658193,41.9945994628997],[-115.024862911148,41.996506455953],[-114.269471632824,41.9959242345073],[-114.039072662345,41.9953908974688],[-114.038151248682,40.9976868405942],[-114.038108189376,40.1110466529553],[-114.039844684228,39.9087788600023],[-114.040105338584,39.5386849268845],[-114.044267501155,38.6789958815881],[-114.045090206153,38.5710950539539],[-114.047272999176,38.1376524399918],[-114.047260595159,37.5984784866001],[-114.043939384154,36.9965379371421],[-114.043716435713,36.8418489458647],[-114.037392074194,36.2160228969702],[-114.045105557286,36.1939778840226],[-114.107775185788,36.1210907070504],[-114.12902308363,36.041730493896],[-114.206768869568,36.0172554164834],[-114.233472615347,36.0183310595897],[-114.307587598189,36.0622330993643],[-114.303857056018,36.0871084040611],[-114.316095374696,36.1114380366653],[-114.344233941709,36.1374802520568],[-114.380803116644,36.1509912717765],[-114.443945697733,36.1210532841897],[-114.466613475422,36.1247112590539],[-114.530573568745,36.1550902046725],[-114.598935242024,36.1383354528834],[-114.621610747198,36.1419666834504],[-114.712761724737,36.1051810523675],[-114.728150311069,36.0859627711604],[-114.728966012834,36.0587530361083],[-114.717673567756,36.0367580437018],[-114.736212493583,35.9876483502758],[-114.699275906446,35.9116119537412],[-114.661600122152,35.8804735854242],[-114.662462095522,35.8709599070091],[-114.689867343369,35.8474424944766],[-114.682739704595,35.7647034175617],[-114.688820027649,35.7325957399896],[-114.665091345861,35.6930994107107],[-114.668486064922,35.6563989882404],[-114.654065925137,35.6465840800053],[-114.6398667219,35.6113485698329],[-114.653134321223,35.5848331056108],[-114.649792053474,35.5466373866597],[-114.672215155693,35.5157541647721],[-114.645396168451,35.4507608261463],[-114.589584275424,35.3583787306827],[-114.587889840369,35.30476812919],[-114.559583045727,35.2201828714608],[-114.561039964054,35.1743461616313],[-114.572255261053,35.1400677445931],[-114.582616239058,35.1325604694085],[-114.626440825485,35.1339067529872],[-114.6359090842,35.1186557767895],[-114.595631971944,35.0760579746697],[-114.633779872695,35.0418633504303],[-114.621068606189,34.9989144286133],[-115.626197382816,35.7956983148418],[-115.88576934392,36.0012259572723],[-117.160423771838,36.9595941441767],[-117.838686423167,37.457298239715],[-118.417419755966,37.8866767486211],[-119.152450421001,38.4118009590513]]], \"spatialReference\":{\"wkid\":4326}}"; org.codehaus.jackson.JsonFactory factory = new org.codehaus.jackson.JsonFactory(); org.codehaus.jackson.JsonParser parser = factory.createJsonParser(strPolygon1); parser.nextToken(); com.esri.core.geometry.MapGeometry mapGeom = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Geometry geom = mapGeom.getGeometry(); com.esri.core.geometry.OperatorExportToWkb operatorExport = (com.esri.core.geometry.OperatorExportToWkb )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type .ExportToWkb); java.nio.ByteBuffer byteBuffer = operatorExport.execute(0, geom, null); byte[] wkb = ((byte[])byteBuffer.array()); // WKB -> GEOM -> JSON com.esri.core.geometry.OperatorImportFromWkb operatorImport = (com.esri.core.geometry.OperatorImportFromWkb )com.esri.core.geometry.OperatorFactoryLocal.getInstance().getOperator(com.esri.core.geometry.Operator.Type .ImportFromWkb); geom = operatorImport.execute(0, com.esri.core.geometry.Geometry.Type.Polygon, java.nio.ByteBuffer .wrap(wkb), null); // geom = operatorImport.execute(0, Geometry.Type.Polygon, // byteBuffer); string outputPolygon1 = com.esri.core.geometry.GeometryEngine.geometryToJson(-1, geom); } catch (org.codehaus.jackson.JsonParseException) { } catch (System.IO.IOException) { } }
internal static void showProjectedGeometryInfo(com.esri.core.geometry.MapGeometry mapGeom) { return; }
/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testPoint() { bool bAnswer = true; com.esri.core.geometry.Point point1 = new com.esri.core.geometry.Point(10.0, 20.0 ); com.esri.core.geometry.Point pointEmpty = new com.esri.core.geometry.Point(); { org.codehaus.jackson.JsonParser pointWebMerc1Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine .geometryToJson(spatialReferenceWebMerc1, point1)); com.esri.core.geometry.MapGeometry pointWebMerc1MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(pointWebMerc1Parser); NUnit.Framework.Assert.IsTrue(point1.getX() == ((com.esri.core.geometry.Point)pointWebMerc1MP .getGeometry()).getX()); NUnit.Framework.Assert.IsTrue(point1.getY() == ((com.esri.core.geometry.Point)pointWebMerc1MP .getGeometry()).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWebMerc1.getID() == pointWebMerc1MP .getSpatialReference().getID() || pointWebMerc1MP.getSpatialReference().getID() == 3857); if (!checkResultSpatialRef(pointWebMerc1MP, 102100, 3857)) { bAnswer = false; } pointWebMerc1Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine .geometryToJson(null, point1)); pointWebMerc1MP = com.esri.core.geometry.GeometryEngine.jsonToGeometry(pointWebMerc1Parser ); NUnit.Framework.Assert.IsTrue(null == pointWebMerc1MP.getSpatialReference()); if (pointWebMerc1MP.getSpatialReference() != null) { if (!checkResultSpatialRef(pointWebMerc1MP, 102100, 3857)) { bAnswer = false; } } string pointEmptyString = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , pointEmpty); pointWebMerc1Parser = factory.createJsonParser(pointEmptyString); } org.codehaus.jackson.JsonParser pointWebMerc2Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine .geometryToJson(spatialReferenceWebMerc2, point1)); com.esri.core.geometry.MapGeometry pointWebMerc2MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(pointWebMerc2Parser); NUnit.Framework.Assert.IsTrue(point1.getX() == ((com.esri.core.geometry.Point)pointWebMerc2MP .getGeometry()).getX()); NUnit.Framework.Assert.IsTrue(point1.getY() == ((com.esri.core.geometry.Point)pointWebMerc2MP .getGeometry()).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWebMerc2.getLatestID() == pointWebMerc2MP .getSpatialReference().getLatestID()); if (!checkResultSpatialRef(pointWebMerc2MP, spatialReferenceWebMerc2.getLatestID( ), 0)) { bAnswer = false; } { org.codehaus.jackson.JsonParser pointWgs84Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine .geometryToJson(spatialReferenceWGS84, point1)); com.esri.core.geometry.MapGeometry pointWgs84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(pointWgs84Parser); NUnit.Framework.Assert.IsTrue(point1.getX() == ((com.esri.core.geometry.Point)pointWgs84MP .getGeometry()).getX()); NUnit.Framework.Assert.IsTrue(point1.getY() == ((com.esri.core.geometry.Point)pointWgs84MP .getGeometry()).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == pointWgs84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(pointWgs84MP, 4326, 0)) { bAnswer = false; } } { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"x\":null,\"y\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"x\":null,\"y\":null,\"z\":null,\"m\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { com.esri.core.geometry.Point p = new com.esri.core.geometry.Point(10.0, 20.0, 30.0 ); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"x\":10,\"y\":20,\"z\":30,\"m\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { // import string s = "{\"x\":0.0,\"y\":1.0,\"z\":5.0,\"m\":11.0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"; org.codehaus.jackson.JsonParser parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry map_pt = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Point pt = (com.esri.core.geometry.Point)map_pt.getGeometry (); NUnit.Framework.Assert.IsTrue(pt.getX() == 0.0); NUnit.Framework.Assert.IsTrue(pt.getY() == 1.0); NUnit.Framework.Assert.IsTrue(pt.getZ() == 5.0); NUnit.Framework.Assert.IsTrue(pt.getM() == 11.0); } { string s = "{\"x\" : 5.0, \"y\" : null, \"spatialReference\" : {\"wkid\" : 4326}} "; org.codehaus.jackson.JsonParser parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry map_pt = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Point pt = (com.esri.core.geometry.Point)map_pt.getGeometry (); NUnit.Framework.Assert.IsTrue(pt.isEmpty()); com.esri.core.geometry.SpatialReference spatial_reference = map_pt.getSpatialReference (); NUnit.Framework.Assert.IsTrue(spatial_reference.getID() == 4326); } return(bAnswer); }
/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testEnvelope() { bool bAnswer = true; com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope(); envelope.setCoords(-109.55, 25.76, -86.39, 49.94); { org.codehaus.jackson.JsonParser envelopeWGS84Parser = factory.createJsonParser(com.esri.core.geometry.GeometryEngine .geometryToJson(spatialReferenceWGS84, envelope)); com.esri.core.geometry.MapGeometry envelopeWGS84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(envelopeWGS84Parser); NUnit.Framework.Assert.IsTrue(envelope.isEmpty() == envelopeWGS84MP.getGeometry() .isEmpty()); NUnit.Framework.Assert.IsTrue(envelope.getXMax() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getXMax()); NUnit.Framework.Assert.IsTrue(envelope.getYMax() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getYMax()); NUnit.Framework.Assert.IsTrue(envelope.getXMin() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getXMin()); NUnit.Framework.Assert.IsTrue(envelope.getYMin() == ((com.esri.core.geometry.Envelope )envelopeWGS84MP.getGeometry()).getYMin()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == envelopeWGS84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(envelopeWGS84MP, 4326, 0)) { bAnswer = false; } } { // export com.esri.core.geometry.Envelope e = new com.esri.core.geometry.Envelope(); e.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); e.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , e); NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":null,\"ymin\":null,\"xmax\":null,\"ymax\":null,\"zmin\":null,\"zmax\":null,\"mmin\":null,\"mmax\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); e.setCoords(0, 1, 2, 3); com.esri.core.geometry.Envelope1D z = new com.esri.core.geometry.Envelope1D(); com.esri.core.geometry.Envelope1D m = new com.esri.core.geometry.Envelope1D(); z.setCoords(5, 7); m.setCoords(11, 13); e.setInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, z); e.setInterval(com.esri.core.geometry.VertexDescription.Semantics.M, 0, m); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , e); NUnit.Framework.Assert.IsTrue(s.Equals("{\"xmin\":0,\"ymin\":1,\"xmax\":2,\"ymax\":3,\"zmin\":5,\"zmax\":7,\"mmin\":11,\"mmax\":13,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { // import string s = "{\"xmin\":0.0,\"ymin\":1.0,\"xmax\":2.0,\"ymax\":3.0,\"zmin\":5.0,\"zmax\":7.0,\"mmin\":11.0,\"mmax\":13.0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"; org.codehaus.jackson.JsonParser parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry map_env = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Envelope env = (com.esri.core.geometry.Envelope)map_env.getGeometry (); com.esri.core.geometry.Envelope1D z = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .Z, 0); com.esri.core.geometry.Envelope1D m = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics .M, 0); NUnit.Framework.Assert.IsTrue(z.vmin == 5.0); NUnit.Framework.Assert.IsTrue(z.vmax == 7.0); NUnit.Framework.Assert.IsTrue(m.vmin == 11.0); NUnit.Framework.Assert.IsTrue(m.vmax == 13.0); } { string s = "{ \"zmin\" : 33, \"xmin\" : -109.55, \"zmax\" : 53, \"ymin\" : 25.76, \"xmax\" : -86.39, \"ymax\" : 49.94, \"mmax\" : 13}"; org.codehaus.jackson.JsonParser parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry map_env = com.esri.core.geometry.GeometryEngine .jsonToGeometry(parser); com.esri.core.geometry.Envelope env = (com.esri.core.geometry.Envelope)map_env.getGeometry (); com.esri.core.geometry.Envelope2D e = new com.esri.core.geometry.Envelope2D(); env.queryEnvelope2D(e); NUnit.Framework.Assert.IsTrue(e.xmin == -109.55 && e.ymin == 25.76 && e.xmax == - 86.39 && e.ymax == 49.94); com.esri.core.geometry.Envelope1D e1D; NUnit.Framework.Assert.IsTrue(env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); e1D = env.queryInterval(com.esri.core.geometry.VertexDescription.Semantics.Z, 0); NUnit.Framework.Assert.IsTrue(e1D.vmin == 33 && e1D.vmax == 53); NUnit.Framework.Assert.IsTrue(!env.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); } return(bAnswer); }
/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testPolygon() { bool bAnswer = true; com.esri.core.geometry.Polygon polygon = new com.esri.core.geometry.Polygon(); polygon.startPath(-97.06138, 32.837); polygon.lineTo(-97.06133, 32.836); polygon.lineTo(-97.06124, 32.834); polygon.lineTo(-97.06127, 32.832); polygon.startPath(-97.06326, 32.759); polygon.lineTo(-97.06298, 32.755); { org.codehaus.jackson.JsonParser polygonPathsWgs84Parser = factory.createJsonParser (com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWGS84, polygon )); com.esri.core.geometry.MapGeometry mPolygonWGS84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(polygonPathsWgs84Parser); NUnit.Framework.Assert.IsTrue(polygon.getPointCount() + 1 == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getPointCount()); NUnit.Framework.Assert.IsTrue(polygon.getPoint(0).getX() == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getPoint(0).getX()); NUnit.Framework.Assert.IsTrue(polygon.getPoint(0).getY() == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getPoint(0).getY()); NUnit.Framework.Assert.IsTrue(polygon.getPathCount() == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getPathCount()); NUnit.Framework.Assert.IsTrue(polygon.getSegmentCount() + 1 == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getSegmentCount()); NUnit.Framework.Assert.IsTrue(polygon.getSegmentCount(0) == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getSegmentCount(0)); NUnit.Framework.Assert.IsTrue(polygon.getSegmentCount(1) + 1 == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getSegmentCount(1)); int lastIndex = polygon.getPointCount() - 1; NUnit.Framework.Assert.IsTrue(polygon.getPoint(lastIndex).getX() == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getPoint(lastIndex).getX()); NUnit.Framework.Assert.IsTrue(polygon.getPoint(lastIndex).getY() == ((com.esri.core.geometry.Polygon )mPolygonWGS84MP.getGeometry()).getPoint(lastIndex).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == mPolygonWGS84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(mPolygonWGS84MP, 4326, 0)) { bAnswer = false; } } { com.esri.core.geometry.Polygon p = new com.esri.core.geometry.Polygon(); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"rings\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); p.startPath(0, 0); p.lineTo(0, 1); p.lineTo(4, 4); p.startPath(2, 2); p.lineTo(3, 3); p.lineTo(7, 8); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 7); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 2, 0, 5); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 5, 0, 5); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"rings\":[[[0,0,3,null],[0,1,0,7],[4,4,0,5],[0,0,3,null]],[[2,2,0,null],[3,3,0,null],[7,8,0,5],[2,2,0,null]]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { // Test Import Polygon from Polygon string rings = "{\"hasZ\": true, \"rings\" : [ [ [0,0, 5], [0.0, 10.0, 5], [10.0,10.0, 5, 66666], [10.0,0.0, 5] ], [ [12, 12] ], [ [13 , 17], [13 , 17] ], [ [1.0, 1.0, 5, 66666], [9.0,1.0, 5], [9.0,9.0, 5], [1.0,9.0, 5], [1.0, 1.0, 5] ] ] }"; com.esri.core.geometry.MapGeometry mapGeometry = com.esri.core.geometry.GeometryEngine .jsonToGeometry(factory.createJsonParser(rings)); com.esri.core.geometry.Polygon p = (com.esri.core.geometry.Polygon)mapGeometry.getGeometry (); double area = p.calculateArea2D(); double length = p.calculateLength2D(); NUnit.Framework.Assert.IsTrue(p.getPathCount() == 4); int count = p.getPointCount(); NUnit.Framework.Assert.IsTrue(count == 15); NUnit.Framework.Assert.IsTrue(p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(!p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); } return(bAnswer); }
/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testPolyline() { bool bAnswer = true; com.esri.core.geometry.Polyline polyline = new com.esri.core.geometry.Polyline(); polyline.startPath(-97.06138, 32.837); polyline.lineTo(-97.06133, 32.836); polyline.lineTo(-97.06124, 32.834); polyline.lineTo(-97.06127, 32.832); polyline.startPath(-97.06326, 32.759); polyline.lineTo(-97.06298, 32.755); { org.codehaus.jackson.JsonParser polylinePathsWgs84Parser = factory.createJsonParser (com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWGS84, polyline )); com.esri.core.geometry.MapGeometry mPolylineWGS84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(polylinePathsWgs84Parser); NUnit.Framework.Assert.IsTrue(polyline.getPointCount() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPointCount()); NUnit.Framework.Assert.IsTrue(polyline.getPoint(0).getX() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(0).getX()); NUnit.Framework.Assert.IsTrue(polyline.getPoint(0).getY() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(0).getY()); NUnit.Framework.Assert.IsTrue(polyline.getPathCount() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPathCount()); NUnit.Framework.Assert.IsTrue(polyline.getSegmentCount() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getSegmentCount()); NUnit.Framework.Assert.IsTrue(polyline.getSegmentCount(0) == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getSegmentCount(0)); NUnit.Framework.Assert.IsTrue(polyline.getSegmentCount(1) == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getSegmentCount(1)); int lastIndex = polyline.getPointCount() - 1; NUnit.Framework.Assert.IsTrue(polyline.getPoint(lastIndex).getX() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(lastIndex).getX()); NUnit.Framework.Assert.IsTrue(polyline.getPoint(lastIndex).getY() == ((com.esri.core.geometry.Polyline )mPolylineWGS84MP.getGeometry()).getPoint(lastIndex).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == mPolylineWGS84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(mPolylineWGS84MP, 4326, 0)) { bAnswer = false; } } { com.esri.core.geometry.Polyline p = new com.esri.core.geometry.Polyline(); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"paths\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); p.startPath(0, 0); p.lineTo(0, 1); p.startPath(2, 2); p.lineTo(3, 3); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z, 0, 0, 3); p.setAttribute(com.esri.core.geometry.VertexDescription.Semantics.M, 1, 0, 5); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"paths\":[[[0,0,3,null],[0,1,0,5]],[[2,2,0,null],[3,3,0,null]]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { string paths = "{\"hasZ\" : true, \"paths\" : [ [ [0.0, 0.0,3], [0, 10.0,3], [10.0, 10.0,3, 6666], [10.0, 0.0,3, 6666] ], [ [1.0, 1,3], [1.0, 9.0,3], [9.0, 9.0,3], [1.0, 9.0,3] ] ], \"spatialReference\" : {\"wkid\" : 4326}, \"hasM\" : false}"; com.esri.core.geometry.MapGeometry mapGeometry = com.esri.core.geometry.GeometryEngine .jsonToGeometry(factory.createJsonParser(paths)); com.esri.core.geometry.Polyline p = (com.esri.core.geometry.Polyline)mapGeometry. getGeometry(); NUnit.Framework.Assert.IsTrue(p.getPathCount() == 2); int count = p.getPathCount(); NUnit.Framework.Assert.IsTrue(p.getPointCount() == 8); NUnit.Framework.Assert.IsTrue(p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(!p.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); double z = p.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0); NUnit.Framework.Assert.IsTrue(z == 3); double length = p.calculateLength2D(); NUnit.Framework.Assert.IsTrue(System.Math.abs(length - 54.0) <= 0.001); com.esri.core.geometry.SpatialReference spatial_reference = mapGeometry.getSpatialReference (); NUnit.Framework.Assert.IsTrue(spatial_reference.getID() == 4326); } return(bAnswer); }
/// <exception cref="org.codehaus.jackson.JsonParseException"/> /// <exception cref="System.IO.IOException"/> internal virtual bool testMultiPoint() { bool bAnswer = true; com.esri.core.geometry.MultiPoint multiPoint1 = new com.esri.core.geometry.MultiPoint (); multiPoint1.add(-97.06138, 32.837); multiPoint1.add(-97.06133, 32.836); multiPoint1.add(-97.06124, 32.834); multiPoint1.add(-97.06127, 32.832); { string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWGS84 , multiPoint1); org.codehaus.jackson.JsonParser mPointWgs84Parser = factory.createJsonParser(s); com.esri.core.geometry.MapGeometry mPointWgs84MP = com.esri.core.geometry.GeometryEngine .jsonToGeometry(mPointWgs84Parser); NUnit.Framework.Assert.IsTrue(multiPoint1.getPointCount() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPointCount()); NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(0).getX() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(0).getX()); NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(0).getY() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(0).getY()); int lastIndex = multiPoint1.getPointCount() - 1; NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(lastIndex).getX() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(lastIndex).getX()); NUnit.Framework.Assert.IsTrue(multiPoint1.getPoint(lastIndex).getY() == ((com.esri.core.geometry.MultiPoint )mPointWgs84MP.getGeometry()).getPoint(lastIndex).getY()); NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.getID() == mPointWgs84MP.getSpatialReference ().getID()); if (!checkResultSpatialRef(mPointWgs84MP, 4326, 0)) { bAnswer = false; } } { com.esri.core.geometry.MultiPoint p = new com.esri.core.geometry.MultiPoint(); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.Z); p.addAttribute(com.esri.core.geometry.VertexDescription.Semantics.M); string s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"points\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); p.add(10.0, 20.0, 30.0); p.add(20.0, 40.0, 60.0); s = com.esri.core.geometry.GeometryEngine.geometryToJson(spatialReferenceWebMerc1 , p); NUnit.Framework.Assert.IsTrue(s.Equals("{\"hasZ\":true,\"hasM\":true,\"points\":[[10,20,30,null],[20,40,60,null]],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}" )); } { string points = "{\"hasM\" : false, \"hasZ\" : true, \"uncle remus\" : null, \"points\" : [ [0,0,1], [0.0,10.0,1], [10.0,10.0,1], [10.0,0.0,1, 6666] ],\"spatialReference\" : {\"wkid\" : 4326}}"; com.esri.core.geometry.MapGeometry mp = com.esri.core.geometry.GeometryEngine.jsonToGeometry (factory.createJsonParser(points)); com.esri.core.geometry.MultiPoint multipoint = (com.esri.core.geometry.MultiPoint )mp.getGeometry(); NUnit.Framework.Assert.IsTrue(multipoint.getPointCount() == 4); com.esri.core.geometry.Point2D point2d; point2d = multipoint.getXY(0); NUnit.Framework.Assert.IsTrue(point2d.x == 0.0 && point2d.y == 0.0); point2d = multipoint.getXY(1); NUnit.Framework.Assert.IsTrue(point2d.x == 0.0 && point2d.y == 10.0); point2d = multipoint.getXY(2); NUnit.Framework.Assert.IsTrue(point2d.x == 10.0 && point2d.y == 10.0); point2d = multipoint.getXY(3); NUnit.Framework.Assert.IsTrue(point2d.x == 10.0 && point2d.y == 0.0); NUnit.Framework.Assert.IsTrue(multipoint.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .Z)); NUnit.Framework.Assert.IsTrue(!multipoint.hasAttribute(com.esri.core.geometry.VertexDescription.Semantics .M)); double z = multipoint.getAttributeAsDbl(com.esri.core.geometry.VertexDescription.Semantics .Z, 0, 0); NUnit.Framework.Assert.IsTrue(z == 1); com.esri.core.geometry.SpatialReference spatial_reference = mp.getSpatialReference (); NUnit.Framework.Assert.IsTrue(spatial_reference.getID() == 4326); } return(bAnswer); }