Ian Overgard ha scritto:
> Hey guys,
> 
> I'm getting points from NASA's WorldWind as LatLon coordinates and 
> trying to convert them into coordinates in the projection the various 
> shapefiles I'm using have. Here's the code I wrote for that:
> 
> public double[] latLonToProjection( LatLon latlon ) throws Exception {
>         MathTransform t = CRS.findMathTransform(CRS.decode("EPSG:4326"), 
> originalCRS);
>         double[] a = {latlon.getLongitude().getDegrees(),
>                       latlon.getLatitude().getDegrees() };
>         double[] b = { 0, 0 };
>        
>         t.transform(a, 0, b, 0, 1);
>         return b;
>     }
> 
> 
> Whenever I try this though, I get this exception:
> 
> 
> org.opengis.referencing.operation.OperationNotFoundException: Bursa wolf 
> parameters required.
>         at 
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1078)
>         at 
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1145)
>         at 
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:883)
>         at 
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:207)
>         at 
> org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:255)
>         at org.geotools.referencing.CRS.findMathTransform(CRS.java:912)
>         at org.geotools.referencing.CRS.findMathTransform(CRS.java:881)
>         at gtww.ShapeLayer.latLonToProjection(ShapeLayer.java:169)
>         at gtww.ShapeLayer.featureAt(ShapeLayer.java:192)
>         at gtww.ShapeLayer.selected(ShapeLayer.java:286)
>         at 
> gov.nasa.worldwind.awt.AWTInputHandler.callSelectListeners(Unknown Source)
>         at gov.nasa.worldwind.awt.AWTInputHandler.mousePressed(Unknown 
> Source)
>         at 
> java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
>         at java.awt.Component.processMouseEvent(Component.java:6035)
>         at java.awt.Component.processEvent(Component.java:5803)
>         at java.awt.Component.dispatchEventImpl(Component.java:4410)
>         at java.awt.Component.dispatchEvent(Component.java:4240)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
>         at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
>         at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
>         at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
>         at 
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
>         at 
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
>         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
> 
> 
> Any ideas what I'm doing wrong? I'm not very well versed in projections 
> so I'm not sure what Bursa wolf parameters are. Is there perhaps a 
> better way to do this? Mostly I just need this for selection purposes 
> (clicking on the layer in worldwind and figuring out which feature was 
> clicked, for instance).

Bursa Wolf parameters are needed to make an accurate "datum shift" 
(http://en.wikipedia.org/wiki/Datum). If you don't have them, the error 
in the transformation may be like 50-100meters, whilst if you have them,
it's usually around 4m (at least that's what happens in Italy with the
italian datums, not sure about other parts of the world).

If you can accept the lower accuracy, ou can ask for a lenient 
transformation that won't throw an exception by using:
CRS.findMathTransform(CRS.decode("EPSG:4326"), originalCRS, true)

Hope this helps
Cheers
Andrea

-------------------------------------------------------------------------
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-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to