Skip to content

Commit b183621

Browse files
committed
update for setting the number of capture digits
1 parent 3c25292 commit b183621

File tree

7 files changed

+41
-27
lines changed

7 files changed

+41
-27
lines changed

copyLatLonTool.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,25 @@ def formatCoord(self, pt, delimiter):
5252
else:
5353
msg = self.latlon.getDDMMSSLonLatOrder(delimiter)
5454
elif self.settings.wgs84NumberFormat == self.settings.Wgs84TypeWKT: # WKT
55-
msg = 'POINT({} {})'.format(self.latlon.lon, self.latlon.lat)
55+
msg = 'POINT({:.{prec}f} {:.{prec}f})'.format(self.latlon.lon, self.latlon.lat, prec=self.settings.decimalDigits)
5656
elif self.settings.wgs84NumberFormat == self.settings.Wgs84TypeGeoJSON: # GeoJSON
57-
msg = '{{"type": "Point","coordinates": [{},{}]}}'.format(self.latlon.lon, self.latlon.lat)
57+
msg = '{{"type": "Point","coordinates": [{:.{prec}f},{:.{prec}f}]}}'.format(self.latlon.lon, self.latlon.lat, prec=self.settings.decimalDigits)
5858
else: # decimal degrees
5959
if self.settings.coordOrder == self.settings.OrderYX:
60-
msg = '{}{}{}'.format(self.latlon.lat,delimiter,self.latlon.lon)
60+
msg = '{:.{prec}f}{}{:.{prec}f}'.format(self.latlon.lat,delimiter,self.latlon.lon,prec=self.settings.decimalDigits)
6161
else:
62-
msg = '{}{}{}'.format(self.latlon.lon,delimiter,self.latlon.lat)
62+
msg = '{:.{prec}f}{}{:.{prec}f}'.format(self.latlon.lon,delimiter,self.latlon.lat,prec=self.settings.decimalDigits)
6363
else:
6464
msg = None
6565
elif self.settings.captureProjIsProjectCRS():
6666
# Projection in the project CRS
6767
if self.settings.otherNumberFormat == 0: # Numerical
6868
if self.settings.coordOrder == self.settings.OrderYX:
69-
msg = '{}{}{}'.format(pt.y(),delimiter,pt.x())
69+
msg = '{:.{prec}f}{}{:.{prec}f}'.format(pt.y(),delimiter,pt.x(),prec=self.settings.decimalDigits)
7070
else:
71-
msg = '{}{}{}'.format(pt.x(),delimiter,pt.y())
71+
msg = '{:.{prec}f}{}{:.{prec}f}'.format(pt.x(),delimiter,pt.y(),prec=self.settings.decimalDigits)
7272
else:
73-
msg = 'POINT({} {})'.format(pt.x(), pt.y())
73+
msg = 'POINT({:.{prec}f} {:.{prec}f})'.format(pt.x(), pt.y(),prec=self.settings.decimalDigits)
7474
elif self.settings.captureProjIsCustomCRS():
7575
# Projection is a custom CRS
7676
canvasCRS = self.canvas.mapSettings().destinationCrs()
@@ -79,11 +79,11 @@ def formatCoord(self, pt, delimiter):
7979
pt = transform.transform(pt.x(), pt.y())
8080
if self.settings.otherNumberFormat == 0: # Numerical
8181
if self.settings.coordOrder == self.settings.OrderYX:
82-
msg = '{}{}{}'.format(pt.y(),delimiter,pt.x())
82+
msg = '{:.{prec}f}{}{:.{prec}f}'.format(pt.y(),delimiter,pt.x(),prec=self.settings.decimalDigits)
8383
else:
84-
msg = '{}{}{}'.format(pt.x(),delimiter,pt.y())
84+
msg = '{:.{prec}f}{}{:.{prec}f}'.format(pt.x(),delimiter,pt.y(),prec=self.settings.decimalDigits)
8585
else:
86-
msg = 'POINT({} {})'.format(pt.x(), pt.y())
86+
msg = 'POINT({:.{prec}f} {:.{prec}f})'.format(pt.x(), pt.y(),prec=self.settings.decimalDigits)
8787
elif self.settings.captureProjIsMGRS():
8888
# Make sure the coordinate is transformed to EPSG:4326
8989
canvasCRS = self.canvas.mapSettings().destinationCrs()

doc/menu.jpg

7.33 KB
Loading

doc/settings.jpg

3.1 KB
Loading

metadata.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name=Lat Lon Tools
33
qgisMinimumVersion=2.12
44
description=Tools to capture and zoom to coordinates using decimal, DMS, WKT, GeoJSON, MGRS, and Plus Codes notation. Provides external map support, MGRS & Plus Codes conversion and point digitizing tools.
5-
version=1.1.1
5+
version=1.1.2
66
author=C Hamilton
77
88
about=
@@ -25,6 +25,7 @@ icon=images/copyicon.png
2525
experimental=False
2626
deprecated=False
2727
changelog=
28+
1.1.2 - Added setting for the significant number of digits captured
2829
1.1.1 - Digitizer Multipoint fix
2930
1.1.0 - Added Plus Codes support
3031
1.0.3 - Added Mapillary support

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ By default ***Lat Lon Tools*** follows the **Google Map** convention making it p
8585

8686
## Settings
8787

