Thanks for the help Larry and Andrea.. reordering the coordinate order
worked.. mostly :)

I am now having a problem getting the correct CRS from my feature when
transforming it. I know the feature has the CRS EPSG:4269 (that is the
CRS it has on the WFS) and running the following code gave the output:

Code:
CoordinateReferenceSystem dataCRS =
feature.getType().getCoordinateReferenceSystem();
System.out.println(dataCRS.toString());
boolean lenient = true; // allow for some error due to different datums
MathTransform transform = CRS.findMathTransform( dataCRS,
CRS.decode("EPSG:4326"), lenient );
Geometry geomConverted = JTS.transform(geotoolsGeom, transform);

System Output:
 GEOGCS["NAD83", 
  DATUM["North American Datum 1983", 
    SPHEROID["GRS 1980", 6378137.0, 298.257222101,
AUTHORITY["EPSG","7019"]], 
    TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0], 
    AUTHORITY["EPSG","6269"]], 
  PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
  UNIT["degree", 0.017453292519943295], 
  AXIS["Geodetic latitude", NORTH], 
  AXIS["Geodetic longitude", EAST], 
  AUTHORITY["EPSG","4269"]]

This seems like it should work however running the above transform gives
incorrect results. I hard coded the transformation (shown below) and got
the correct transformation results.
MathTransform transform = CRS.findMathTransform(
CRS.decode("EPSG:4269"), CRS.decode("EPSG:4326"), lenient );

So is feature.getType().getCoordinateReferenceSystem() the wrong way to
get a feature's CRS.. and ifso how should the correct way look? 

Thanks,
Dan

-----Original Message-----
From: Andrea Aime [mailto:[email protected]] 
Sent: Thursday, March 18, 2010 2:54 AM
To: Bellinski, Dan
Cc: [email protected]
Subject: Re: [Geotools-gt2-users] Math transform to EPSG:4326 giving odd
results

Bellinski, Dan ha scritto:

> And storing it in the oracle DB yields the point:
> 
>
MDSYS.SDO_GEOMETRY(2003,4326,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1,776
9,2003,1),MDSYS.SDO_ORDINATE_ARRAY(-57.0903920409945,-141.67926099,-57.0
926290409912,-141.67983399...
> 
>  
> 
> The transformed point seems to be in the form:  (-180 - (lat coord1), 
> 180 + (lat coord2)) ... but 4269 and 4326 are very similar coordinate 
> systems and should barely differ when transformed. Am I doing
something 
> wrong?

You're probably not telling GeoTools you want to work in lon/lat order,
and referencing defaults to lat/lon order instead.
Add:

Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER,
Boolean.TRUE);

at the beginning of your app and it should work fine

Cheers
Andrea


-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.





------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to