Java Code Examples for com.esri.core.geometry.Point#getX()

The following examples show how to use com.esri.core.geometry.Point#getX() . 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: RangeFanProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Geometry constructRangeFan(double x, double y, double range,
		String unit, double bearing, double traversal) throws Exception {
	try {
		Polygon fan = new Polygon();
		Point center = new Point();
		center.setX(x);
		center.setY(y);

		Point centerProj = (Point) GeometryEngine.project(center, srIn,
				srBuffer);

		double centerX = centerProj.getX();
		double centerY = centerProj.getY();
		bearing = GeometryUtility.Geo2Arithmetic(bearing);
		double leftAngle = bearing - (traversal / 2);
		double rightAngle = bearing + (traversal / 2);
		int count = (int) Math.round(Math.abs(leftAngle - rightAngle));
		fan.startPath(centerProj);
		UnitConverter uc = new UnitConverter();
		range = uc.Convert(range, unit, srBuffer);
		for (int i = 0; i < count; ++i) {
			double d = Math.toRadians(leftAngle + i);
			double arcX = centerX + (range * Math.cos(d));
			double arcY = centerY + (range * Math.sin(d));
			Point arcPt = new Point(arcX, arcY);
			fan.lineTo(arcPt);
		}
		fan.closeAllPaths();
		return fan;
	} catch (Exception e) {
		LOG.error(e.getMessage());
		throw e;
	}
}
 
Example 2
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 3
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 4
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 5
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Point ellipsePtFromAngle(Point center, double rh, double rv, double angle)
{
	double x = center.getX();
	double y = center.getY();
	double c = Math.cos(angle);
	double s = Math.sin(angle);
	double ta = s/c;
	double tt = ta * (rh/rv);
	double d = 1.0 / Math.sqrt(1.0 + Math.pow(tt, 2));
	double ex = x + Math.copySign(rh*d, c);
	double ey = y + Math.copySign(rv * tt * d, s);
	return new Point(ex,ey);
	
}
 
Example 6
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 7
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 8
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
private static Point computePointsCentroid(MultiVertexGeometry multiVertex)
{
    double xSum = 0;
    double ySum = 0;
    for (int i = 0; i < multiVertex.getPointCount(); i++) {
        Point point = multiVertex.getPoint(i);
        xSum += point.getX();
        ySum += point.getY();
    }
    return new Point(xSum / multiVertex.getPointCount(), ySum / multiVertex.getPointCount());
}
 
Example 9
Source File: Geography.java    From barefoot with Apache License 2.0 5 votes vote down vote up
@Override
public double intercept(Point a, Point b, Point c) {

    if (a.getX() == b.getX() && a.getY() == b.getY()) {
        return 0;
    }
    Intercept inter = new Intercept(Geodesic.WGS84);
    GeodesicData ci =
            inter.intercept(a.getY(), a.getX(), b.getY(), b.getX(), c.getY(), c.getX());
    GeodesicData ai = Geodesic.WGS84.Inverse(a.getY(), a.getX(), ci.lat2, ci.lon2);
    GeodesicData ab = Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX());

    return (Math.abs(ai.azi1 - ab.azi1) < 1) ? ai.s12 / ab.s12 : (-1) * ai.s12 / ab.s12;
}
 
Example 10
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 11
Source File: RangeFanProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Geometry constructRangeFan(double x, double y, double range,
		String unit, double bearing, double traversal)
		throws GeometryException {
	Polygon fan = new Polygon();
	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);

	double centerX = centerProj.getX();
	double centerY = centerProj.getY();
	bearing = GeometryUtility.Geo2Arithmetic(bearing);
	double leftAngle = bearing - (traversal / 2);
	double rightAngle = bearing + (traversal / 2);
	int count = (int) Math.round(Math.abs(leftAngle - rightAngle));
	fan.startPath(centerProj);
	UnitConverter uc = new UnitConverter();
	range = uc.Convert(range, unit, srBuffer);
	for (int i = 0; i < count; ++i) {
		double d = Math.toRadians(leftAngle + i);
		double arcX = centerX + (range * Math.cos(d));
		double arcY = centerY + (range * Math.sin(d));
		Point arcPt = new Point(arcX, arcY);
		// arcPt = (Point) GeometryEngine.project(arcPt, srBuffer, srOut);
		fan.lineTo(arcPt);
	}
	fan.closeAllPaths();
	return fan;
}
 
Example 12
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private static Point _rotate(Point center, Point inPt, double ra)
{
	double x = inPt.getX();
	double y = inPt.getY();
	double cx = center.getX();
	double cy = center.getY();
	double cosra = Math.cos(ra);
	double sinra = Math.sin(ra);
	double rx = cx + cosra * (x - cx) - sinra * (y - cy);
	double ry = cy + sinra * (x - cx) + cosra * (y-cy);
	Point rPt = new Point(rx,ry);
	return rPt;
}
 