88-
> <div style="background-color: #FFE0DD; margin: 18px; padding: 8px;">The <b>CRS</b> and <b>coordinate order</b> are independently set for the coordinate capture, zoom to, and multi-zoom to tools. Be careful that when setting one of these settings, that you check the rest to make sure that they are set correctly for your needs.</div>
88+
> <div style="background-color: #FFE0DD; margin: 18px; padding: 8px;">The <b>CRS</b> and <b>coordinate order</b> are independently set for the coordinate capture, zoom to, and multi-zoom to tools. Be careful when setting one of these settings, that you check the rest to make sure that they are set correctly for your needs.</div>
8989
9090
### Capture & Display Settings
9191

@@ -121,6 +121,7 @@ The order in which the coordinates are captured are determined by ***Coordinate
121121
* **Tab** - This useful if you are pasting the coordinates into two columns of a spreadsheet.
122122
* **Space**
123123
* **Other** - With this selected, the contents of ***Other Delimiter*** is used.
124+
* ***Number of decimal digits*** - This is the number of significant decimal digits that are captured. The default is 6.
124125
* ***DMS Second Precision*** - Used when formatting DMS coordinates and specifies the number of digits after the decimal.
125126
* ***Plus Codes Length*** - Used when formatting Plus Code coordinates. The minimum value is 10.
126127

settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def restoreDefaults(self):
9292
self.precisionSpinBox.setValue(0)
9393
self.captureProjectionSelectionWidget.setCrs(epsg4326)
9494
self.plusCodesSpinBox.setValue(10)
95+
self.digitsSpinBox.setValue(6)
9596

9697
### ZOOM TO SETTINGS ###
9798
self.zoomToProjectionComboBox.setCurrentIndex(self.ProjectionTypeWgs84)
@@ -126,6 +127,7 @@ def readSettings(self):
126127
self.wgs84NumberFormat = int(settings.value('/LatLonTools/WGS84NumberFormat', 0))
127128
self.otherNumberFormat = int(settings.value('/LatLonTools/OtherNumberFormat', 0))
128129
self.plusCodesLength = int(settings.value('/LatLonTools/PlusCodesLength', 10))
130+
self.decimalDigits = int(settings.value('/LatLonTools/DecimalDigits', 6))
129131

130132
### ZOOM TO SETTINGS ###
131133
self.zoomToCoordOrder = int(settings.value('/LatLonTools/ZoomToCoordOrder', self.OrderYX))
@@ -174,6 +176,7 @@ def accept(self):
174176

175177
settings.setValue('/LatLonTools/DMSPrecision', self.precisionSpinBox.value())
176178
settings.setValue('/LatLonTools/PlusCodesLength', self.plusCodesSpinBox.value())
179+
settings.setValue('/LatLonTools/DecimalDigits', self.digitsSpinBox.value())
177180

178181
### ZOOM TO SETTINGS ###
179182
settings.setValue('/LatLonTools/ZoomToCoordType', int(self.zoomToProjectionComboBox.currentIndex()))

ui/latLonSettings.ui

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,47 +88,56 @@
8888
<widget class="QComboBox" name="delimComboBox"/>
8989
</item>
9090
<item>
91-
<layout class="QHBoxLayout" name="horizontalLayout">
92-
<item>
91+
<layout class="QFormLayout" name="formLayout_2">
92+
<item row="0" column="0">
9393
<widget class="QLabel" name="label_3">
9494
<property name="text">
9595
<string>Other Delimiter: </string>
9696
</property>
9797
</widget>
9898
</item>
99-
<item>
99+
<item row="0" column="1">
100100
<widget class="QLineEdit" name="otherTxt"/>
101101
</item>
102-
</layout>
103-
</item>
104-
<item>
105-
<layout class="QHBoxLayout" name="horizontalLayout_2">
106-
<item>
102+
<item row="1" column="0">
103+
<widget class="QLabel" name="label_20">
104+
<property name="text">
105+
<string>Number of decimal digits: </string>
106+
</property>
107+
</widget>
108+
</item>
109+
<item row="1" column="1">
110+
<widget class="QSpinBox" name="digitsSpinBox">
111+
<property name="maximum">
112+
<number>64</number>
113+
</property>
114+
<property name="value">
115+
<number>6</number>
116+
</property>
117+
</widget>
118+
</item>
119+
<item row="2" column="0">
107120
<widget class="QLabel" name="label_4">
108121
<property name="text">
109122
<string>DMS Second Precision: </string>
110123
</property>
111124
</widget>
112125
</item>
113-
<item>
126+
<item row="2" column="1">
114127
<widget class="QSpinBox" name="precisionSpinBox">
115128
<property name="maximum">
116129
<number>6</number>
117130
</property>
118131
</widget>
119132
</item>
120-
</layout>
121-
</item>
122-
<item>
123-
<layout class="QHBoxLayout" name="horizontalLayout_3">
124-
<item>
133+
<item row="3" column="0">
125134
<widget class="QLabel" name="label_18">
126135
<property name="text">
127136
<string>Plus Codes Length:</string>
128137
</property>
129138
</widget>
130139
</item>
131-
<item>
140+
<item row="3" column="1">
132141
<widget class="QSpinBox" name="plusCodesSpinBox">
133142
<property name="minimum">
134143
<number>10</number>

0 commit comments

Comments
 (0)