Java Code Examples for mil.nga.sf.LineString#numPoints()

The following examples show how to use mil.nga.sf.LineString#numPoints() . 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: GeoPackageGeometryDataUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Compare the two line strings for equality
 *
 * @param expected
 * @param actual
 * @parma delta
 */
private static void compareLineString(LineString expected,
                                      LineString actual, double delta) {

    compareBaseGeometryAttributes(expected, actual);
    TestCase.assertEquals(expected.numPoints(), actual.numPoints());
    for (int i = 0; i < expected.numPoints(); i++) {
        comparePoint(expected.getPoints().get(i),
                actual.getPoints().get(i), delta);
    }
}
 
Example 2
Source File: MapUtils.java    From mage-android with Apache License 2.0 5 votes vote down vote up
public static boolean polygonHasKinks(Polygon polygon) {
    for (LineString line1 : polygon.getRings()) {
        Point lastPoint = line1.getPoints().get(line1.numPoints() - 1);
        for (LineString line2 : polygon.getRings()) {
            for (int i = 0; i < line1.numPoints() - 1; i++) {
                Point point1 = line1.getPoints().get(i);
                Point nextPoint1 = line1.getPoints().get(i + 1);
                for (int k = i; k < line2.numPoints() - 1; k++) {
                    Point point2 = line2.getPoints().get(k);
                    Point nextPoint2 = line2.getPoints().get(k + 1);
                    if (line1 != line2) {
                        continue;
                    }

                    if (Math.abs(i - k) == 1) {
                        continue;
                    }

                    if (i == 0 && k == line1.numPoints() - 2 && point1.getX() == lastPoint.getX() && point1.getY() == lastPoint.getY()) {
                        continue;
                    }

                    boolean intersects = intersects(point1, nextPoint1, point2, nextPoint2);

                    if (intersects) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
Example 3
Source File: GeoPackageGeometryDataUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Compare the two line strings for equality
 * 
 * @param expected
 * @param actual
 * @parma delta
 */
private static void compareLineString(LineString expected,
		LineString actual, double delta) {

	compareBaseGeometryAttributes(expected, actual);
	TestCase.assertEquals(expected.numPoints(), actual.numPoints());
	for (int i = 0; i < expected.numPoints(); i++) {
		comparePoint(expected.getPoints().get(i),
				actual.getPoints().get(i), delta);
	}
}