Hi Martin,<br><br>Thanks for your reply. It turns out that the exception is caused by a weird interaction between GTK and the GWT (Google Web Toolkit) &quot;devmode&quot; (the coordinate conversion is happening in the back-end of a GWT/Java web app). For the record, this is the exception:<br>
<br><span style="font-family: courier new,monospace;">Caused by: java.lang.RuntimeException: java.lang.ClassCastException: class org.geotoolkit.referencing.operation.DefaultMathTransformFactory</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">     at com.example.LonLatConverter.toLonLat(LonLatConverter.java:47)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">...</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Caused by: java.lang.ClassCastException: class org.geotoolkit.referencing.operation.DefaultMathTransformFactory</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">     at java.lang.Class.asSubclass(Class.java:3018)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     at org.geotoolkit.factory.FactoryRegistry.register(FactoryRegistry.java:921) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    at org.geotoolkit.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:793) </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    at org.geotoolkit.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:843) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    at org.geotoolkit.factory.FactoryRegistry.getServiceProviders(FactoryRegistry.java:236) </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    at com.example.LonLatConverter.getMathTransformFactory(LonLatConverter.java:71) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    at com.example.LonLatConverter.toLonLat(LonLatConverter.java:35) </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">...</span><br>
<br>My current work-around is to use the GWT Eclipse Plug-in. That doesn&#39;t throw the exception, nor does building the war and deploying the web-app to either Tomcat or Jetty. All very strange, but I&#39;m happy to ignore it for now.<br>
<br>Thanks again for your help,<br><br>dan<br><br><br><div class="gmail_quote">On 3 March 2010 12:35, Martin Desruisseaux <span dir="ltr">&lt;<a href="mailto:martin.desruisseaux@geomatys.fr">martin.desruisseaux@geomatys.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello Dan<br>
<br>
I just tried to executed the code snippet that you sent, replacing &quot;GeoLocation&quot; and &quot;Vector2D&quot; by Point2D.Double since I do not have those classes. I did not get any exception. However there is some tips that may make things easier (I will add them to the referencing FAQ later).<br>

<br>
<br>
Le 03/03/10 12:15, dan twining a écrit :<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
public GeoLocation toLonLat(Vector2D location) {<br></div>
  (...snip...)<div class="im"><br>
  MathTransform tr = getMathTransform(factory);<br>
  DirectPosition sourcePt = new GeneralDirectPosition(location.getX(), location.getY());<br>
  DirectPosition targetPt = tr.transform(sourcePt, null);<br></div>
  (...snip...)<br>
}<br>
</blockquote>
<br>
It is worth to point out that this method is called &quot;toLonLat&quot; but is actually projecting from &quot;geographic&quot; to UTM, since the map projection created in the &quot;getMathTransform()&quot; method. Not sure if it is relevant...<br>

<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
private MathTransformFactory getMathTransformFactory() {<br>
  if (factory == null) {<br>
    FactoryRegistry registry = new FactoryRegistry(MathTransformFactory.class);<br></div>
    factory = registry.getServiceProvider(MathTransformFactory.class, ...);<br>
  }<br>
  return factory;<br>
}<br>
</blockquote>
<br>
Mentioning just in case, you can also just invoke the FactoryFinder.getMathTransformFactory(null) static method.<br>
<br>
<a href="http://www.geotoolkit.org/apidocs/org/geotoolkit/factory/FactoryFinder.html#getMathTransformFactory%28org.geotoolkit.factory.Hints%29" target="_blank">http://www.geotoolkit.org/apidocs/org/geotoolkit/factory/FactoryFinder.html#getMathTransformFactory%28org.geotoolkit.factory.Hints%29</a><br>

<br>
A note about the getMathTransform(...) method. The code snippet that you send it correct (if you still have the ClassCastException, maybe posting the stack trace would help?) Just mentioning in case, an alternative is also to apply the usual 2 step approach:<br>

<br>
1) Define your source and target CRS where:<br>
  - The source is DefaultGeographicCRS.WGS84<br>
  - The target can be created with either of the following:<br>
    * CRS.decode(&quot;EPSG:&quot; + (32600 + zone)) where &#39;zone&#39; is<br>
      the UTM zone (this require the EPSG database - use<br>
      32700 instead of 32600 if you want South hemisphere);<br>
    * CRS.decode(&quot;AUTO:42002,long,lat&quot;) where &#39;long&#39; and &#39;lat&#39;<br>
      are your central latitude and meridian.<br>
<br>
2) Get your MathTransform with CRS.findMathTransform(sourceCRS,<br>
   targetCRS);<br>
<br>
This is more heavy than your approach (use it only if performance is not critical in this area of your code), but using CoordinateReferenceSystem objects that you can associate with your coordinates is often a recommanded approach, a little bit like associating Unit with measurement values.<br>

<br>
        Regards,<br>
<br>
                Martin<br>
_______________________________________________<br>
Geotoolkit mailing list<br>
<a href="mailto:Geotoolkit@lists.osgeo.org" target="_blank">Geotoolkit@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geotoolkit" target="_blank">http://lists.osgeo.org/mailman/listinfo/geotoolkit</a><br>
</blockquote></div><br>