From: Rueben S. <r_j...@ya...> - 2004-03-16 04:28:50
|
To Matthias, Glad to hear the tutorial was useful :). You may be the first new geotools user to use it. Unfortunately tutorials for most other modules have not yet been written. You may be interested in the new geotools wiki that was created last week at http://docs.codehaus.org/display/GEOTOOLS/Home. It does not have much information yet, but will hopefully be helpful in a few months. You are not the first person to have this problem, so I will need to clarify this the next time I work on the tutorial (probably May). The problem you are having is that CTS is too flexible for its own good. It allows coordinates to be given in any order. The axis order for a coordinate system can be discovered from CoordinateSystem::getAxis(dimension). In the cts tutorial, example 5 (Creating a Geographic Coordinate System (NAD 27)), I created a coordinate system that was (LATITUDE, LONGITUDE). In this case CoordinateSystem.getAxis(0) should return an AxisInfo object with a name of "Latitude" and an AxisOrientation of north. (also note that the AxisOrientation can vary, creating even more confusion). Some further answers to your questions are below. Rueben On Mon, 2004-03-15 at 12:31, Matthias Basler wrote: > 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). No. This is a bad assumption. As mentioned above, the order of the axis is a property of the coordinate system and can change. It looks like CoordinateSystemEPSGFactory is creating the axis information in the order that records are returned from the epsg_coordinateaxis table. In this case it happens to be (Lat, long). If you print out the coordinate system (System.out.println(sourceCS);) you will get the wkt that should be like the following: GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree of angle",0.017453292519943295], AXIS["Geodetic latitude",NORTH], AXIS["Geodetic longitude",EAST], AUTHORITY["EPSG","4326"]] Note that the axis order is given as: AXIS["Geodetic latitude",NORTH], AXIS["Geodetic longitude",EAST]. > > 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. This is because the axis order for GeographicCoordinateSystem.WGS84 is created with the default for a GeographicCoordinateSystem: (Long, Lat). > > What should I think of this? What is correct, what is wrong or what's the deeper > sense behind this? Hopefully I answered this above. > > Matthias Basler > c9...@un... > > ----------------------------------------------------- > This mail was sent through http://webmail.uni-jena.de > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Geotools-gt2-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |