Search in sources :

Example 86 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project jena by apache.

the class SRSInfoTest method testCheckAxisXY_OSGB36.

/**
 * Test of checkAxisXY method, of class SRSInfo.
 *
 * @throws org.opengis.util.FactoryException
 */
@Test
public void testCheckAxisXY_OSGB36() throws FactoryException {
    CoordinateReferenceSystem crs = CRS.forCode(SRS_URI.OSGB36_CRS);
    Boolean expResult = true;
    Boolean result = SRSInfo.checkAxisXY(crs);
    assertEquals(expResult, result);
}
Also used : CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 87 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project jena by apache.

the class SRSRegistryTest method testGetDefaultWKTCRS.

/**
 * Test of getCRS method, of class SRSRegistry.
 */
@Test
public void testGetDefaultWKTCRS() {
    try {
        String srsURI = SRS_URI.DEFAULT_WKT_CRS84;
        String default_CRS_WKT = "GeodeticCRS[\"WGS 84\",\n" + "  Datum[\"World Geodetic System 1984\",\n" + "    Ellipsoid[\"WGS 84\", 6378137.0, 298.257223563]],\n" + "  CS[ellipsoidal, 2],\n" + "    Axis[\"Geodetic longitude (Lon)\", east],\n" + "    Axis[\"Geodetic latitude (Lat)\", north],\n" + "    Unit[\"degree\", 0.017453292519943295],\n" + "  Scope[\"Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.\"],\n" + "  Area[\"World.\"],\n" + "  BBox[-90.00, -180.00, 90.00, 180.00],\n" + "  Id[\"CRS\", 84, Citation[\"WMS\"], URI[\"urn:ogc:def:crs:OGC:1.3:CRS84\"]]]";
        CoordinateReferenceSystem expResult = CRS.fromWKT(default_CRS_WKT);
        CoordinateReferenceSystem result = SRSRegistry.getCRS(srsURI);
        assertEquals(expResult.toWKT(), result.toWKT());
    } catch (FactoryException ex) {
    }
}
Also used : FactoryException(org.opengis.util.FactoryException) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 88 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project jena by apache.

the class GeometryTransformIndex method transform.

private static GeometryWrapper transform(GeometryWrapper sourceGeometryWrapper, String srsURI) throws MismatchedDimensionException, FactoryException, TransformException {
    CoordinateReferenceSystem sourceCRS = sourceGeometryWrapper.getCRS();
    CoordinateReferenceSystem targetCRS = SRSRegistry.getCRS(srsURI);
    MathTransform transform = MathTransformRegistry.getMathTransform(sourceCRS, targetCRS);
    Geometry parsingGeometry = sourceGeometryWrapper.getParsingGeometry();
    // Transform the coordinates into a new Geometry.
    Geometry transformedGeometry = GeometryTransformation.transform(parsingGeometry, transform);
    // Construct a new GeometryWrapper using info from original GeometryWrapper.
    String geometryDatatypeURI = sourceGeometryWrapper.getGeometryDatatypeURI();
    DimensionInfo dimensionInfo = sourceGeometryWrapper.getDimensionInfo();
    return new GeometryWrapper(transformedGeometry, srsURI, geometryDatatypeURI, dimensionInfo);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) MathTransform(org.opengis.referencing.operation.MathTransform) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 89 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project jena by apache.

the class GeometryWrapper method getUTMZoneURI.

/**
 * @return URI of the GeometryWrapper's UTM zone
 * @throws FactoryException
 * @throws MismatchedDimensionException
 * @throws TransformException
 */
public String getUTMZoneURI() throws FactoryException, MismatchedDimensionException, TransformException {
    if (utmURI == null) {
        // Find a point in the parsing geometry so can directly apply the SRS.
        Point coord = parsingGeometry.getCentroid();
        DirectPosition2D point = new DirectPosition2D(coord.getX(), coord.getY());
        // Convert to WGS84. Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
        CoordinateReferenceSystem wgs84CRS = SRSRegistry.getCRS(SRS_URI.WGS84_CRS);
        MathTransform transform = MathTransformRegistry.getMathTransform(srsInfo.getCrs(), wgs84CRS);
        DirectPosition wgs84Point = transform.transform(point, null);
        // Find the UTM zone.
        utmURI = SRSRegistry.findUTMZoneURIFromWGS84(wgs84Point.getOrdinate(0), wgs84Point.getOrdinate(1));
    }
    return utmURI;
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) MathTransform(org.opengis.referencing.operation.MathTransform) Point(org.locationtech.jts.geom.Point) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) DirectPosition2D(org.apache.sis.geometry.DirectPosition2D)

Example 90 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project jena by apache.

the class GeometryWrapperTest method testGetCRS.

/**
 * Test of getCRS method, of class GeometryWrapper.
 *
 * @throws org.opengis.util.FactoryException
 */
@Test
public void testGetCRS() throws FactoryException {
    Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
    String sourceSRSURI = SRS_URI.WGS84_CRS;
    GeometryWrapper instance = new GeometryWrapper(geometry, sourceSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    CoordinateReferenceSystem expResult = CRS.forCode(sourceSRSURI);
    CoordinateReferenceSystem result = instance.getCRS();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Aggregations

CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)210 Test (org.junit.Test)80 MathTransform (org.opengis.referencing.operation.MathTransform)32 FactoryException (org.opengis.referencing.FactoryException)25 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)24 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)23 Geometry (com.vividsolutions.jts.geom.Geometry)21 TransformException (org.opengis.referencing.operation.TransformException)21 DependsOnMethod (org.apache.sis.test.DependsOnMethod)19 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)13 Geometry (org.locationtech.jts.geom.Geometry)11 FactoryException (org.opengis.util.FactoryException)11 SimpleFeature (org.opengis.feature.simple.SimpleFeature)9 DirectPosition (org.opengis.geometry.DirectPosition)9 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)9 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)9 CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)9 ArrayList (java.util.ArrayList)8 GeometryType (org.opengis.feature.type.GeometryType)8 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)7