System.out.println("Creating two CRSs by hand:");
// createCRSByHand3 start
CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
DatumFactory datumFactory = ReferencingFactoryFinder.getDatumFactory(null);
CSFactory csFactory = ReferencingFactoryFinder.getCSFactory(null);
Map<String, Object> map = new HashMap<String, Object>();
//
// Create a datum used for each CRS
//
map.clear();
map.put("name", "Greenwich Meridian");
PrimeMeridian greenwichMeridian = datumFactory.createPrimeMeridian(map, 0, NonSI.DEGREE_ANGLE);
map.clear();
map.put("name", "WGS 84 Ellipsoid Datum");
Ellipsoid wgs84Ellipsoid = datumFactory.createFlattenedSphere(map, 6378137, 298.257223563,
SI.METER);
map.clear();
map.put("name", "WGS84 Height Datum");
GeodeticDatum wgs84Datum = datumFactory.createGeodeticDatum(map, wgs84Ellipsoid,
greenwichMeridian);
//
// Create a geocentric CRS
//
// Create a collection of axes for the coordinate system.
map.clear();
map.put("name", "Cartesian X axis");
CoordinateSystemAxis xAxis = csFactory.createCoordinateSystemAxis(map, "X",
AxisDirection.GEOCENTRIC_X, SI.METER);
map.clear();
map.put("name", "Cartesian Y axis");
CoordinateSystemAxis yAxis = csFactory.createCoordinateSystemAxis(map, "Y",
AxisDirection.GEOCENTRIC_Y, SI.METER);
map.clear();
map.put("name", "Cartesian Z axis");
CoordinateSystemAxis zAxis = csFactory.createCoordinateSystemAxis(map, "Z",
AxisDirection.GEOCENTRIC_Z, SI.METER);
map.clear();
map.put("name", "Rendered Cartesian CS");
CartesianCS worldCS = csFactory.createCartesianCS(map, xAxis, yAxis, zAxis);
// Now, the geocentric coordinate reference system that we'd use for output - eg to a 3D
// renderer
map.clear();
map.put("name", "Output Cartesian CS");
CoordinateReferenceSystem geocentricCRS = crsFactory.createGeocentricCRS(map, wgs84Datum,
worldCS);
System.out.println("Geocentric CRS: " + geocentricCRS.toWKT());
//
// Create a geograyhic CRS for the Airy 1830 ellipsoid
// map.clear();
// map.put("name", "Airy 1830");
// Ellipsoid airyEllipse =
// datumFactory.createFlattenedSphere(map, 6377563.396, 299.3249646, SI.METER);
map.clear();
map.put("name", "Geodetic North axis");
CoordinateSystemAxis northAxis = csFactory.createCoordinateSystemAxis(map, "N",
AxisDirection.NORTH, NonSI.DEGREE_ANGLE);
map.clear();
map.put("name", "Geodetic East axis");
CoordinateSystemAxis eastAxis = csFactory.createCoordinateSystemAxis(map, "E",
AxisDirection.EAST, NonSI.DEGREE_ANGLE);
map.clear();
map.put("name", "Geodetic Height axis");
CoordinateSystemAxis heightAxis = csFactory.createCoordinateSystemAxis(map, "Up",
AxisDirection.UP, SI.METER);
map.clear();
map.put("name", "<long>,<lat> Airy 1830 geodetic");
EllipsoidalCS airyCS = csFactory.createEllipsoidalCS(map, eastAxis, northAxis, heightAxis);
// finally create the source geographic CRS
CoordinateReferenceSystem airyCRS = crsFactory.createGeographicCRS(map, wgs84Datum, airyCS);
// createCRSByHand3 end