Skip to content

Commit

Permalink
making extraction with osmconvert easier #36
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Dec 5, 2022
1 parent b7151f5 commit 07fef00
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/guisim/GUINet.cpp
Expand Up @@ -30,6 +30,7 @@
#include <utils/gui/globjects/GUIPolygon.h>
#include <utils/gui/globjects/GUIPointOfInterest.h>
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
#include <utils/gui/div/GUIDesigns.h>
#include <utils/gui/div/GUIParameterTableWindow.h>
#include <utils/gui/div/GUIGlobalSelection.h>
#include <utils/gui/globjects/GUIShapeContainer.h>
Expand Down Expand Up @@ -429,6 +430,9 @@ GUINet::getPopUpMenu(GUIMainWindow& app,
buildCenterPopupEntry(ret);
buildShowParamsPopupEntry(ret);
buildPositionCopyEntry(ret, app);
if (GeoConvHelper::getFinal().usingGeoProjection()) {
GUIDesigns::buildFXMenuCommand(ret, "Copy view geo-boundary to clipboard", nullptr, ret, MID_COPY_VIEW_GEOBOUNDARY);
}
return ret;
}

Expand Down
4 changes: 4 additions & 0 deletions src/netedit/GNENet.cpp
Expand Up @@ -52,6 +52,7 @@
#include <netwrite/NWFrame.h>
#include <netwrite/NWWriter_SUMO.h>
#include <netwrite/NWWriter_XML.h>
#include <utils/gui/div/GUIDesigns.h>
#include <utils/gui/div/GUIParameterTableWindow.h>
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
#include <utils/gui/globjects/GUIGlObjectStorage.h>
Expand Down Expand Up @@ -158,6 +159,9 @@ GNENet::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildPositionCopyEntry(ret, app);
if (GeoConvHelper::getFinal().usingGeoProjection()) {
GUIDesigns::buildFXMenuCommand(ret, "Copy view geo-boundary to clipboard", nullptr, ret, MID_COPY_VIEW_GEOBOUNDARY);
}
return ret;
}

Expand Down
18 changes: 17 additions & 1 deletion src/utils/gui/globjects/GUIGLObjectPopupMenu.cpp
Expand Up @@ -47,6 +47,7 @@ FXDEFMAP(GUIGLObjectPopupMenu) GUIGLObjectPopupMenuMap[] = {
FXMAPFUNC(SEL_COMMAND, MID_COPY_EDGE_NAME, GUIGLObjectPopupMenu::onCmdCopyEdgeName),
FXMAPFUNC(SEL_COMMAND, MID_COPY_CURSOR_POSITION, GUIGLObjectPopupMenu::onCmdCopyCursorPosition),
FXMAPFUNC(SEL_COMMAND, MID_COPY_CURSOR_GEOPOSITION, GUIGLObjectPopupMenu::onCmdCopyCursorGeoPosition),
FXMAPFUNC(SEL_COMMAND, MID_COPY_VIEW_GEOBOUNDARY, GUIGLObjectPopupMenu::onCmdCopyViewGeoBoundary),
FXMAPFUNC(SEL_COMMAND, MID_SHOW_GEOPOSITION_ONLINE, GUIGLObjectPopupMenu::onCmdShowCursorGeoPositionOnline),
FXMAPFUNC(SEL_COMMAND, MID_SHOWPARS, GUIGLObjectPopupMenu::onCmdShowPars),
FXMAPFUNC(SEL_COMMAND, MID_SHOWTYPEPARS, GUIGLObjectPopupMenu::onCmdShowTypePars),
Expand Down Expand Up @@ -185,13 +186,28 @@ long
GUIGLObjectPopupMenu::onCmdCopyCursorGeoPosition(FXObject*, FXSelector, void*) {
Position pos = myNetworkPosition;
GeoConvHelper::getFinal().cartesian2geo(pos);
// formated for pasting into google maps
// formatted for pasting into google maps
const std::string posString = toString(pos.y(), gPrecisionGeo) + ", " + toString(pos.x(), gPrecisionGeo);
GUIUserIO::copyToClipboard(*myParent->getApp(), posString);
return 1;
}


long
GUIGLObjectPopupMenu::onCmdCopyViewGeoBoundary(FXObject*, FXSelector, void*) {
const Boundary b = myParent->getVisibleBoundary();
Position lowLeft(b.xmin(), b.ymin());
GeoConvHelper::getFinal().cartesian2geo(lowLeft);
Position upRight(b.xmax(), b.ymax());
GeoConvHelper::getFinal().cartesian2geo(upRight);
// formatted for usage with osmconvert
const std::string posString = toString(lowLeft.x(), gPrecisionGeo) + "," + toString(lowLeft.y(), gPrecisionGeo) + "," +
toString(upRight.x(), gPrecisionGeo) + "," + toString(upRight.y(), gPrecisionGeo);
GUIUserIO::copyToClipboard(*myParent->getApp(), posString);
return 1;
}


long
GUIGLObjectPopupMenu::onCmdShowCursorGeoPositionOnline(FXObject* item, FXSelector, void*) {
FXMenuCommand* const mc = dynamic_cast<FXMenuCommand*>(item);
Expand Down
3 changes: 3 additions & 0 deletions src/utils/gui/globjects/GUIGLObjectPopupMenu.h
Expand Up @@ -105,6 +105,9 @@ class GUIGLObjectPopupMenu : public FXMenuPane {
/// @brief Called if the cursor geo-position shall be copied to clipboard
long onCmdCopyCursorGeoPosition(FXObject*, FXSelector, void*);

/// @brief Called if the current geo-boundary shall be copied to clipboard
long onCmdCopyViewGeoBoundary(FXObject*, FXSelector, void*);

/// @brief Called if the cursor geo-position shall be shown online
long onCmdShowCursorGeoPositionOnline(FXObject*, FXSelector, void*);

Expand Down
2 changes: 2 additions & 0 deletions src/utils/gui/windows/GUIAppEnum.h
Expand Up @@ -456,6 +456,8 @@ enum {
MID_COPY_CURSOR_POSITION,
/// @brief Copy cursor geo-coordinate position - popup entry
MID_COPY_CURSOR_GEOPOSITION,
/// @brief Copy view geo-coordinate boundary - popup entry
MID_COPY_VIEW_GEOBOUNDARY,
/// @brief Show the cursor geo-coordinate position online in GeoHack - popup entry
MID_SHOW_GEOPOSITION_ONLINE,
/// @brief open additional dialog (used in netedit)
Expand Down

0 comments on commit 07fef00

Please sign in to comment.