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);
}
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) {
}
}
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);
}
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;
}
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);
}
Aggregations