Search in sources :

Example 66 with Polygon

use of org.locationtech.jts.geom.Polygon in project arctic-sea by 52North.

the class GeoJSONTest method randomPolygon.

private Polygon randomPolygon(int srid) {
    Polygon geometry = geometryFactory.createPolygon(randomLinearRing(srid), new LinearRing[] { randomLinearRing(srid), randomLinearRing(srid), randomLinearRing(srid) });
    geometry.setSRID(srid);
    return geometry;
}
Also used : Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon)

Example 67 with Polygon

use of org.locationtech.jts.geom.Polygon in project arctic-sea by 52North.

the class GeoJSONTest method testPolygonWithZCoordinate.

@Test
public void testPolygonWithZCoordinate() {
    Polygon geometry = randomPolygon(EPSG_4326);
    geometry.apply(new RandomZCoordinateFilter());
    geometry.geometryChanged();
    readWriteTest(geometry);
}
Also used : Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.jupiter.api.Test)

Example 68 with Polygon

use of org.locationtech.jts.geom.Polygon in project arctic-sea by 52North.

the class JTSHelperTest method shouldReverseMultiPolygon.

@Test
public void shouldReverseMultiPolygon() throws OwsExceptionReport {
    final GeometryFactory factory = getGeometryFactoryForSRID(4326);
    testReverse(factory.createMultiPolygon(new Polygon[] { factory.createPolygon(factory.createLinearRing(randomCoordinateRing(13)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(130)), factory.createLinearRing(randomCoordinateRing(4121)), factory.createLinearRing(randomCoordinateRing(12)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(8)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(1101)), factory.createLinearRing(randomCoordinateRing(413)), factory.createLinearRing(randomCoordinateRing(123)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(89)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(112)), factory.createLinearRing(randomCoordinateRing(4)), factory.createLinearRing(randomCoordinateRing(43)) }) }));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Polygon(org.locationtech.jts.geom.Polygon) Test(org.junit.jupiter.api.Test)

Example 69 with Polygon

use of org.locationtech.jts.geom.Polygon in project arctic-sea by 52North.

the class JTSHelperTest method shouldPolygonSwitchCoordinates.

@Test
public void shouldPolygonSwitchCoordinates() throws ParseException {
    final GeometryFactory factory = getGeometryFactoryForSRID(4326);
    Polygon polygon = factory.createPolygon(factory.createLinearRing(randomCoordinateRing(10)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(10)), factory.createLinearRing(randomCoordinateRing(41)), factory.createLinearRing(randomCoordinateRing(13)) });
    assertNotEquals(polygon, switchCoordinateAxisOrder(polygon));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Polygon(org.locationtech.jts.geom.Polygon) Test(org.junit.jupiter.api.Test)

Example 70 with Polygon

use of org.locationtech.jts.geom.Polygon in project onebusaway-application-modules by camsys.

the class BoundingBoxController method index.

@RequestMapping()
public ModelAndView index() {
    GeometryFactory gf = new GeometryFactory();
    List<Polygon> polygons = new ArrayList<Polygon>();
    Map<String, CoordinateBounds> agencies = _agencyService.getAgencyIdsAndCoverageAreas();
    for (CoordinateBounds cb : agencies.values()) {
        Envelope e = new Envelope(cb.getMinLon(), cb.getMaxLon(), cb.getMinLat(), cb.getMaxLat());
        Polygon p = (Polygon) gf.toGeometry(e);
        polygons.add(p);
    }
    MultiPolygon mp = gf.createMultiPolygon(polygons.toArray(new Polygon[0]));
    Geometry hull = mp.convexHull();
    Envelope env = hull.getEnvelopeInternal();
    ModelAndView mv = new ModelAndView("bounding-box.jspx");
    mv.addObject("minY", env.getMinY());
    mv.addObject("minX", env.getMinX());
    mv.addObject("maxY", env.getMaxY());
    mv.addObject("maxX", env.getMaxX());
    mv.addObject("hullWKT", hull.toText());
    return mv;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Envelope(org.locationtech.jts.geom.Envelope) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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