Loïc MAZE a écrit :
Everything works but the result isn't accurate. For example, I have a
point at longitude 5.08° east and at latitude 47.31° north (in WGS84).
The result of the transformation is a point with the following coords :
X = 807332 meters and Y = 2260657 meters.
The correct point will have those coords :
X = 807389 meters and Y = 2260315 meters.
Do you know where the correct point come from? Which parameters were used
for computing it?
The following line added to yours source code:
System.out.println(targetCRS);
produces the following output:
PROJCS["NTF (Paris) / Lambert zone II",
GEOGCS["NTF (Paris)",
DATUM["Nouvelle Triangulation Francaise (Paris)",
SPHEROID["Clarke 1880 (IGN)", 6378249.2, 293.4660212936269,
AUTHORITY["EPSG","7011"]],
AUTHORITY["EPSG","6807"]],
PRIMEM["Paris", 2.5969213, AUTHORITY["EPSG","8903"]],
UNIT["grade", 0.015707963267948967],
AXIS["Geodetic latitude", NORTH],
AXIS["Geodetic longitude", EAST],
AUTHORITY["EPSG","4807"]],
PROJECTION["Lambert Conic Conformal (1SP)", AUTHORITY["EPSG","9801"]],
PARAMETER["central_meridian", 0.0],
PARAMETER["latitude_of_origin", 52.0],
PARAMETER["scale_factor", 0.99987742],
PARAMETER["false_easting", 600000.0],
PARAMETER["false_northing", 2200000.0],
UNIT["m", 1.0],
AXIS["Easting", EAST],
AXIS["Northing", NORTH],
AUTHORITY["EPSG","27572"]]
Note: This is "Well Know Text" format (WKT), which is defined by OGC (not
a custom Geotools format). I understand that it seems unfriendly at a
first look. But it is really worth to become familiar with it, since it is
of great help for understanding what is going on and debugging.
The interesting part is that the SPHEROID[...] element is something else
than "WGS 84" ("Clarke 1880 (IGN)" in the above case), but there is no
TOWGS84[...] element defined. Concequently, Geotools don't know how to
apply a datum shift from "WGS 84" to "Clarke 1880 (IGN)". This is why you
got a "Bursa Wolf parameters required" exception when trying to get the
transformation without Hints.LENIENT_DATUM_SHIFT set to Boolean.TRUE. The
LENIENT_DATUM_SHIFT hint shutdown the warning, but hey! this warning was
telling you that the transformation may be innacurate because some
information are missing, so you are supposed to know what you are doing if
you shutdown the warning and process anyway ;)
The consequence of missing TOWGS84[...] element can be seen if you add the
following line of code:
System.out.println(transform);
It produces the following output:
CONCAT_MT[PARAM_MT["Affine",
PARAMETER["num_row", 3],
PARAMETER["num_col", 3],
PARAMETER["elt_0_0", 0.0],
PARAMETER["elt_0_1", 1.0],
PARAMETER["elt_1_0", 1.0],
PARAMETER["elt_1_1", 0.0]],
PARAM_MT["Molodenski",
PARAMETER["dim", 2],
PARAMETER["dx", 0.0],
PARAMETER["dy", 0.0],
PARAMETER["dz", 0.0],
PARAMETER["src_semi_major", 6378137.0],
PARAMETER["src_semi_minor", 6356752.314245179],
PARAMETER["tgt_semi_major", 6378249.2],
PARAMETER["tgt_semi_minor", 6356515.0]],
PARAM_MT["Affine",
PARAMETER["num_row", 3],
PARAMETER["num_col", 3],
PARAMETER["elt_0_2", -2.33722917]],
PARAM_MT["Lambert_Conformal_Conic_1SP",
PARAMETER["semi_major", 6378249.2],
PARAMETER["semi_minor", 6356515.0],
PARAMETER["central_meridian", 0.0],
PARAMETER["latitude_of_origin", 46.8],
PARAMETER["scale_factor", 0.99987742],
PARAMETER["false_easting", 600000.0],
PARAMETER["false_northing", 2200000.0]]]
The interresting point is that the "dx", "dy" and "dz" parameter values
inside the "Molodenski" block are set to 0. This is a concequence of
missing "TOWGS84[...]" info.
Now, the question is whatever TOWGS84 info should exists or not. Make sure
that *one* of epsg-access, epsg-hsql or epsg-postgresql is in yours
classpath, and make sure that epsg-wkt is *not* in yours classpath
(because epsg-wkt to not contains any TOWGS84 info).
If Geotools still unable to find TOWGS84 info using epsg-access with
latest EPSG database (I tried with EPSG version 6.9), there is two choice:
- Either the info exists but Geotools was unable to find it, in which
case this is a Geotools bug.
- Or either the info do not exists or should not exists in the EPSG
database.
I suggest to search manually in the EPSG database. I did a quick search
(more specifically, I searched for "27572" in both the "Source" and
"Target" columns of "Coordinate_Operation" table) and found nothing. But
it may be worth to try harder (for example search for any coordinate
operation involving the "Clarke 1880 (IGN)" ellipsoid). Try to upgrate to
latest EPSG database if a more recent version is available
(http://www.epsg.org).
If you find an information in the EPSG database that Geotools should have
been able to find by itself, please let me known.
Otherwise, you may try to search outside EPSG (maybe google) for "Bursa
Wolf Parameters", "Molodenski", "Position Vector 7-param. transformation",
"Coordinate Frame rotation" etc. involving "Nouvelle Triangulation
Francaise (Paris)" or "Clarke 1880 (IGN)", and let me know what you find.
Martin.