use of org.openstreetmap.josm.data.coor.LatLon in project josm by JOSM.
the class AddNodeAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (!isEnabled())
return;
// #17682 - Run the action later in EDT to make sure the KeyEvent triggering it is consumed before the dialog is shown
SwingUtilities.invokeLater(() -> {
LatLonDialog dialog = new LatLonDialog(MainApplication.getMainFrame(), tr("Add Node..."), ht("/Action/AddNode"));
if (textLatLon != null) {
dialog.setLatLonText(textLatLon);
}
if (textEastNorth != null) {
dialog.setEastNorthText(textEastNorth);
}
dialog.showDialog();
if (dialog.getValue() != 1)
return;
LatLon coordinates = dialog.getCoordinates();
if (coordinates == null)
return;
textLatLon = dialog.getLatLonText();
textEastNorth = dialog.getEastNorthText();
Node nnew = new Node(coordinates);
// add the node
DataSet ds = getLayerManager().getEditDataSet();
UndoRedoHandler.getInstance().add(new AddCommand(ds, nnew));
ds.setSelected(nnew);
MapView mapView = MainApplication.getMap().mapView;
if (mapView != null && !mapView.getRealBounds().contains(nnew.getCoor())) {
AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew));
}
});
}
use of org.openstreetmap.josm.data.coor.LatLon in project josm by JOSM.
the class OffsetBookmark method bookmarkOffset.
/**
* Add a bookmark for the displacement of that layer
* @param name The bookmark name
* @param layer The layer to store the bookmark for
*/
public static void bookmarkOffset(String name, AbstractTileSourceLayer<?> layer) {
LatLon center;
if (MainApplication.isDisplayingMapView()) {
center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
} else {
center = LatLon.ZERO;
}
OffsetBookmark nb = new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), name, layer.getDisplaySettings().getDisplacement(), center);
for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext(); ) {
OffsetBookmark b = it.next();
if (b.isUsable(layer) && name.equals(b.name)) {
it.set(nb);
saveBookmarks();
return;
}
}
allBookmarks.add(nb);
saveBookmarks();
}
use of org.openstreetmap.josm.data.coor.LatLon in project josm by JOSM.
the class WMTSTileSource method xyToLatLon.
@Override
public Coordinate xyToLatLon(int x, int y, int zoom) {
TileMatrix matrix = getTileMatrix(zoom);
if (matrix == null) {
return new Coordinate(0, 0);
}
double scale = matrix.scaleDenominator * this.crsScale;
EastNorth ret = new EastNorth(matrix.topLeftCorner.east() + x * scale, matrix.topLeftCorner.north() - y * scale);
LatLon ll = tileProjection.eastNorth2latlon(ret);
return new Coordinate(ll.lat(), ll.lon());
}
use of org.openstreetmap.josm.data.coor.LatLon in project josm by JOSM.
the class WMTSTileSource method latLonToXY.
@Override
public Point latLonToXY(double lat, double lon, int zoom) {
TileMatrix matrix = getTileMatrix(zoom);
if (matrix == null) {
return new Point(0, 0);
}
double scale = matrix.scaleDenominator * this.crsScale;
EastNorth point = tileProjection.latlon2eastNorth(new LatLon(lat, lon));
return new Point((int) Math.round((point.east() - matrix.topLeftCorner.east()) / scale), (int) Math.round((matrix.topLeftCorner.north() - point.north()) / scale));
}
use of org.openstreetmap.josm.data.coor.LatLon in project josm by JOSM.
the class SlippyMapBBoxChooser method handleMouseMoved.
/**
* Handles a {@link SlippyMapController#mouseMoved} event
* @param point The point in the view
*/
public void handleMouseMoved(Point point) {
final ICoordinate coordinate = getPosition(point);
final LatLon latLon = new LatLon(coordinate.getLat(), coordinate.getLon());
firePropertyChange(CURSOR_COORDINATE_PROP, null, latLon);
}
Aggregations