Milton Jonathan ha scritto:
Hi there

Once again, the axis issue attacked me :P. I guess this may have something to do with changes from 2.5.x to 2.6.x (has LONGITUDE_FIRST become the default now?).

The situation is like this: I have a (valid) WKT generated for a Projected CRS with longitude first (it is a SouthAmericanDatum1969 with a UTM projection). When I try to lookup its epsg code, it tries, tries, and fails. But it fails due to the axis order of the DATUM (i.e., not due to the projected part).

To illustrate, here goes the code that fails:

String wkt = "PROJCS[\"SAD69 / UTM zone 23S\"," +
"GEOGCS[\"SAD69\"," +
"DATUM[\"South American Datum 1969\"," +
"SPHEROID[\"GRS 1967 (SAD69)\", 6378160.0, 298.25, AUTHORITY[\"EPSG\",\"7050\"]]," +
"TOWGS84[-66.87, 4.37, -38.52, 0.0, 0.0, 0.0, 0.0]," +
"AUTHORITY[\"EPSG\",\"6618\"]]," +
"PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]]," +
"UNIT[\"degree\", 0.017453292519943295]," +
"AXIS[\"Geodetic longitude\", EAST]," +
"AXIS[\"Geodetic latitude\", NORTH]," +
"AUTHORITY[\"EPSG\",\"4618\"]]," +
"PROJECTION[\"Transverse Mercator\", AUTHORITY[\"EPSG\",\"9807\"]]," +
"PARAMETER[\"central_meridian\", -45.0]," +
"PARAMETER[\"latitude_of_origin\", 0.0]," +
"PARAMETER[\"scale_factor\", 0.9996]," +
"PARAMETER[\"false_easting\", 500000.0]," +
"PARAMETER[\"false_northing\", 10000000.0]," +
"UNIT[\"m\", 1.0]," +
"AXIS[\"Easting\", EAST]," +
"AXIS[\"Northing\", NORTH]]";

CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
Integer srid = CRS.lookupEpsgCode(crs, true);

Milton, I just tried your code on my computer and the lookup
returns back 29193 for me, no matter how I set the
axis order hints (or even if I set them at all).

Full program attached. What am I missing?

Cheers
Andrea


--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
import org.geotools.referencing.CRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;


public class WktDecoder {
    public static void main(String[] args) throws Exception {
        // uncomment either of these, makes no difference
        // GeoTools.init(new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE));
        // System.setProperty("org.geotools.referencing.forceXY", "true");
        
        String wkt = "PROJCS[\"SAD69 / UTM zone 23S\"," +
        "GEOGCS[\"SAD69\"," +
        "DATUM[\"South American Datum 1969\"," +
        "SPHEROID[\"GRS 1967 (SAD69)\", 6378160.0, 298.25, AUTHORITY[\"EPSG\",\"7050\"]]," +
        "TOWGS84[-66.87, 4.37, -38.52, 0.0, 0.0, 0.0, 0.0]," +
        "AUTHORITY[\"EPSG\",\"6618\"]]," +
        "PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]]," +
        "UNIT[\"degree\", 0.017453292519943295]," +
        "AXIS[\"Geodetic longitude\", EAST]," +
        "AXIS[\"Geodetic latitude\", NORTH]," +
        "AUTHORITY[\"EPSG\",\"4618\"]]," +
        "PROJECTION[\"Transverse Mercator\", AUTHORITY[\"EPSG\",\"9807\"]]," +
        "PARAMETER[\"central_meridian\", -45.0]," +
        "PARAMETER[\"latitude_of_origin\", 0.0]," +
        "PARAMETER[\"scale_factor\", 0.9996]," +
        "PARAMETER[\"false_easting\", 500000.0]," +
        "PARAMETER[\"false_northing\", 10000000.0]," +
        "UNIT[\"m\", 1.0]," +
        "AXIS[\"Easting\", EAST]," +
        "AXIS[\"Northing\", NORTH]]";

        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
        System.out.println(crs);
        Integer srid = CRS.lookupEpsgCode(crs, true);
        System.out.println("Lookup result: " + srid);
        
        System.out.println(CRS.decode("EPSG:29193"));
    }
}
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to