[geotk] Coordinate reference systems: identifiers and equality

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Wed Apr 21 11:25:02 EDT 2010

Hello John

Le 21/04/10 16:25, Jonathan Blower a écrit :
> I notice that the three coordinate systems:
>     DefaultGeographicCRS.WGS84
>     CRS.decode("EPSG:4326", true)
>     CRS.decode("CRS:84", true)
> are not considered equal() to each other, even though I thought they all
> represent the same logical CRS (note that I am forcing longitude-first
> axis order).  The WKT is slightly different in each case, but not
> "functionally" so as far as I understand.  Is there a reason they are
> considered different?

They have different metadata associated with them (identifiers, scope, domain of 
validity, etc.). However you can test if they are functionally different with:

     CRS.equalsIgnoreMetadata(crs1, crs2)


There is one corner case where this method will return "false" while the 2 CRS 
are functionality equivalent: when comparing a 3D-GeographicCRS with a 
ComponentCRS[2D-GeographicCRS + VerticalCRS using ellipsoidal height]. But 
except for this corner case, the above should work well.

> Secondly, I'd like a reliable method to perform the inverse of
> CRS.decode(), i.e. take a CRS and return its code.  I notice that Geotk
> has a CRS.getDeclaredIdentifier() method, which is cheaper than
> CRS.lookupIdentifier().  Is getDeclaredIdentifier() guaranteed to return
> the correct code for a CRS for all CRSs that are returned by
> CRS.decode()?  I.e. does every CRS returned by CRS.decode() declare an
> identifier?

Since Geotk uses a plugeable factory system, it depends on which factory created 
the CRS. For the following factories, the answer is "yes":

   - The factory backed by the EPSG database.
   - The factory backed by an epsg.properties file.
   - Actually every CRS authority factories provided by Geotk...

For the following CRS, there is no garantees:

   - CRS created by a custom authority factory - it depends on
     the factory implementation.

   - CRS created from CRS.parseWKT(String) - it depends if the
     WKT contains an AUTHORITY["..."] declaration. This include
     in particular the CRS created from the .prj file which are
     provided with some raster or shapefile data.



More information about the Geotoolkit mailing list