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!
All I want to do is to be able to do the following transforms...
UTM (with altitude) -> Geocentric
Geocentric -> UTM (with altitude)
Can anyone help me out?
From: Martin Desruisseaux <martin.desruisseaux@no...> - 2006-01-26 20:55:10
Newcomb, Michael-P57487 a =E9crit :
> What is going on? I'm trying to upgrade from an early 2.0 release and i=
> 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 i=
(i.e. "opengis" instead of "geotools"). It is an interface from the=20
In summary: the Open Geospatial (OGC) specification changed. They=20
uniformized their specification with the ISO equivalent. Consequently,=20
the legacy OGC "Coordinate Transformation Services" specification has=20
been replaced by ISO 19111. The deprecated class in Geotools and the new=20
implementation reflect that changes.
I agree that it is a pain for users to migrate the API. On the bright=20
side, I think that the ISO 19111 API has real advantages over the old=20
OGC ones. For example it was not possible to know for sure if a=20
coordinate system is cartesian with the legacy OGC API, while the ISO=20
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 =3D FactoryFinder.getCRSFactory(null);
FactoryFinder live in org.geotools.referencing and returns=20
implementation of various GeoAPI interfaces, including=20
From that point, you can create yours CRS object in a way similar than=20
the legacy implementation:
CoordinateReferenceSystem horizontalCRS =3D ...
CoordinateReferenceSystem verticalCRS =3D crsFactory.createVerticalCRS(..=
CoordinateReferenceSystem crs3D =3D crsFactory.createCompoundCRS(...);
CoordinateReferenceSystem geoCRS =3D crsFactory.createGeocentricCRS(...);
Note that creating CRS object from ordinary factories is a tedious task,=20
especially for the ProjectedCRS. An easier way is to use an=20
AuthorityFactory (if possible) at least for the horizontal component.=20
The EPSG database provides many UTM projection. Note that you don't need=20
to download the EPSG database yourself if "gt2-epsg-hsql.jar" and=20
"hdqldb.jar" are in yours classpath.
For example the code below creates the "WGS 84 / UTM zone 15N" CRS (EPSG=20
CRSAuthorityFactory af =3D FactoryFinder.getCRSAuthorityFactory("EPSG", n=
CoordinateReferenceSystem horizontalCRS =3D=20
The next steps are similar to the old API:
CoordinateOperationFactory opFactory =3D=20
CoordinateOperation op =3D opFactory.createOperation(crs3D, geoCRS);