com.esri.core.geometry.Point2D Java Examples

The following examples show how to use com.esri.core.geometry.Point2D. 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 5 votes vote down vote up
private static Point _centerOfMass(Polygon p)
{
	try
	{
		Double cx = 0.0;
		Double cy = 0.0;
		double a = p.calculateArea2D();
		Point2D[] points = p.getCoordinates2D();
		int i, j, n=p.getPointCount();
		Double factor = 0.0;
		for(i=0; i<n; i++)
		{
			j=(i+1)%n;
			factor = (points[j].x * points[i].y - points[i].x*points[j].y);
			cx += (points[i].x + points[j].x)*factor;
			cy += (points[i].y + points[j].y)*factor;
		}
		a*=6.0f;
		factor = 1/a;
		cx *=factor;
		cy*=factor;
		Point pt = new Point (cx, cy);
		return pt;
	}
	catch(Exception e)
	{
		LOGGER.error(e.getMessage());
		return null;
	}
}
 
Example #2
Source File: StoreTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Asserts that the given polyline contains the expected coordinate values.
 */
private static void assertPolylineEquals(final double[] trajectory, final Polyline polyline) {
    assertEquals("pointCount", trajectory.length / 2, polyline.getPointCount());
    for (int i=0; i < trajectory.length;) {
        final Point2D xy = polyline.getXY(i / 2);
        assertEquals("x", trajectory[i++], xy.x, STRICT);
        assertEquals("y", trajectory[i++], xy.y, STRICT);
    }
}