Skip to content

Commit

Permalink
made coordinate conversion dockable
Browse files Browse the repository at this point in the history
  • Loading branch information
hamiltoncj committed Dec 5, 2019
1 parent 1a7ce72 commit 33c003b
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 454 deletions.
19 changes: 12 additions & 7 deletions coordinateConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from qgis.PyQt.QtCore import QSize
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QDialog, QMenu, QApplication
from qgis.PyQt.QtWidgets import QDockWidget, QMenu, QApplication
from qgis.PyQt.QtCore import pyqtSlot
from qgis.PyQt.uic import loadUiType
from qgis.core import QgsCoordinateTransform, QgsPoint, QgsPointXY, QgsProject
Expand All @@ -18,7 +18,7 @@
FORM_CLASS, _ = loadUiType(os.path.join(
os.path.dirname(__file__), 'ui/coordinateConverter.ui'))

class CoordinateConverterWidget(QDialog, FORM_CLASS):
class CoordinateConverterWidget(QDockWidget, FORM_CLASS):
inputProjection = 0
origPt = None
origCrs = epsg4326
Expand Down Expand Up @@ -52,9 +52,10 @@ def __init__(self, lltools, settingsDialog, iface, parent):
self.clearFormButton.clicked.connect(self.clearForm)
self.coordCaptureButton.setIcon(QIcon(os.path.dirname(__file__) + "/images/coordinate_capture.png"))
self.coordCaptureButton.clicked.connect(self.startCapture)
self.zoomButton.setIcon(QIcon(':/images/themes/default/mActionZoomIn.svg'))
self.zoomButton.clicked.connect(self.zoomTo)
self.optionsButton.setIcon(QIcon(':/images/themes/default/mActionOptions.svg'))
self.optionsButton.clicked.connect(self.showSettings)
self.closeButton.clicked.connect(self.closeEvent)

icon = QIcon(os.path.dirname(__file__) + "/images/check.png")
self.wgs84CommitButton.setIcon(icon)
Expand Down Expand Up @@ -120,10 +121,6 @@ def showEvent(self, e):
self.xyButton.setDefaultAction(self.xymenu.actions()[settings.converterCoordOrder])
self.updateLabel()

def closeEvent(self, e):
self.stopCapture()
self.hide()

def xyTriggered(self, action):
self.xyButton.setDefaultAction(action)
self.inputXYOrder = action.data()
Expand Down Expand Up @@ -479,3 +476,11 @@ def stopCapture(self):

def showSettings(self):
self.settings.showTab(5)

def zoomTo(self):
text = self.wgs84LineEdit.text().strip()
try:
lat, lon = parseDMSString(text, self.inputXYOrder)
pt = self.lltools.zoomTo(epsg4326, lat, lon)
except Exception:
pass
Binary file modified doc/coordinateConversion.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions latLonTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def convertCoordinatesTool(self):
if self.convertCoordinateDialog is None:
from .coordinateConverter import CoordinateConverterWidget
self.convertCoordinateDialog = CoordinateConverterWidget(self, self.settingsDialog, self.iface, self.iface.mainWindow())
self.convertCoordinateDialog.setFloating(True)
self.convertCoordinateDialog.show()

def multiZoomTo(self):
Expand Down
3 changes: 2 additions & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name=Lat Lon Tools
qgisMinimumVersion=3.0
description=Tools to capture and zoom to coordinates using decimal, DMS, WKT, GeoJSON, MGRS, UTM, Geohash, and Plus Codes formats. Provides external map support, point digitizing tools, and coordinate conversion tools.
version=3.3.11
version=3.3.12
author=C Hamilton
[email protected]
about=
Expand All @@ -27,6 +27,7 @@ icon=images/copyicon.png
experimental=False
deprecated=False
changelog=
3.3.12 - Made coordinate conversion dialog box dockable & added zoom to button.
3.3.11 - Fix bug
3.3.10 - Added 'degree minute' capture and to coordinate conversion dialog box.
3.3.9 - Added geohash support
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Some of the functions can be accessed from the ***Lat Lon Tools*** toolbar. If f
* <img src="doc/xy.jpg" alt="X, Y Coordinate Order"> / <img src="doc/yx.jpg" alt="Y, X Coordinate Order"> ***Coordinate order*** - Select whether the coordinates should be displayed in an **x,y (longitude, latitude)** or **y,x (latitude, longitude)** order.
* <img src="doc/converter-clear.jpg" alt="Clear all fields"> ***Clear form*** - This clears the form of all values.
* <img src="doc/settings.png" alt="Settings"> ***Show coordinate conversion settings*** - This shows the default settings for coordinate conversion.
* <img src="doc/zoomtool.jpg" alt="Zoom to"> ***Zoom to*** will zoom to the coordinate in the Decimal Degrees field.
* <img src="images/coordinate_capture.png" alt="Capture coordinate"> ***Capture coordinate*** enables the user to click on the map to capture a coordinate directly to the form and have it automatically converted.
* <img src="images/check.png" alt="Convert coordinate"> ***Convert coordinate*** updates all coordinate fields with values converted from this text field.
* <img src="doc/copy.jpg" alt="Copy to clipboard"> ***Copy to clipboard*** copies the value in the text area onto the clipboard.
Expand Down
Loading

0 comments on commit 33c003b

Please sign in to comment.