Java Code Examples for com.esri.core.geometry.GeometryEngine#geometryToJson()
The following examples show how to use
com.esri.core.geometry.GeometryEngine#geometryToJson() .
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: BufferProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private com.esri.ges.spatial.Geometry constructBuffer(double x, double y, double radius, String units, int wkidin, int wkidbuffer, int wkidout) throws GeometryException { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); UnitConverter uc = new UnitConverter(); String c_name = uc.findConnonicalName(units); int unitout = uc.findWkid(c_name); Unit u = new LinearUnit(unitout); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); Geometry buffer = GeometryEngine.buffer(centerProj, srBuffer, radius, u); Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, bufferout); return spatial.fromJson(json); }
Example 2
Source File: ST_AsJson.java From spatial-framework-for-hadoop with Apache License 2.0 | 6 votes |
public Text evaluate(BytesWritable geomref){ if (geomref == null || geomref.getLength() == 0){ LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } Geometry esriGeom = ogcGeometry.getEsriGeometry(); int wkid = GeometryUtils.getWKID(geomref); return new Text(GeometryEngine.geometryToJson(wkid, esriGeom)); }
Example 3
Source File: EllipseProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private com.esri.ges.spatial.Geometry constructEllipse(double x, double y, double majorAxis, double minorAxis, double rotation, int wkidin, int wkidbuffer, int wkidout) throws GeometryException { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); GeometryUtility geoutil = new GeometryUtility(); Polygon ellipse = geoutil.GenerateEllipse(centerProj, majorAxis, minorAxis, rotation); Geometry ellipseOut = GeometryEngine.project(ellipse, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, ellipseOut); return spatial.fromJson(json); }
Example 4
Source File: QueryReportProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private com.esri.ges.spatial.Geometry constructGeometryFromString(String geoString) throws GeometryException { String[] pairs = geoString.split(" "); Polygon polygon = new Polygon(); Boolean firstit = true; for(String coords: pairs) { String[] tuple = coords.split(","); Double x = Double.parseDouble(tuple[0]); Double y = Double.parseDouble(tuple[1]); Point p = new Point(x,y); Double z = Double.NaN; if (tuple.length>2) { z = Double.parseDouble(tuple[2]); p.setZ(z); } if(firstit) { polygon.startPath(p); firstit=false; } else { polygon.lineTo(p); } } polygon.closeAllPaths(); String json = GeometryEngine.geometryToJson(srIn, polygon); return spatial.fromJson(json); }
Example 5
Source File: QueryReportProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private com.esri.ges.spatial.Geometry constructBuffer(Geometry geo, double radius, Unit u) throws GeometryException, JsonParseException, IOException { com.esri.core.geometry.Geometry buffer = GeometryEngine.buffer(inGeometry, srBuffer, radius, u); com.esri.core.geometry.Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, bufferout); return spatial.fromJson(json); }
Example 6
Source File: PolygonProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private com.esri.ges.spatial.Geometry constructCAPGeometry(String geoString) throws GeometryException { try { String[] pairs = geoString.split(" "); Polygon polygon = new Polygon(); Boolean firstit = true; for (String coords : pairs) { String[] tuple = coords.split(","); Double x = Double.parseDouble(tuple[0]); Double y = Double.parseDouble(tuple[1]); Point p = new Point(x, y); Double z = Double.NaN; if (tuple.length > 2) { z = Double.parseDouble(tuple[2]); p.setZ(z); } if (firstit) { polygon.startPath(p); firstit = false; } else { polygon.lineTo(p); } } polygon.closeAllPaths(); String json = GeometryEngine.geometryToJson(srIn, polygon); return spatial.fromJson(json); } catch (GeometryException ex) { LOG.error(ex.getMessage()); LOG.error(ex.getStackTrace()); return null; } }
Example 7
Source File: VisibilityProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private String ConstructJsonMaskFromGeoEvent(GeoEvent ge) throws IOException { com.esri.ges.spatial.Geometry eventgeo = ge.getGeometry(); String json = eventgeo.toJson(); JsonFactory jf = new JsonFactory(); JsonParser jp = jf.createJsonParser(json); MapGeometry mgeo = GeometryEngine.jsonToGeometry(jp); Geometry geo = mgeo.getGeometry(); Geometry maskGeo = GeometryEngine.project(geo, srIn, srBuffer); return GeometryEngine.geometryToJson(srBuffer, maskGeo); }
Example 8
Source File: VisibilityProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
private String ConstructJsonMaskFromGeoEvent(GeoEvent ge) throws IOException { MapGeometry eventgeo = ge.getGeometry(); Geometry geo = eventgeo.getGeometry(); Geometry maskGeo = GeometryEngine.project(geo, srIn, srBuffer); return GeometryEngine.geometryToJson(srBuffer, maskGeo); }
Example 9
Source File: OGCGeometry.java From geometry-api-java with Apache License 2.0 | 2 votes |
/** * * @return Convert to REST JSON. */ public String asJson() { return GeometryEngine.geometryToJson(esriSR, getEsriGeometry()); }