-
Notifications
You must be signed in to change notification settings - Fork 16
2. Create a new CoordinateReferenceSystem from an OGC WKT
The easiest way to create a CoordinateReferenceSystem is to deifned it as a Well-Known Text and to ask CTS to read it to create the corresponding Coordinate Reference System.
This pseudo-code explains how to create a new geographic CoordinateReferenceSystem.
// Create a new CRSFactory, this is necessary to create a CRS without definig all its components one by one
CRSFactory cRSFactory = new CRSFactory();
// The Well-Known Text describing the desired Coordinate Reference System
// The \n and spaces are unnecessary but contribute to make the WKT clearer
String wktString = "PROJCS[\\"NTF (Paris) / Lambert zone II\",\n"
+ " GEOGCS[\\"NTF (Paris)\",\n"
+ " DATUM[\\"Nouvelle_Triangulation_Francaise_Paris\",\n"
+ " SPHEROID[\\"Clarke 1880 (IGN)\",6378249.2,293.4660212936269,\n"
+ " AUTHORITY[\\"EPSG\",\\"7011\"]],\n"
+ " TOWGS84[-168,-60,320,0,0,0,0],\n"
+ " AUTHORITY[\\"EPSG\",\\"6807\"]],\n"
+ " PRIMEM[\\"Paris\",2.33722917,\n"
+ " AUTHORITY[\\"EPSG\",\\"8903\"]],\n"
+ " UNIT[\\"grad\",0.01570796326794897,\n"
+ " AUTHORITY[\\"EPSG\",\\"9105\"]],\n"
+ " AUTHORITY[\\"EPSG\",\\"4807\"]],\n"
+ " UNIT[\\"metre\",1,\n"
+ " AUTHORITY[\\"EPSG\",\\"9001\"]],\n"
+ " PROJECTION[\\"Lambert_Conformal_Conic_1SP\"],\n"
+ " PARAMETER[\\"latitude_of_origin\",52],\n"
+ " PARAMETER[\\"central_meridian\",0],\n"
+ " PARAMETER[\\"scale_factor\",0.99987742],\n"
+ " PARAMETER[\\"false_easting\",600000],\n"
+ " PARAMETER[\\"false_northing\",2200000],\n"
+ " AUTHORITY[\\"EPSG\",\\"27572\"],\n"
+ " AXIS[\\"X\",EAST],\n"
+ " AXIS[\\"Y\",NORTH]]";
// Create the Coordinate Reference System corresponding to the Well-Known Text
CoordinateReferenceSystem scrs = cRSFactory.createFromPrj(prjString);
CTS recognizes most nodes used in Well-Known Text. Here is the list of these nodes and of the argument they can accept :
-
COMPD_CS[name (mandatory), PROJCS or GEOGCS (mandatory), VERT_CS (mandatory), AUTHORITY (optional)]
-
PROJCS[name (mandatory), GEOGCS (mandatory), PROJECTION (mandatory), PARAMETER (multiple, optional), UNIT (optional), AXIS (multiple, optional), AUTHORITY (optional)]
-
GEOGCS[name (mandatory), DATUM (mandatory), PRIMEM (optional), UNIT (optional), AXIS (multiple, optional), AUTHORITY (optional)]
-
VERT_CS[name (mandatory),VERT_DATUM (mandatory), UNIT (optional), AXIS (multiple, optional), AUTHORITY (optional)]
NB1: The order in which the axes are defined is important. The first axis defined will be the first axis used in the Coordinate System and so on.
NB2: If there is too much axes defined (for instance 4 axes for a GEOGCS), CTS will throw an exception. If there is less axes than expected, CTS will complete the CoordinateSystem with default axes.
- DATUM[name (mandatory), SPHEROID (mandatory), TOWGS84 (optional), AUTHORITY (optional)]
NB3: If the node TOWGS84 is not defined, CTS will consider that the transformation to convert geocentric coordinates into WGS84 referential is identity transformation.
-
SPHEROID[name (mandatory), majorAxis (mandatory), reverseFlattening (mandatory), AUTHORITY (optional)]
-
TOWGS84[tx (mandatory), ty (optional), tz (optional), rx_sec (optional), ry_sec (optional), rz_sec (optional), ds_ppm (optional)]
NB4: The WGS84 must contain at list 1 value, CTS complete the given values with zeros so to obtain proper seven parameter table.
- PRIMEM[name (mandatory), meridianLongitude (in decimal dagree, mandatory), AUTHORITY (optional)]
NB5: In fact, the meridianLongitude is not required if the name of the prime meridian is one of the name recognized by CTS.
- VERT_DATUM[name (mandatory), typeCode (mandatory), AUTHORITY (optional)]
NB6: the typeCode define the way height is obtained, here is the significations of this code :
2000: OTHER SURFACE
2001: ORTHOMETRIC
2002: ELLIPSOIDAL
2003: BAROMETRIC
2005: GEOIDAL
2006: DEPTH
-
PROJECTION[name (mandatory)]
-
PARAMETER[name (mandatory), value (mandatory)]
NB7: The name must be correctly written to be recognize [here] (https://github.com/irstv/CTS/blob/master/src/main/java/org/cts/Parameter.java) is the list of recognized parameter names.
-
UNIT[name (mandatory), scale (mandatory), AUTHORITY (optional)]
-
AXIS[name (mandatory), direction (mandatory)]
NB8: The direction accepted are : SOUTH, NORTH, EAST, WEST, UP, DOWN and OTHER. All unrecognized will be interpreted as OTHER.
- AUTHORITY[registryName (mandatory), registryKey (mandatory)]
NB9: WARNING CTS often try to get a component only by its authority, without checking the other argument in the node, so DO NOT USE AUTHORITY nodes if you are not sure that this authority correpsond to the component you want to define.