Search in sources :

Example 31 with GeometryFactory

use of com.vividsolutions.jts.geom.GeometryFactory in project ddf by codice.

the class GeoUtilTest method testTransformEpsg4326LonLatNullSrs.

@Test
public void testTransformEpsg4326LonLatNullSrs() throws GeoFormatException {
    GeometryFactory gf = new GeometryFactory();
    Coordinate coord = new Coordinate(25.22, 33.45);
    Point point = gf.createPoint(coord);
    Geometry geom = GeospatialUtil.transformToEPSG4326LonLatFormat(point, (String) null);
    assertThat(geom, is(point));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) Point(com.vividsolutions.jts.geom.Point) Test(org.junit.Test)

Example 32 with GeometryFactory

use of com.vividsolutions.jts.geom.GeometryFactory in project ddf by codice.

the class GeoUtilTest method testTransformEpsg4326LonLatBadSrs.

@Test(expected = GeoFormatException.class)
public void testTransformEpsg4326LonLatBadSrs() throws GeoFormatException {
    GeometryFactory gf = new GeometryFactory();
    Coordinate coord = new Coordinate(25.22, 33.45);
    Point point = gf.createPoint(coord);
    Geometry geom = GeospatialUtil.transformToEPSG4326LonLatFormat(point, "ESPG:Bad");
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) Point(com.vividsolutions.jts.geom.Point) Test(org.junit.Test)

Example 33 with GeometryFactory

use of com.vividsolutions.jts.geom.GeometryFactory in project ddf by codice.

the class GeoUtilTest method testTransformEpsg4326EpsgNoSourceCRS.

@Test
public void testTransformEpsg4326EpsgNoSourceCRS() throws FactoryException, TransformException, GeoFormatException {
    double lon = 33.45;
    double lat = 25.22;
    CoordinateReferenceSystem sourceCRS = null;
    GeometryFactory geometryFactory = new GeometryFactory();
    Coordinate coordinate = new Coordinate(lon, lat);
    Point utmPoint = geometryFactory.createPoint(coordinate);
    Envelope envelope = JTS.toEnvelope(utmPoint);
    Geometry utmGeometry = JTS.toGeometry(envelope);
    Geometry lonLatGeom = GeospatialUtil.transformToEPSG4326LonLatFormat(utmGeometry, sourceCRS);
    assertThat(lonLatGeom.getCoordinates()[0].x, closeTo(lon, .00001));
    assertThat(lonLatGeom.getCoordinates()[0].y, closeTo(lat, .00001));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Point(com.vividsolutions.jts.geom.Point) Envelope(com.vividsolutions.jts.geom.Envelope) Test(org.junit.Test)

Aggregations

GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)33 Coordinate (com.vividsolutions.jts.geom.Coordinate)27 Test (org.junit.Test)21 Geometry (com.vividsolutions.jts.geom.Geometry)13 SimpleFeature (org.opengis.feature.simple.SimpleFeature)12 ArrayList (java.util.ArrayList)10 Point (com.vividsolutions.jts.geom.Point)9 File (java.io.File)9 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)8 Optional (com.google.common.base.Optional)7 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)7 RevFeature (org.locationtech.geogig.api.RevFeature)7 ImmutableList (com.google.common.collect.ImmutableList)6 List (java.util.List)6 AddOp (org.locationtech.geogig.api.porcelain.AddOp)6 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)5 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)5 Envelope (com.vividsolutions.jts.geom.Envelope)4 IOException (java.io.IOException)4 Serializable (java.io.Serializable)4