Search in sources :

Example 91 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class GeometryTestFactory method newCircle.

public static Polygon newCircle(final GeometryFactory fact, final double basex, final double basey, final double size, final int nPts) {
    final Point[] pts = newCircle(basex, basey, size, nPts);
    final LinearRing ring = fact.linearRing(pts);
    final Polygon poly = fact.polygon(ring);
    return poly;
}
Also used : Point(com.revolsys.geometry.model.Point) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon)

Example 92 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class LineStringImplTest method testUnclosedLinearRing.

public void testUnclosedLinearRing() {
    try {
        final LinearRing linearRing = this.geometryFactory.linearRing(new PointDoubleXY(0.0, 0), new PointDoubleXY(1.0, 0), new PointDoubleXY(1.0, 1), new PointDoubleXY(2.0, 1));
        assertTrue(false);
    } catch (final Exception e) {
        assertTrue(e instanceof IllegalArgumentException);
    }
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 93 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class LineStringImplTest method testLinearRingConstructor.

public void testLinearRingConstructor() throws Exception {
    try {
        final LinearRing ring = GeometryFactory.DEFAULT_3D.linearRing(2, 0.0, 0, 10.0, 10);
        assertTrue(false);
    } catch (final IllegalArgumentException e) {
        assertTrue(true);
    }
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

Example 94 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class EdgeRing method findEdgeRingContaining.

/**
 * Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.
 * The innermost enclosing ring is the <i>smallest</i> enclosing ring.
 * The algorithm used depends on the fact that:
 * <br>
 *  ring A contains ring B iff envelope(ring A) contains envelope(ring B)
 * <br>
 * This routine is only safe to use if the chosen point of the hole
 * is known to be properly contained in a shell
 * (which is guaranteed to be the case if the hole does not touch its shell)
 *
 * @return containing EdgeRing, if there is one
 * or null if no containing EdgeRing is found
 */
public static EdgeRing findEdgeRingContaining(final EdgeRing testEr, final List<EdgeRing> shellList) {
    final LinearRing testRing = testEr.getRing();
    final BoundingBox testEnv = testRing.getBoundingBox();
    Point testPt = testRing.getPoint(0);
    if (testPt == null) {
        return null;
    } else {
        EdgeRing minShell = null;
        BoundingBox minShellEnv = null;
        for (final EdgeRing tryShell : shellList) {
            final LinearRing tryShellRing = tryShell.getRing();
            final BoundingBox tryShellEnv = tryShellRing.getBoundingBox();
            // (also guards against testing rings against themselves)
            if (tryShellEnv.equals(testEnv)) {
                continue;
            }
            // hole must be contained in shell
            if (!tryShellEnv.covers(testEnv)) {
                continue;
            }
            testPt = CoordinatesUtil.pointNotInList(testRing, tryShellRing);
            boolean isContained = false;
            if (tryShellRing.isPointInRing(testPt)) {
                isContained = true;
            }
            // ring
            if (isContained) {
                if (minShell == null || minShellEnv.covers(tryShellEnv)) {
                    minShell = tryShell;
                    minShellEnv = minShell.getRing().getBoundingBox();
                }
            }
        }
        return minShell;
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 95 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class MCPointInRingTest method runPtInRing.

@Override
protected void runPtInRing(final Location expectedLoc, final Point pt, final String wkt) throws Exception {
    // isPointInRing is not defined for pts on boundary
    if (expectedLoc == Location.BOUNDARY) {
        return;
    }
    final Geometry geom = this.geometryFactory.geometry(wkt);
    if (!(geom instanceof Polygon)) {
        return;
    }
    final LinearRing ring = ((Polygon) geom).getShell();
    final boolean expected = expectedLoc == Location.INTERIOR;
    final MCPointInRing pir = new MCPointInRing(ring);
    final boolean result = pir.isInside(pt);
    assertEquals(expected, result);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) MCPointInRing(com.revolsys.geometry.algorithm.MCPointInRing)

Aggregations

LinearRing (com.revolsys.geometry.model.LinearRing)95 Polygon (com.revolsys.geometry.model.Polygon)53 Point (com.revolsys.geometry.model.Point)44 ArrayList (java.util.ArrayList)21 LineString (com.revolsys.geometry.model.LineString)19 Geometry (com.revolsys.geometry.model.Geometry)14 Polygonal (com.revolsys.geometry.model.Polygonal)11 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)9 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 Lineal (com.revolsys.geometry.model.Lineal)7 Punctual (com.revolsys.geometry.model.Punctual)6 List (java.util.List)4 NoSuchElementException (java.util.NoSuchElementException)4 IOException (java.io.IOException)3 MCPointInRing (com.revolsys.geometry.algorithm.MCPointInRing)2 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 BigDecimal (java.math.BigDecimal)2 PointInRing (com.revolsys.geometry.algorithm.PointInRing)1 EdgeRing (com.revolsys.geometry.geomgraph.EdgeRing)1