Java Code Examples for com.esri.core.geometry.Polygon#closeAllPaths()

The following examples show how to use com.esri.core.geometry.Polygon#closeAllPaths() . 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: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 2
Source File: GeoJsonParser.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * Example:
 * [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
 * @param parser
 * @return a polygon
 * @throws JsonParseException
 * @throws IOException
 */
private Polygon parseSimplePolygonCoordinates(JsonNode node) {
  Polygon g = new Polygon();
  boolean first = true;
  ArrayNode points = (ArrayNode) node;
  for (JsonNode point : points) {
    Point p = parsePointCoordinates(point);
    if (first) {
      g.startPath(p);
      first = false;
    } else {
      g.lineTo(p);
    }  
  }
  g.closeAllPaths();
  return g;
}
 
Example 3
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 4
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 5
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 6
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 7
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 8
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 9
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 10
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 11
Source File: GeometryUtility.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
Example 12
Source File: QueryReportProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private MapGeometry constructGeometryFromString(String geoString)
{
	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();
	MapGeometry mapgeo = new MapGeometry(polygon, srOut);
	return mapgeo;
}
 
Example 13
Source File: QueryReportProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
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 14
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 15
Source File: SpatialQProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private MapGeometry constructGeometryFromString(String geoString) {
	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();
	MapGeometry mapgeo = new MapGeometry(polygon, srOut);
	return mapgeo;
}
 
Example 16
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 17
Source File: TestStGeomFromShape.java    From spatial-framework-for-hadoop with Apache License 2.0 5 votes vote down vote up
private static Polygon createPolygon() {
	Polygon polygon = new Polygon();
	polygon.startPath(createFirstLocation());
	polygon.lineTo(createSecondLocation());
	polygon.lineTo(createThirdLocation());
	polygon.lineTo(createFourthLocation());
	polygon.closeAllPaths();
	return polygon;
}
 
Example 18
Source File: PolygonProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
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 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;
}