Java Code Examples for com.esri.core.geometry.MapGeometry#getGeometry()

The following examples show how to use com.esri.core.geometry.MapGeometry#getGeometry() . 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: QueryReportProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private com.esri.core.geometry.Geometry constructGeometry(com.esri.ges.spatial.Geometry geo) throws Exception
{
	try{
		String jsonIn = geo.toJson();
		JsonFactory jf = new JsonFactory();
		JsonParser jp = jf.createJsonParser(jsonIn);
		MapGeometry mgeo = GeometryEngine.jsonToGeometry(jp);
		com.esri.core.geometry.Geometry geoIn= mgeo.getGeometry();
		return GeometryEngine.project(geoIn, srIn, srBuffer);
	}
	catch(Exception e)
	{
		LOG.error(e.getMessage());
		LOG.error(e.getStackTrace());
		throw(e);
	}
}
 
Example 2
Source File: TrackIdleProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
private boolean hasGeometryMoved(MapGeometry geom1, MapGeometry geom2,
		double tolerance) {
	if (geom1 != null && geom1.getGeometry() != null
			&& geom1.getGeometry().getType() == Type.Point && geom2 != null
			&& geom2.getGeometry() != null
			&& geom2.getGeometry().getType() == Type.Point) {
		Point corePt1 = (Point) geom1.getGeometry();
		Point corePt2 = (Point) geom2.getGeometry();
		double meters = 0.0;
		try {
			meters = GeometryEngine.geodesicDistanceOnWGS84(corePt1,
					corePt2);
		} catch (Throwable error) {
			LOGGER.error(error.getMessage());
		}

		double feet = meter2feet(meters);
		if (feet >= tolerance)
			return true;
		else
			return false;
	} else {
		throw new RuntimeException(
				LOGGER.translate("INVALID_GEOMETRY_TYPE"));
	}
}
 
Example 3
Source File: BufferProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
@Override
public GeoEvent process(GeoEvent ge) throws Exception {
	// Operation phase...
	if (radius == null) {
		radius = (Double) ge.getField(bufferEventFld);
		if (radius == null) {
			Exception e = new Exception("Radius is not defined in geoevent");
			throw (e);
		}
	}
	MapGeometry mapGeo = ge.getGeometry();
	Point eventGeo = (Point) mapGeo.getGeometry();
	double x = eventGeo.getX();
	double y = eventGeo.getY();
	int inwkid = mapGeo.getSpatialReference().getID();
	//int inwkid = eventGeo.getSpatialReference().getWkid();
	Geometry buffer = constructBuffer(x, y, radius,
			units, inwkid, bufferwkid, outwkid);
	
	SpatialReference srOut = SpatialReference.create(outwkid);
	MapGeometry outMapGeo = new MapGeometry(buffer, srOut);
	ge.setGeometry(outMapGeo);
	return ge;
}
 
Example 4
Source File: VisibilityProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
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 5
Source File: QueryReportProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Geometry constructGeometry(MapGeometry geo) throws Exception
{
	try{
		
		Geometry geoIn= geo.getGeometry();
		return GeometryEngine.project(geoIn, srIn, srBuffer);
	}
	catch(Exception e)
	{
		LOG.error(e.getMessage());
		LOG.error(e.getStackTrace());
		throw(e);
	}
}
 
Example 6
Source File: EllipseProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
@Override
public GeoEvent process(GeoEvent ge) throws Exception {
	
	if(!ge.getGeoEventDefinition().getTagNames().contains("GEOMETRY"))
	{
		return null;
	}
	inwkid = ge.getGeometry().getSpatialReference().getID();
	if(majAxisSource.equals("Event"))
	{
		majorAxisRadius = (Double)ge.getField(majorAxisField);
	}
	if(minAxisSource.equals("Event"))
	{
		minorAxisRadius = (Double)ge.getField(minorAxisField);
	}
	if(rotSource.equals("Event"))
	{
		rotation=(Double)ge.getField(rotationField);
	}
	
	MapGeometry mapGeo = ge.getGeometry();
	Geometry geo = mapGeo.getGeometry();
	if(!(geo instanceof Point))
	{
		return null;
	}
	Point eventGeo = (Point)geo;
	double x = eventGeo.getX();
	double y = eventGeo.getY();
	double rdeg = GeometryUtility.Geo2Arithmetic(rotation);
	double r = Math.toRadians(rdeg);
	MapGeometry ellipse = constructEllipse(x, y, majorAxisRadius, minorAxisRadius, r, inwkid, procwkid, outwkid);
	ge.setGeometry(ellipse);
	return ge;
}
 
