Newcomb, Michael-P57487 a écrit :
What is going on? I'm trying to upgrade from an early 2.0 release and in
looking through the documentation, find
org.geotools.cs.CoordinateSystemFactory has been:

"Deprecated. Replaced by org.geotools.referencing.crs.CRSFactory."

So, I go to look for org.geotools.referencing.crs.CRSFactory and there
is no such class!

It is a typo (I will fix that, thanks for spotting it). The replacement is:

    org.opengis.referencing.crs.CRSFactory

(i.e. "opengis" instead of "geotools"). It is an interface from the GeoAPI project.

In summary: the Open Geospatial (OGC) specification changed. They uniformized their specification with the ISO equivalent. Consequently, the legacy OGC "Coordinate Transformation Services" specification has been replaced by ISO 19111. The deprecated class in Geotools and the new implementation reflect that changes.

I agree that it is a pain for users to migrate the API. On the bright side, I think that the ISO 19111 API has real advantages over the old OGC ones. For example it was not possible to know for sure if a coordinate system is cartesian with the legacy OGC API, while the ISO API provides a nice way to check that.



All I want to do is to be able to do the following transforms...

UTM (with altitude) -> Geocentric
Geocentric -> UTM (with altitude)


If yours horizontal UTM come from an EPSG database:

CRSFactory crsFactory = FactoryFinder.getCRSFactory(null);

FactoryFinder live in org.geotools.referencing and returns implementation of various GeoAPI interfaces, including org.opengis.referencing.CRSFactory.

http://javadoc.geotools.fr/2.2/org/geotools/referencing/FactoryFinder.html#getCRSFactory(org.geotools.factory.Hints)

From that point, you can create yours CRS object in a way similar than the legacy implementation:

CoordinateReferenceSystem horizontalCRS = ...
CoordinateReferenceSystem verticalCRS = crsFactory.createVerticalCRS(...);
CoordinateReferenceSystem crs3D = crsFactory.createCompoundCRS(...);
CoordinateReferenceSystem geoCRS = crsFactory.createGeocentricCRS(...);

Note that creating CRS object from ordinary factories is a tedious task, especially for the ProjectedCRS. An easier way is to use an AuthorityFactory (if possible) at least for the horizontal component. The EPSG database provides many UTM projection. Note that you don't need to download the EPSG database yourself if "gt2-epsg-hsql.jar" and "hdqldb.jar" are in yours classpath.

For example the code below creates the "WGS 84 / UTM zone 15N" CRS (EPSG code "32615"):

CRSAuthorityFactory af = FactoryFinder.getCRSAuthorityFactory("EPSG", null);
CoordinateReferenceSystem horizontalCRS = af.createCoordinateReferenceSystem("EPSG:32615");

The next steps are similar to the old API:

CoordinateOperationFactory opFactory = FactoryFinder.getCoordinateOperationFactory(null);
CoordinateOperation op = opFactory.createOperation(crs3D, geoCRS);

        Martin.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to