|
From: Casson S. <cas...@ea...> - 2004-06-20 18:47:55
|
Hi all,
I am having problems printing out the results of a mouse click in map coordinates and this has brought up several questions. I have read over the materials on coordinate systems and think I could create a coordinate system or a coordinate transform (we'll see once I know what to do with them). However, it is not clear to me when and where they need to be applied.
I am using the j2d renderer.
The question is motivated by the method below. This gets the mouse click and returns the coordinates.
public void mouseClicked(MouseEvent event) {
java.awt.geom.Point2D pnt = null;
java.awt.geom.Point2D pnt2 = null;
GeoMouseEvent e = (GeoMouseEvent) event;
if (pnt != null) {
try {
pnt2 = e.getMapCoordinate(mapcs,pnt);
jb.setText(pnt2.toString());
}
catch(TransformException te) {
jb.setText("CS Transform Exception");
System.err.println(te.getMessage());
}
repaint();
}
}
When I initially wrote this I used e.getMapCoordinate which I expected to return the coordinate in NC StatePlane (the coordinates system of the data, although not specified at any point in the program). It clearly returned the pixel loction, however. The bounding box is given in the proper StatePlane coordinates, so I know the data is being read correctly. These may not be the right questions, but you should be able to figure out what Iam after here.
Could someone explain to me a few things.
1. Should I be setting the coordinate system to StatePlane using org.geotools.j2d.Renderer.setCoordinateSystem. If I do this just it just say what the coordinates are, or does it try to transform things?
2. If I have the renderer set to a specific coordinate system, will data in other coordinate systems be automatically transformed, or do I need to build the transformation mannually?
3. If data is automatically transformed, how to I associate a coordinate system with a dataset or datastore?
4. If I use GeoMouseEvent.getMapCoordinate(coordinate system, point) (I am not sure on the exact syntax.) Does this convert the coordinate from the Renderer map coordinates to the specified coordinate system coordinates?
Thanks.
If I understand well enough when I am done I will write up another little How To.
Casson Stallings
cas...@ea... |