Example 7
Source File: VisibilityProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
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 8
Source File: Polygon2PtProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
@Override
public GeoEvent process(GeoEvent ge) throws Exception {
	
	MapGeometry mapGeo = ge.getGeometry();
	Geometry geo = mapGeo.getGeometry();
	if(geo.getType()!=Geometry.Type.Polygon)
		return null;
	Point center = GeometryUtility.CenterOfMass((Polygon)geo);
	MapGeometry outMapGeo = new MapGeometry(center, mapGeo.getSpatialReference());
	ge.setGeometry(outMapGeo);
	return ge;
}
 
Example 9
Source File: SpatialQProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Geometry constructGeometry(MapGeometry geo) throws Exception {
	try {

		Geometry geoIn = geo.getGeometry();
		return GeometryEngine.project(geoIn, srIn, srBuffer);
	} catch (Exception e) {
		LOG.error(e.getMessage());
		LOG.error(e.getStackTrace());
		throw (e);
	}
}
 
Example 10
Source File: MainActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a geojson string to com.esri.core.geometry.Point.
 *
 * @param jsonPoint geoJson string representation of a Point
 * @return com.esri.core.geometry.Point
 * @throws Exception
 */
static Point createPointFromGeoJson(String jsonPoint) throws Exception {

    MapGeometry mapGeom = OperatorImportFromGeoJson.local().execute(GeoJsonImportFlags.geoJsonImportDefaults,
            Geometry.Type.Point,
            jsonPoint,
            null);

    return (Point) mapGeom.getGeometry();
}
 
Example 11
Source File: MGRSProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
@Override
public GeoEvent process(GeoEvent evt) throws Exception {
	MapGeometry mapGeo = (MapGeometry) evt.getField(geofld);
	Geometry geo = mapGeo.getGeometry();
	int wkid = mapGeo.getSpatialReference().getID();
	if(wkid != 4326)
	{
		return null;
	}
	if(geo.getType() != Geometry.Type.Point)
	{
		return null;
	}
	Point pt = (Point)geo;
	double[] coords = {pt.getX(), pt.getY()};
	PeGeogcs pegeocs = PeFactory.geogcs(4326);
	String[] mgrsvals = new String[1];
	PeNotationMgrs.geog_to_mgrs(pegeocs, 1, coords, accuracy, false, mgrsvals);
	String mgrs = mgrsvals[0];
	//LL ll = new LL(pt.getX(), pt.getY());
	//ll.setAccuracy(accuracy);
	
	//MGRS2LatLongConverter converter = new MGRS2LatLongConverter();
	//String mgrs = converter.LL2MRGS(ll);
	GeoEventDefinition edOut;
	GeoEventDefinition geoDef = evt.getGeoEventDefinition();
	if((edOut=manager.searchGeoEventDefinition(newdef, getId()))==null)
	{
		edOut = geoDef.augment(fds);
		edOut.setOwner(getId());
		edOut.setName(newdef);
		manager.addGeoEventDefinition(edOut);
	}
	GeoEventCreator  geoEventCreator = messaging.createGeoEventCreator();
	GeoEvent geOut = geoEventCreator.create(edOut.getGuid(), new Object[] {
		evt.getAllFields(), mgrs });
	geOut.setProperty(GeoEventPropertyName.TYPE, "message");
	geOut.setProperty(GeoEventPropertyName.OWNER_ID, getId());
	geOut.setProperty(GeoEventPropertyName.OWNER_ID, definition.getUri());
	return geOut;
}