Example 13
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
private static Point computeMultiPolygonCentroid(OGCMultiPolygon multiPolygon)
{
    double xSum = 0;
    double ySum = 0;
    double weightSum = 0;
    for (int i = 0; i < multiPolygon.numGeometries(); i++) {
        Point centroid = computePolygonCentroid((Polygon) multiPolygon.geometryN(i).getEsriGeometry());
        Polygon polygon = (Polygon) multiPolygon.geometryN(i).getEsriGeometry();
        double weight = polygon.calculateArea2D();
        weightSum += weight;
        xSum += centroid.getX() * weight;
        ySum += centroid.getY() * weight;
    }
    return new Point(xSum / weightSum, ySum / weightSum);
}
 
Example 14
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Point ellipsePtFromAngle(Point center, double rh, double rv, double angle)
{
	double x = center.getX();
	double y = center.getY();
	double c = Math.cos(angle);
	double s = Math.sin(angle);
	double ta = s/c;
	double tt = ta * (rh/rv);
	double d = 1.0 / Math.sqrt(1.0 + Math.pow(tt, 2));
	double ex = x + Math.copySign(rh*d, c);
	double ey = y + Math.copySign(rv * tt * d, s);
	return new Point(ex,ey);
	
}
 
Example 15
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
private static Point computePolygonCentroid(Polygon polygon)
{
    int pathCount = polygon.getPathCount();

    if (pathCount == 1) {
        return getPolygonSansHolesCentroid(polygon);
    }

    double xSum = 0;
    double ySum = 0;
    double areaSum = 0;

    for (int i = 0; i < pathCount; i++) {
        int startIndex = polygon.getPathStart(i);
        int endIndex = polygon.getPathEnd(i);

        Polygon sansHoles = getSubPolygon(polygon, startIndex, endIndex);

        Point centroid = getPolygonSansHolesCentroid(sansHoles);
        double area = sansHoles.calculateArea2D();

        xSum += centroid.getX() * area;
        ySum += centroid.getY() * area;
        areaSum += area;
    }

    return new Point(xSum / areaSum, ySum / areaSum);
}
 
Example 16
Source File: MapController.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
@Override
public double[] projectPoint(double x, double y, int fromWkid, int toWkid) {
    Point pt = (Point) GeometryEngine.project(new Point(x, y), SpatialReference.create(fromWkid), SpatialReference.create(toWkid));
    return new double[] { pt.getX(), pt.getY() };
}
 
Example 17
Source File: BingTileFunctions.java    From presto with Apache License 2.0 4 votes vote down vote up
private static Envelope tileToEnvelope(BingTile tile)
{
    Point upperLeftCorner = tileXYToLatitudeLongitude(tile.getX(), tile.getY(), tile.getZoomLevel());
    Point lowerRightCorner = tileXYToLatitudeLongitude(tile.getX() + 1, tile.getY() + 1, tile.getZoomLevel());
    return new Envelope(upperLeftCorner.getX(), lowerRightCorner.getY(), lowerRightCorner.getX(), upperLeftCorner.getY());
}
 
Example 18
Source File: ClusterLayer.java    From arcgis-runtime-demo-java with Apache License 2.0 4 votes vote down vote up
ClusterableLocation(int id, Feature f) {
  Point p = (Point) f.getGeometry();
  xy[0] = p.getX();
  xy[1] = p.getY();
  this.id = id;
}
 
Example 19
Source File: LatLongProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 4 votes vote down vote up
private Geometry findBoundingBox(String mgrs, int accuracy, Point mgrsPt)
{
	String mgrsZone = mgrs.substring(0, 1);
	int wkid = 0;
	String utm = null;
	if(mgrsZone.equals("A") || mgrsZone.equals("B") )
	{
		wkid = 32761;
	}
	else if(mgrsZone.equals("Y") || mgrsZone.equals("Z"))
	{
		wkid = 32661;
	}
	else
	{
		PeGeogcs peGeoCS = PeFactory.geogcs(4326);
		double[] coordArray = {mgrsPt.getX(), mgrsPt.getY()};
		String[] utmArray = new String[1];
		PeNotationUtm.geog_to_utm(peGeoCS, 1, coordArray, PeNotationUtm.PE_UTM_OPTS_NS, utmArray);
		utm=utmArray[0];
		wkid=GetWkidFromUTM(utm);
		
	}
	SpatialReference pcs = SpatialReference.create(wkid);
	SpatialReference gcs = SpatialReference.create(4326);
	Geometry projGeo = GeometryEngine.project(mgrsPt, gcs, pcs);//projec local
	Point projPt = (Point)projGeo;
	double dist = getDistFromAccuracy(accuracy);
	double xmin, ymin, xmax, ymax;
	xmin=projPt.getX();
	ymin=projPt.getY();
	xmax = xmin + dist;
	ymax = ymin + dist;
	Polygon pbb = new Polygon();
	pbb.startPath(xmin, ymin);
	pbb.lineTo(xmax, ymin);
	pbb.lineTo(xmax, ymax);
	pbb.lineTo(xmin, ymax);
	pbb.lineTo(xmin, ymin);
	pbb.closeAllPaths();
	Geometry bb = GeometryEngine.project(pbb, pcs, gcs);//project back to wgs84
	return bb;
}
 
Example 20
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;
}