|
From: Matthias B. <c9...@un...> - 2004-03-15 20:31:52
|
Hi,
I just started using GeoTool2. (I miss some more complete documentation for GT2
users that covers all the subprojects, interactions between them a.s.o. But
this is not the reason I write.)
The first thing I tried was doing coordinate transformations I read the
tutorial, installed the EPSG database and tried following cute program:
---
CoordinateSystemAuthorityFactory epsgFactory
=CoordinateSystemEPSGFactory.getDefault();
CoordinateSystem sourceCS =
epsgFactory.createCoordinateSystem("4326");
//GeographicCoordinateSystem.WGS84;
CoordinateSystem targetCS = epsgFactory.createCoordinateSystem("4314");
CoordinateTransformationFactory trFactory =
CoordinateTransformationFactory.getDefault();
CoordinateTransformation tr =
trFactory.createFromCoordinateSystems(sourceCS, targetCS);
MathTransform transform = tr.getMathTransform();
//CoordinatePoints
CoordinatePoint p1 = new CoordinatePoint(50.96325, 11.62433);
System.out.println(p1.toString());
CoordinatePoint p2 = transform.transform(p1, null);
System.out.println(p2.toString());
---
This produces following correct output:
CoordinatePoint[50.96325, 11.62433]
CoordinatePoint[50.96449359750475, 11.625770335735508]
If I switch x and y and write "new CoordinatePoint(11.62433, 50.96325)" then the
output is wrong:
CoordinatePoint[11.62433, 50.96325]
CoordinatePoint[11.621145239993298, 50.96777586997982]
Question 1: Is it correct that in GeoTools reads and write coordinates as "(LAT,
LON)"? From above test I assume this is the case, even though the call to
create a new Coordinate Point is "= new CoordinatePoint(x, y);", which I would
interpret as (LON, LAT).
OK. I can live with (LAT, LON) although I think this should definitly be better
documented (e.g. in the JavaDoc for this constructor).
But what drives me mad is when I replace
= epsgFactory.createCoordinateSystem("4326");
by
= GeographicCoordinateSystem.WGS84; or, which is the same
= new GeographicCoordinateSystem("WGS84", HorizontalDatum.WGS84));
(See the annotation in the code above.)
Now I get following output:
CoordinatePoint[50.96325, 11.62433]
CoordinatePoint[11.621145239993314, 50.96777586997987]
..which of course is wrong AND inconsistent.
Therefore Question 2: Why does a manually created coordinate system obviously
use (LON, LAT) whereas EPSG coordiante systems use (LAT, LON). This is IMHO a
mess and - as the above example shows - can lead to fatal errors.
What should I think of this? What is correct, what is wrong or what's the deeper
sense behind this?
Matthias Basler
c9...@un...
-----------------------------------------------------
This mail was sent through http://webmail.uni-jena.de
|