You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sis.apache.org by Martin Desruisseaux <ma...@geomatys.com> on 2017/07/27 09:05:07 UTC

Proj4 binding in Apache SIS

Hello all

A binding to Proj.4 has been added in a separated module, "sis-gdal". As
a reminder, Apache SIS has its own map projection engine, which is in
closer compliance with authoritative definitions from EPSG and have more
capabilities with metadata (domain of validity, etc.), multi-dimensional
support and Jacobian matrices. However use of Proj.4 library is
convenient when needing a map projection not yet supported by Apache
SIS, or when the exact same numerical results are desired for
compatibility with MapServer, PostGIS or QGIS. This is currently
supported only for Linux and MacOS, and requires Proj.4 to be
pre-installed on the machine (we do not provides Proj.4 in the JAR
file). If all those conditions are meet and the "sis-gdal" optional
module is present on the class path, then the CRS.forCode(String) method
(the same method than the one we already use for EPSG codes) accepts
also strings in the "Proj4" namespace. For example:

    CoordinateReferenceSystem crs = CRS.forCode("proj4::+init=epsg:3395");

Any legal Proj.4 definition string can appear after "Proj4::". Note
however that definitions like "proj4::+init=epsg:4326" are NOT compliant
with the authoritative EPSG:4326 definition. Proj.4 differs in axis
order and sometime units of measurement. For the authoritative
definition, we need to use CRS.forCode("EPSG::4326") like before.

The method gives back an implementation of the GeoAPI's
CoordinateReferenceSystem interface. Whether the
CoordinateReferenceSystem is implemented by an EPSG or a Proj.4
definition is transparent to the user (the two cases can be
distinguished by looking at the CRS identifiers if needed). Coordinate
transformations can be done in the usual way:

    CoordinateOperation op = CRS.findOperation(sourceCRS, targetCRS, areaOfValidity);
    op.getMathTransform().transform(…);

If both sourceCRS and targetCRS were created from a Proj.4 definition
string, then above method returns a coordinate operation backed by
Proj.4. Otherwise the coordinate operation uses Apache SIS
implementation. Again, the fact that the coordinate operation is backed
by Apache SIS or Proj.4 is transparent to the user; the same GeoAPI
interfaces are used in all cases.

    Martin