Search in sources :

Example 11 with LinearRing

use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.

the class InteriorPointTest method testHalfmoon.

/**
 * Test with a polygon describing a rough half moon.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testHalfmoon() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87359, 8.65558), new Coordinate(49.87307, 8.65649), new Coordinate(49.87239, 8.65812), new Coordinate(49.8724, 8.65586), new Coordinate(49.87294, 8.65431), new Coordinate(49.87402, 8.65378), new Coordinate(49.87541, 8.65358), new Coordinate(49.87671, 8.65437), new Coordinate(49.87751, 8.65659), new Coordinate(49.87683, 8.65548), new Coordinate(49.87583, 8.65489), new Coordinate(49.87448, 8.65505), new Coordinate(49.87359, 8.65558) });
    Polygon geom = factory.createPolygon(outer);
    testPointWithin(geom);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LinearRing(com.vividsolutions.jts.geom.LinearRing) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test)

Example 12 with LinearRing

use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.

the class InteriorPointTest method testProblemCase.

/**
 * Test with a problem case from real data.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testProblemCase() throws Exception {
    LinearRing outer1 = factory.createLinearRing(new Coordinate[] { new Coordinate(466713.482, 5974979.283), new Coordinate(466737.125, 5974995.621), new Coordinate(466737.125, 5974995.621), new Coordinate(467230.558, 5975071.481), new Coordinate(467230.558, 5975071.481), new Coordinate(467309.28, 5975083.867), new Coordinate(467309.28, 5975083.867), new Coordinate(466776.829, 5975009.807), new Coordinate(466776.829, 5975009.807), new Coordinate(466742.764, 5974999.507), new Coordinate(466713.482, 5974979.283) });
    Polygon poly1 = factory.createPolygon(outer1);
    testPointWithin(factory.createMultiPolygon(new Polygon[] { poly1 }));
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LinearRing(com.vividsolutions.jts.geom.LinearRing) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test)

Example 13 with LinearRing

use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.

the class InteriorPointTest method testTriangle.

/**
 * Test with a simple triangular polygon.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testTriangle() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87401, 8.65491), new Coordinate(49.87318, 8.65606), new Coordinate(49.87297, 8.6545), new Coordinate(49.87401, 8.65491) });
    Polygon geom = factory.createPolygon(outer);
    testPointWithin(geom);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LinearRing(com.vividsolutions.jts.geom.LinearRing) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test)

Example 14 with LinearRing

use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.

the class InteriorPointTest method testFootprint2Hole.

/**
 * Test with a complex polygon describing a rough building footprint.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testFootprint2Hole() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87517, 8.64862), new Coordinate(49.87491, 8.64873), new Coordinate(49.87497, 8.64913), new Coordinate(49.87521, 8.64904), new Coordinate(49.87525, 8.64924), new Coordinate(49.87424, 8.64958), new Coordinate(49.8742, 8.64937), new Coordinate(49.87446, 8.64929), new Coordinate(49.87441, 8.6489), new Coordinate(49.87414, 8.64897), new Coordinate(49.87411, 8.64877), new Coordinate(49.87514, 8.64844), new Coordinate(49.87517, 8.64862) });
    LinearRing inner = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87478, 8.6488), new Coordinate(49.87482, 8.64914), new Coordinate(49.8746, 8.64924), new Coordinate(49.87454, 8.64887), new Coordinate(49.87478, 8.6488) });
    Polygon geom = factory.createPolygon(outer, new LinearRing[] { inner });
    testPointWithin(geom);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LinearRing(com.vividsolutions.jts.geom.LinearRing) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test)

Example 15 with LinearRing

use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.

the class ExtendedWKBReader method readPolygon.

@SuppressWarnings("null")
private Polygon readPolygon() throws IOException {
    int numRings = dis.readInt();
    LinearRing[] holes = null;
    if (numRings > 1)
        holes = new LinearRing[numRings - 1];
    LinearRing shell = readLinearRing();
    for (int i = 0; i < numRings - 1; i++) {
        holes[i] = readLinearRing();
    }
    return factory.createPolygon(shell, holes);
}
Also used : LinearRing(com.vividsolutions.jts.geom.LinearRing) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Aggregations

LinearRing (com.vividsolutions.jts.geom.LinearRing)101 Polygon (com.vividsolutions.jts.geom.Polygon)72 Coordinate (com.vividsolutions.jts.geom.Coordinate)52 Test (org.junit.Test)42 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)28 PackedCoordinateSequence (com.vividsolutions.jts.geom.impl.PackedCoordinateSequence)27 RdfToRyaConversions.convertStatement (org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement)24 Resource (org.openrdf.model.Resource)24 Statement (org.openrdf.model.Statement)24 URI (org.openrdf.model.URI)24 Value (org.openrdf.model.Value)24 ValueFactory (org.openrdf.model.ValueFactory)24 ContextStatementImpl (org.openrdf.model.impl.ContextStatementImpl)24 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)24 ArrayList (java.util.ArrayList)22 StatementConstraints (org.apache.rya.indexing.StatementConstraints)12 LineString (com.vividsolutions.jts.geom.LineString)10 Point (com.vividsolutions.jts.geom.Point)10 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)9 Geometry (com.vividsolutions.jts.geom.Geometry)8