Geo-api does not enter into it; it comes down to what version of 
GeoTools you are using (2.4.2 perhaps?) and what version of the 
epsg-xxxx.jar you are using (epsg-hsql is the most accurate but requires 
a temp file, epsg-wkt is only suitable for applets etc...). It is also 
really really common to confuse your axis order; getting them the wrong 
way around is how I usually manage to get 100m out :-)

Cheers,
Jody
> Can anybody help with this? I have latitude and longitude(34.7473139, 
> 45.0638444) for a shot point. When I used WGS84 to generate segp file I 
> got about 98 meters difference for "Easting" value comparing with the 
> original segp file. The following is the fragment of the codes. All 
> classes I used are from geoapi-nogenerics-2.1-M2.jar. Did I use the 
> wrong classes? Thanks very much.
>
> CRSAuthorityFactory crsFactory = 
> FactoryFinder.getCRSAuthorityFactory("EPSG", null);
> CoordinateReferenceSystem crs = 
> crsFactory.createCoordinateReferenceSystem("WGS 84 / UTM zone 38N");
> CoordinateReferenceSystem crsNad27 = 
> crsFactory.createCoordinateReferenceSystem("NAD27"); 
> DirectPosition pt1 = new GeneralDirectPosition(34.7473139, 45.0638444);
> ((GeneralDirectPosition)pt1).setCoordinateReferenceSystem(crsNad27);  
> GeotoolsCoordinateConverter converter = new 
> GeotoolsCoordinateConverter();  --- my class implementing 
> CoordinateConverter
> DirectPosition pt2 = converter.convert(pt1, crs);
> System.out.println(pt2);   -------------------- The result I got is 
> (505,942.407    3,844,897.644); but the value from original segp file is 
> (505,843.7       3,845,023.5), almost 100 meters difference. This 
> difference is very big.
>
> public class GeotoolsCoordinateConverter implements CoordinateConverter
> {
>   protected CoordinateOperationFactory coFactory;
>  
>   public GeotoolsCoordinateConverter()
>   {
>     coFactory = FactoryFinder.getCoordinateOperationFactory(null);    
>   }
>  
>   public DirectPosition convert(DirectPosition pt, 
> CoordinateReferenceSystem toCrs)
>   {
>     CoordinateOperation transform = null;
>    
>     try
>     {
>       transform = 
> coFactory.createOperation(pt.getCoordinateReferenceSystem(), toCrs);
>     }
>     catch (OperationNotFoundException e)
>     { e.printStackTrace(); }
>     catch (FactoryException e)
>     { e.printStackTrace(); }
>    
>     MathTransform trans = transform.getMathTransform();
>     DirectPosition pt2 = null;
>    
>     try
>     { pt2 = trans.transform(pt, null); }
>     catch (MismatchedDimensionException e)
>     { e.printStackTrace(); }
>     catch (TransformException e)
>     { e.printStackTrace(); }
>     return pt2;
>   }
> } 
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Geotools-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to