Search in sources :

Example 96 with Polygon

use of org.locationtech.jts.geom.Polygon in project hale by halestudio.

the class InteriorPointTest method testStreetOuter.

/**
 * Test with a complex polygon describing streets and a square.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testStreetOuter() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87274, 8.6547), new Coordinate(49.87275, 8.65473), new Coordinate(49.87269, 8.65477), new Coordinate(49.87261, 8.65486), new Coordinate(49.87257, 8.65489), new Coordinate(49.87247, 8.65506), new Coordinate(49.87241, 8.65525), new Coordinate(49.87234, 8.65536), new Coordinate(49.87241, 8.65536), new Coordinate(49.87247, 8.65539), new Coordinate(49.87248, 8.65542), new Coordinate(49.87282, 8.65532), new Coordinate(49.87281, 8.65536), new Coordinate(49.87248, 8.65546), new Coordinate(49.87245, 8.65557), new Coordinate(49.8724, 8.65561), new Coordinate(49.87235, 8.65562), new Coordinate(49.87228, 8.6556), new Coordinate(49.87223, 8.65558), new Coordinate(49.87218, 8.65554), new Coordinate(49.87206, 8.65558), new Coordinate(49.87205, 8.65556), new Coordinate(49.87219, 8.6555), new Coordinate(49.87229, 8.6554), new Coordinate(49.87235, 8.65529), new Coordinate(49.8724, 8.65521), new Coordinate(49.87244, 8.65509), new Coordinate(49.87252, 8.65494), new Coordinate(49.87258, 8.65483), new Coordinate(49.87267, 8.65475), new Coordinate(49.87274, 8.6547) });
    Polygon geom = factory.createPolygon(outer);
    testPointWithin(geom);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

Example 97 with Polygon

use of org.locationtech.jts.geom.Polygon in project hale by halestudio.

the class InteriorPointTest method testCurve2.

/**
 * Test with a complex polygon describing a curve.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testCurve2() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87377, 8.65508), new Coordinate(49.87369, 8.65529), new Coordinate(49.87356, 8.65544), new Coordinate(49.87349, 8.65549), new Coordinate(49.87327, 8.65566), new Coordinate(49.87325, 8.6556), new Coordinate(49.8734, 8.65548), new Coordinate(49.87351, 8.6554), new Coordinate(49.87357, 8.65532), new Coordinate(49.87365, 8.65518), new Coordinate(49.87371, 8.65497), new Coordinate(49.87377, 8.65447), new Coordinate(49.87371, 8.65431), new Coordinate(49.87356, 8.65424), new Coordinate(49.87345, 8.65427), new Coordinate(49.87337, 8.65439), new Coordinate(49.87326, 8.65466), new Coordinate(49.87319, 8.65503), new Coordinate(49.87324, 8.65518), new Coordinate(49.87332, 8.65519), new Coordinate(49.87339, 8.65516), new Coordinate(49.87346, 8.65501), new Coordinate(49.87354, 8.65475), new Coordinate(49.87357, 8.65459), new Coordinate(49.8736, 8.65441), new Coordinate(49.87368, 8.65449), new Coordinate(49.87363, 8.65467), new Coordinate(49.87357, 8.65486), new Coordinate(49.87348, 8.65515), new Coordinate(49.87336, 8.6553), new Coordinate(49.87325, 8.65539), new Coordinate(49.87312, 8.65513), new Coordinate(49.87315, 8.65477), new Coordinate(49.87324, 8.65444), new Coordinate(49.87334, 8.65423), new Coordinate(49.87343, 8.65412), new Coordinate(49.87358, 8.6541), new Coordinate(49.87377, 8.65413), new Coordinate(49.87385, 8.6545), new Coordinate(49.87377, 8.65508) });
    Polygon geom = factory.createPolygon(outer);
    testPointWithin(geom);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

Example 98 with Polygon

use of org.locationtech.jts.geom.Polygon in project hale by halestudio.

the class InteriorPointTest method testFootprint3.

/**
 * Test with a complex polygon describing a rough building footprint.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testFootprint3() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87494, 8.65267), new Coordinate(49.87488, 8.65277), new Coordinate(49.87461, 8.65286), new Coordinate(49.87451, 8.65274), new Coordinate(49.87449, 8.65256), new Coordinate(49.87457, 8.65225), new Coordinate(49.87483, 8.65217), new Coordinate(49.87494, 8.65229), new Coordinate(49.87488, 8.65249), new Coordinate(49.8748, 8.65242), new Coordinate(49.87471, 8.65244), new Coordinate(49.87466, 8.65252), new Coordinate(49.87468, 8.65265), new Coordinate(49.87479, 8.65261), new Coordinate(49.87494, 8.65267) });
    Polygon geom = factory.createPolygon(outer);
    testPointWithin(geom);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

Example 99 with Polygon

use of org.locationtech.jts.geom.Polygon in project hale by halestudio.

the class InteriorPointTest method testStreetHole.

/**
 * Test with a complex polygon describing streets and a roundabout.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testStreetHole() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87274, 8.6547), new Coordinate(49.87275, 8.65473), new Coordinate(49.87269, 8.65477), new Coordinate(49.87261, 8.65486), new Coordinate(49.87257, 8.65489), new Coordinate(49.87247, 8.65506), new Coordinate(49.87241, 8.65525), new Coordinate(49.87234, 8.65536), new Coordinate(49.87241, 8.65536), new Coordinate(49.87247, 8.65539), new Coordinate(49.87248, 8.65542), new Coordinate(49.87282, 8.65532), new Coordinate(49.87281, 8.65536), new Coordinate(49.87248, 8.65546), new Coordinate(49.87245, 8.65557), new Coordinate(49.8724, 8.65561), new Coordinate(49.87235, 8.65562), new Coordinate(49.87228, 8.6556), new Coordinate(49.87223, 8.65558), new Coordinate(49.87218, 8.65554), new Coordinate(49.87206, 8.65558), new Coordinate(49.87205, 8.65556), new Coordinate(49.87219, 8.6555), new Coordinate(49.87229, 8.6554), new Coordinate(49.87235, 8.65529), new Coordinate(49.8724, 8.65521), new Coordinate(49.87244, 8.65509), new Coordinate(49.87252, 8.65494), new Coordinate(49.87258, 8.65483), new Coordinate(49.87267, 8.65475), new Coordinate(49.87274, 8.6547) });
    LinearRing inner = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87246, 8.65545), new Coordinate(49.87245, 8.65551), new Coordinate(49.87244, 8.65555), new Coordinate(49.87241, 8.65557), new Coordinate(49.87236, 8.6556), new Coordinate(49.87232, 8.6556), new Coordinate(49.87225, 8.65556), new Coordinate(49.8722, 8.65552), new Coordinate(49.87233, 8.65539), new Coordinate(49.87235, 8.65539), new Coordinate(49.87238, 8.65539), new Coordinate(49.87243, 8.65539), new Coordinate(49.87245, 8.65541), new Coordinate(49.87246, 8.65545) });
    Polygon geom = factory.createPolygon(outer, new LinearRing[] { inner });
    testPointWithin(geom);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

Example 100 with Polygon

use of org.locationtech.jts.geom.Polygon in project hale by halestudio.

the class InteriorPointTest method testTriangleHole.

/**
 * Test with a triangular polygon with a hole in the middle.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testTriangleHole() 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) });
    LinearRing inner = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87374, 8.65501), new Coordinate(49.87327, 8.65566), new Coordinate(49.87313, 8.65478), new Coordinate(49.87374, 8.65501) });
    Polygon geom = factory.createPolygon(outer, new LinearRing[] { inner });
    testPointWithin(geom);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

Aggregations

Polygon (org.locationtech.jts.geom.Polygon)179 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)89 Coordinate (org.locationtech.jts.geom.Coordinate)78 LinearRing (org.locationtech.jts.geom.LinearRing)55 Point (org.locationtech.jts.geom.Point)54 Test (org.junit.Test)51 Geometry (org.locationtech.jts.geom.Geometry)48 LineString (org.locationtech.jts.geom.LineString)48 ArrayList (java.util.ArrayList)37 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)30 MultiPoint (org.locationtech.jts.geom.MultiPoint)29 MultiLineString (org.locationtech.jts.geom.MultiLineString)19 List (java.util.List)15 Test (org.junit.jupiter.api.Test)15 GeometryCollection (org.locationtech.jts.geom.GeometryCollection)12 WKTReader (org.locationtech.jts.io.WKTReader)12 HashMap (java.util.HashMap)9 CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)8 ParseException (org.locationtech.jts.io.ParseException)7 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)5