Hi!
It is probably just me being stupid, but just in case anyone else has this problem I thought I would share the solution.
I finally figured out the way you have to convert the drag and drop coordinates if you drag onto a MapEditor from outside.
You first have to call toControl() on the map display to convert between the map display and screen.
You then have to convert to the map world using pixelToWorld().
See code snippet below:
final int fx = event.x;
final int fy = event.y;
final org.eclipse.swt.graphics.Point fpoint=new org.eclipse.swt.graphics.Point(0,0);
Display.getDefault().syncExec( new Runnable(){
public void run(){
org.eclipse.swt.graphics.Point tmp=((ViewportPaneSWT)fmap.getRenderManager().getMapDisplay()).toControl(fx,fy);
fpoint.x=tmp.x;
fpoint.y=tmp.y;
}
});
Coordinate coord = map.getViewportModel().pixelToWorld(fpoint.x, fpoint.y);
GeometryFactory geomFactory = new GeometryFactory();
com.vividsolutions.jts.geom.Point point = geomFactory.createPoint(coord);
At least I think that is what is happening.
Either way, it works! :-)
Michelle
_______________________________________________ User-friendly Desktop Internet GIS (uDig) http://udig.refractions.net http://lists.refractions.net/mailman/listinfo/udig-devel
