You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@sis.apache.org by Thierry Danard <th...@int.com> on 2019/12/03 16:42:05 UTC
Comparing results with GIGS test #5207
Hello,
I have started testing Apache SIS using GIGS tests (
https://www.iogp.org/geomatics/#gigs). I wrote the following code for the
test #5207:
public class Test5207Ntv2 {
@Test
public void part1_Australia() throws FactoryException, Exception {
CoordinateReferenceSystem eps4202 = CRS.forCode("EPSG:4202");
CoordinateReferenceSystem eps4283 = CRS.forCode("EPSG:4283");
double inputLat = -12;
double inputLong = -115;
double resultLat = -11.9986441666667; // From GIGS Test5207
double resultLong =-115.001261388889; // from GIGS Test5207
CoordinateOperation operation =
TransformUtil.getCoordinateTransformForPoint(eps4202, eps4283, inputLong,
inputLat);
System.out.println(operation.toString());
DirectPosition position = new DirectPosition2D(inputLat, inputLong);
double[] coordinate =
operation.getMathTransform().transform(position, position).getCoordinate();
Assert.assertEquals(resultLat, coordinate[0], 0.001);
Assert.assertEquals(resultLong, coordinate[1], 0.001);
}
The test fails:
[image: image.png]
I did check that NTV2 grids were used. This is the description of the
operation, confirming that the A66 National (13.09.01).gsb NTV2 file is
used.
CoordinateOperation["AGD66 to GDA94 (11)",
SourceCRS[GeodeticCRS["AGD66",
Datum["Australian Geodetic Datum 1966",
Ellipsoid["Australian National Spheroid", 6378160.0, 298.25]],
CS[ellipsoidal, 2],
Axis["Geodetic longitude (Lon)", east],
Axis["Geodetic latitude (Lat)", north],
Unit["degree", 0.017453292519943295]]],
TargetCRS[GeodeticCRS["GDA94",
Datum["Geocentric Datum of Australia 1994",
Ellipsoid["GRS 1980", 6378137.0, 298.257222101]],
CS[ellipsoidal, 2],
Axis["Geodetic longitude (Lon)", east],
Axis["Geodetic latitude (Lat)", north],
Unit["degree", 0.017453292519943295]]],
Method["NTv2"],
Parameter["Latitude and longitude difference file", "A66 National
(13.09.01).gsb"],
OperationAccuracy[0.1],
Scope["0.1m accuracy."],
Area["Australia - Australian Capital Territory; New South Wales; Northern
Territory; Queensland; South Australia; Tasmania; Western Australia;
Victoria."],
BBox[-43.70, 112.85, -9.86, 153.69],
Remark["Replaces AGD66 to GDA94 variants 6, 7 and 10 (codes 1506 1507
1596). Input expects longitudes to be positive west; EPSG GeogCRS AGD66
(code 4202) and GDA94 (code 4283) both have longitudes positive east. May
be used as tfm to WGS 84 - see code 15786."]]
Why is there a discrepency in the conversion results compared to the GIGS
test? Is it something I am doing wrong?
-Thierry
Re: Comparing results with GIGS test #5207
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Thierry
Thanks for the information. I will investigate in the next few days I
will try to report before Monday.
Martin
Le 03/12/2019 à 22:49, Thierry Danard a écrit :
> Thank you
> Flipping the coordinates doesn't solve the problem
>
> Here is the updated code:
>
> (...snip...)
Re: Comparing results with GIGS test #5207
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Le 16/12/2019 à 16:12, Thierry Danard a écrit :
> Yes, it works if I fix the longitude sign, and make it first. Thank you
>
Thanks for letting us know. Just for information, the expected sign of
longitude values is also given by the WKT:
> Axis["Geodetic longitude (Lon)", east],
>
The "east" value in above string means that longitude are positive east.
It is also possible to have longitude positive west if desired (was used
in USA and Canada, also used in astronomy); SIS adjusts the sign
automatically to match the WKT definition.
Martin
Re: Comparing results with GIGS test #5207
Posted by Thierry Danard <th...@int.com>.
Yes, it works if I fix the longitude sign, and make it first. Thank you
On Wed, Dec 11, 2019 at 2:56 AM Martin Desruisseaux <
martin.desruisseaux@geomatys.com> wrote:
> Hello Thierry
>
> Indeed from the WKT below, longitude is first. I do not know yet why we
> got different string (I should look again at the test code). Have you tried
> with longitude first again, but fixing only the longitude sign?
>
> Martin
>
> Le 11/12/2019 à 00:50, Thierry Danard a écrit :
>
> Thank you
> It does work using your method.
>
> I was wondering, I got this operation string, how do you know from this
> operation string whether longitude or latitude is first? I would have
> assumed longitude is first from the string.
>
> CoordinateOperation["AGD66 to GDA94 (11)",
> SourceCRS[GeodeticCRS["AGD66",
> Datum["Australian Geodetic Datum 1966",
> Ellipsoid["Australian National Spheroid", 6378160.0, 298.25]],
> CS[ellipsoidal, 2],
> Axis["Geodetic longitude (Lon)", east],
> Axis["Geodetic latitude (Lat)", north],
> Unit["degree", 0.017453292519943295]]],
> TargetCRS[GeodeticCRS["GDA94",
> Datum["Geocentric Datum of Australia 1994",
> Ellipsoid["GRS 1980", 6378137.0, 298.257222101]],
> CS[ellipsoidal, 2],
> Axis["Geodetic longitude (Lon)", east],
> Axis["Geodetic latitude (Lat)", north],
> Unit["degree", 0.017453292519943295]]],
> Method["NTv2"],
> Parameter["Latitude and longitude difference file", "A66 National
> (13.09.01).gsb"],
> OperationAccuracy[0.1],
> Scope["0.1m accuracy."],
> Area["Australia - Australian Capital Territory; New South Wales;
> Northern Territory; Queensland; South Australia; Tasmania; Western
> Australia; Victoria."],
> BBox[-43.70, 112.85, -9.86, 153.69],
> Remark["Replaces AGD66 to GDA94 variants 6, 7 and 10 (codes 1506 1507
> 1596). Input expects longitudes to be positive west; EPSG GeogCRS AGD66
> (code 4202) and GDA94 (code 4283) both have longitudes positive east. May
> be used as tfm to WGS 84 - see code 15786."]]
>
>
>
Re: Comparing results with GIGS test #5207
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Thierry
Indeed from the WKT below, longitude is first. I do not know yet why we
got different string (I should look again at the test code). Have you
tried with longitude first again, but fixing only the longitude sign?
Martin
Le 11/12/2019 à 00:50, Thierry Danard a écrit :
> Thank you
> It does work using your method.
>
> I was wondering, I got this operation string, how do you know from
> this operation string whether longitude or latitude is first? I would
> have assumed longitude is first from the string.
>
> CoordinateOperation["AGD66 to GDA94 (11)",
> SourceCRS[GeodeticCRS["AGD66",
> Datum["Australian Geodetic Datum 1966",
> Ellipsoid["Australian National Spheroid", 6378160.0, 298.25]],
> CS[ellipsoidal, 2],
> Axis["Geodetic longitude (Lon)", east],
> Axis["Geodetic latitude (Lat)", north],
> Unit["degree", 0.017453292519943295]]],
> TargetCRS[GeodeticCRS["GDA94",
> Datum["Geocentric Datum of Australia 1994",
> Ellipsoid["GRS 1980", 6378137.0, 298.257222101]],
> CS[ellipsoidal, 2],
> Axis["Geodetic longitude (Lon)", east],
> Axis["Geodetic latitude (Lat)", north],
> Unit["degree", 0.017453292519943295]]],
> Method["NTv2"],
> Parameter["Latitude and longitude difference file", "A66 National
> (13.09.01).gsb"],
> OperationAccuracy[0.1],
> Scope["0.1m accuracy."],
> Area["Australia - Australian Capital Territory; New South Wales;
> Northern Territory; Queensland; South Australia; Tasmania; Western
> Australia; Victoria."],
> BBox[-43.70, 112.85, -9.86, 153.69],
> Remark["Replaces AGD66 to GDA94 variants 6, 7 and 10 (codes 1506
> 1507 1596). Input expects longitudes to be positive west; EPSG GeogCRS
> AGD66 (code 4202) and GDA94 (code 4283) both have longitudes positive
> east. May be used as tfm to WGS 84 - see code 15786."]]
Re: Comparing results with GIGS test #5207
Posted by Thierry Danard <th...@int.com>.
Thank you
It does work using your method.
I was wondering, I got this operation string, how do you know from this
operation string whether longitude or latitude is first? I would have
assumed longitude is first from the string.
CoordinateOperation["AGD66 to GDA94 (11)",
SourceCRS[GeodeticCRS["AGD66",
Datum["Australian Geodetic Datum 1966",
Ellipsoid["Australian National Spheroid", 6378160.0, 298.25]],
CS[ellipsoidal, 2],
Axis["Geodetic longitude (Lon)", east],
Axis["Geodetic latitude (Lat)", north],
Unit["degree", 0.017453292519943295]]],
TargetCRS[GeodeticCRS["GDA94",
Datum["Geocentric Datum of Australia 1994",
Ellipsoid["GRS 1980", 6378137.0, 298.257222101]],
CS[ellipsoidal, 2],
Axis["Geodetic longitude (Lon)", east],
Axis["Geodetic latitude (Lat)", north],
Unit["degree", 0.017453292519943295]]],
Method["NTv2"],
Parameter["Latitude and longitude difference file", "A66 National
(13.09.01).gsb"],
OperationAccuracy[0.1],
Scope["0.1m accuracy."],
Area["Australia - Australian Capital Territory; New South Wales; Northern
Territory; Queensland; South Australia; Tasmania; Western Australia;
Victoria."],
BBox[-43.70, 112.85, -9.86, 153.69],
Remark["Replaces AGD66 to GDA94 variants 6, 7 and 10 (codes 1506 1507
1596). Input expects longitudes to be positive west; EPSG GeogCRS AGD66
(code 4202) and GDA94 (code 4283) both have longitudes positive east. May
be used as tfm to WGS 84 - see code 15786."]]
On Sun, Dec 8, 2019 at 10:48 AM Martin Desruisseaux <
martin.desruisseaux@geomatys.com> wrote:
> Hello Thierry
>
> I had a chance to test. The GIGS 5207 test passed on my machine providing
> that we apply the following 2 or 3 modifications on the test code:
>
> 1) As shown by System.out.println(operation) line, that coordinate
> operation expects coordinates in (latitude, longitude) order. The results
> are also produced in that order, so the change applied to 6 places.
> Expected code:
>
> - new DirectPosition2D(inputLat, inputLong) (2 occurrences)
> - assertEquals(inputLat, coordinate[0], 0.001) (2 occurrences)
> - assertEquals(inputLong, coordinate[1], 0.001) (2 occurrences)
>
> 2) Another change is that coordinates in Australia are in the East
> hemisphere, so the longitudes need to be positive. I saw that the GIGS
> Excel files put negative values, but I think it is because they applied the
> change described in cell A33, which said "The NTv2 routine requires
> longitudes to be positive west. The application being tested is expected to
> be able to handle the change of sign". Expected code:
>
> - double inputLong = 115;
> - double resultLong = 115.001261388889; // from GIGS Test5207
>
> 3) A last change is in the order of coordinates given to
> DefaultGeographicBoundingBox constructor, which is not the same than in
> WKT BBOX element (GeographicBoundingBox follows the order used by ISO
> 19115). It should be as below (however this change has no effect on the
> result in this case):
>
> - new DefaultGeographicBoundingBox(lng, lng, lat, lat)
>
> With those changes, the test passed on my machine. Please let me know if
> it is not the case on your side.
>
> Regards,
>
> Martin
>
> P.S.: during the tests, a noticed a SIS bug in the coordinate operation
> name. This bug happens only in some cases and has no incidence on the
> numerical results however: https://issues.apache.org/jira/browse/SIS-483
>
>
>
Re: Comparing results with GIGS test #5207
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Thierry
I had a chance to test. The GIGS 5207 test passed on my machine
providing that we apply the following 2 or 3 modifications on the test code:
1) As shown by System.out.println(operation) line, that coordinate
operation expects coordinates in (latitude, longitude) order. The
results are also produced in that order, so the change applied to 6
places. Expected code:
* new DirectPosition2D(inputLat, inputLong) (2 occurrences)
* assertEquals(inputLat, coordinate[0], 0.001) (2 occurrences)
* assertEquals(inputLong, coordinate[1], 0.001) (2 occurrences)
2) Another change is that coordinates in Australia are in the East
hemisphere, so the longitudes need to be positive. I saw that the GIGS
Excel files put negative values, but I think it is because they applied
the change described in cell A33, which said "The NTv2 routine requires
longitudes to be positive west. The application being tested is expected
to be able to handle the change of sign". Expected code:
* double inputLong = 115;
* double resultLong = 115.001261388889; // from GIGS Test5207
3) A last change is in the order of coordinates given to
DefaultGeographicBoundingBox constructor, which is not the same than in
WKT BBOX element (GeographicBoundingBox follows the order used by ISO
19115). It should be as below (however this change has no effect on the
result in this case):
* new DefaultGeographicBoundingBox(lng, lng, lat, lat)
With those changes, the test passed on my machine. Please let me know if
it is not the case on your side.
Regards,
Martin
P.S.: during the tests, a noticed a SIS bug in the coordinate operation
name. This bug happens only in some cases and has no incidence on the
numerical results however: https://issues.apache.org/jira/browse/SIS-483
Re: Comparing results with GIGS test #5207
Posted by Thierry Danard <th...@int.com>.
Thank you
Flipping the coordinates doesn't solve the problem
Here is the updated code:
public void part1_Australia() throws FactoryException, Exception {
CoordinateReferenceSystem eps4202 = CRS.forCode("EPSG:4202");
CoordinateReferenceSystem eps4283 = CRS.forCode("EPSG:4283");
double inputLat = -12;
double inputLong = -115;
double resultLat = -11.9986441666667; // From GIGS Test5207
double resultLong =-115.001261388889; // from GIGS Test5207
CoordinateOperation operation =
TransformUtil.getCoordinateTransformForPoint(eps4202, eps4283, inputLong,
inputLat);
System.out.println(operation.toString());
DirectPosition position = new DirectPosition2D(inputLong, inputLat);
double[] coordinate =
operation.getMathTransform().transform(position, position).getCoordinate();
Assert.assertEquals(resultLong, coordinate[0], 0.001);
Assert.assertEquals(resultLat, coordinate[1], 0.001);
// The other way around
operation = TransformUtil.getCoordinateTransformForPoint(eps4283,
eps4202, inputLong, inputLat);
position = new DirectPosition2D(resultLong, resultLat);
coordinate = operation.getMathTransform().transform(position,
position).getCoordinate();
Assert.assertEquals(inputLong, coordinate[0], 0.001);
Assert.assertEquals(inputLat, coordinate[1], 0.001);
}
and
public class TransformUtil {
// Area of use will be calculated from single point
public static CoordinateOperation
getCoordinateTransformForPoint(CoordinateReferenceSystem fromCRS,
CoordinateReferenceSystem toCRS, double lng, double lat) throws
FactoryException {
DefaultGeographicBoundingBox bb = new
DefaultGeographicBoundingBox(lng, lat, lng, lat);
return CRS.findOperation(fromCRS, toCRS, bb);
}
}
On Tue, Dec 3, 2019 at 11:53 AM Martin Desruisseaux <
martin.desruisseaux@geomatys.com> wrote:
> Hello Thierry
>
> I did not looked fully at the test yet, but a first look at the code and
> WKT make me suspect an axis order issue. The code contains the following
> line:
>
> Le 03/12/2019 à 17:42, Thierry Danard a écrit :
>
> DirectPosition position = new DirectPosition2D(inputLat, inputLong);
>
> which (latitude, longitude), but the WKT shows the following:
>
> SourceCRS[GeodeticCRS["AGD66", (...snip...)
> CS[ellipsoidal, 2],
> Axis["Geodetic longitude (Lon)", east],
> Axis["Geodetic latitude (Lat)", north]
>
> which is (longitude, latitude). Can you check if it solves the problem?
>
> As a side note, we started to implement GIGS tests in GeoAPI a long time
> ago. Those tests are designed for execution with any GeoAPI implementation,
> not only Apache SIS. It does not yet cover the 5000 series, but I have this
> long standing which to complete those tests some day.
>
>
> https://github.com/opengeospatial/geoapi/tree/master/geoapi-conformance/src/main/java/org/opengis/test/referencing/gigs
>
> Second note: EPSG is in process of updating the GIGS tests right now. I do
> not know when the updated version will be ready.
>
> Martin
>
>
>
Re: Comparing results with GIGS test #5207
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Thierry
I did not looked fully at the test yet, but a first look at the code and
WKT make me suspect an axis order issue. The code contains the following
line:
Le 03/12/2019 à 17:42, Thierry Danard a écrit :
> DirectPosition position = new DirectPosition2D(inputLat, inputLong);
>
which (latitude, longitude), but the WKT shows the following:
> SourceCRS[GeodeticCRS["AGD66", (...snip...)
> CS[ellipsoidal, 2],
> Axis["Geodetic longitude (Lon)", east],
> Axis["Geodetic latitude (Lat)", north]
which is (longitude, latitude). Can you check if it solves the problem?
As a side note, we started to implement GIGS tests in GeoAPI a long time
ago. Those tests are designed for execution with any GeoAPI
implementation, not only Apache SIS. It does not yet cover the 5000
series, but I have this long standing which to complete those tests some
day.
https://github.com/opengeospatial/geoapi/tree/master/geoapi-conformance/src/main/java/org/opengis/test/referencing/gigs
Second note: EPSG is in process of updating the GIGS tests right now. I
do not know when the updated version will be ready.
Martin