Java Code Examples for com.esri.core.geometry.ogc.OGCGeometry#fromJson()
The following examples show how to use
com.esri.core.geometry.ogc.OGCGeometry#fromJson() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ST_GeomFromJson.java From spatial-framework-for-hadoop with Apache License 2.0 | 6 votes |
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { DeferredObject jsonDeferredObject = arguments[0]; String json = null; if (jsonOI.getCategory() == Category.STRUCT){ //StructObjectInspector structOI = (StructObjectInspector)jsonOI; // TODO support structs } else { PrimitiveObjectInspector primOI = (PrimitiveObjectInspector)jsonOI; json = (String)primOI.getPrimitiveJavaObject(jsonDeferredObject.get()); } try { OGCGeometry ogcGeom = OGCGeometry.fromJson(json); return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom); } catch (Exception e) { } return null; }
Example 2
Source File: TestOGC.java From geometry-api-java with Apache License 2.0 | 6 votes |
@Test public void testPolylineSimplifyIssueGithub52() throws Exception { String json = "{\"paths\":[[[2,0],[4,3],[5,1],[3.25,1.875],[1,3]]],\"spatialReference\":{\"wkid\":4326}}"; { OGCGeometry g = OGCGeometry.fromJson(json); assertTrue(g.geometryType().equals("LineString")); OGCGeometry simpleG = g.makeSimple();//make ogc simple assertTrue(simpleG.geometryType().equals("MultiLineString")); assertTrue(simpleG.isSimpleRelaxed());//geodatabase simple assertTrue(simpleG.isSimple());//ogc simple OGCMultiLineString mls =(OGCMultiLineString)simpleG; assertTrue(mls.numGeometries() == 4); OGCGeometry baseGeom = OGCGeometry.fromJson("{\"paths\":[[[2,0],[3.25,1.875]],[[3.25,1.875],[4,3],[5,1]],[[5,1],[3.25,1.875]],[[3.25,1.875],[1,3]]],\"spatialReference\":{\"wkid\":4326}}"); assertTrue(simpleG.equals(baseGeom)); } }
Example 3
Source File: TestOGC.java From geometry-api-java with Apache License 2.0 | 5 votes |
@Test public void testIsectTriaJson1() throws Exception { String json1 = "{\"rings\":[[[1, 0], [3, 0], [1, 2], [1, 0]]], \"spatialReference\":{\"wkid\":4326}}"; String json2 = "{\"rings\":[[[0, 1], [2, 1], [0, 3], [0, 1]]], \"spatialReference\":{\"wkid\":4326}}"; OGCGeometry g0 = OGCGeometry.fromJson(json1); OGCGeometry g1 = OGCGeometry.fromJson(json2); OGCGeometry rslt = g0.intersection(g1); assertTrue(rslt != null); assertTrue(rslt.geometryType().equals("Polygon")); assertTrue(rslt.esriSR.getID() == 4326); String s = GeometryEngine.geometryToJson(rslt.getEsriSpatialReference().getID(), rslt.getEsriGeometry()); }