Skip to content

Commit 8631928

Browse files
committed
added azimuth calculation for UTM data
fixing #20
1 parent fc8283f commit 8631928

21 files changed

+45
-48
lines changed

openstereo/os_base.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import traceback
1515
import webbrowser
1616
import codecs
17-
from math import degrees
17+
from math import degrees, atan2, hypot
1818

1919
utf8_reader = codecs.getreader("utf-8")
2020

@@ -390,7 +390,10 @@ def __init__(self):
390390
)
391391

392392
self.actionConvert_Shapefile_to_Azimuth_data.triggered.connect(
393-
self.import_shapefile
393+
lambda: self.import_shapefile(geographic=True)
394+
)
395+
self.actionConvert_Shapefile_to_Azimuth_Data_UTM.triggered.connect(
396+
lambda: self.import_shapefile(geographic=False)
394397
)
395398
self.actionConvert_Mesh_to_Plane_Data.triggered.connect(
396399
self.import_mesh
@@ -717,7 +720,7 @@ def import_fault_data(
717720
faults_item.data_settings["sensecolumncheck"] = False
718721
return planes_item, lines_item, faults_item
719722

720-
def import_shapefile(self):
723+
def import_shapefile(self, geographic):
721724
fname, extension = QtWidgets.QFileDialog.getOpenFileName(
722725
self,
723726
_translate("main", "Select Shapefile to convert"),
@@ -735,15 +738,21 @@ def import_shapefile(self):
735738
)
736739
if not fname_out:
737740
return
741+
if geographic:
742+
azimuth = bearing
743+
length = haversine
744+
else:
745+
azimuth = lambda x0, x1, y0, y1: degrees(atan2(x1 - x0, y1 - y0))
746+
length = lambda x0, x1, y0, y1: hypot(x1 - x0, y1 - y0)
738747
with open(fname_out, "w") as f:
739748
sf = shapefile.Reader(fname)
740749
f.write("azimuth;length\n")
741750
for shape in sf.shapes():
742751
for A, B in pairwise(shape.points):
743752
f.write(
744753
"{};{}\n".format(
745-
bearing(A[0], B[0], A[1], B[1]),
746-
haversine(A[0], B[0], A[1], B[1]),
754+
azimuth(A[0], B[0], A[1], B[1]),
755+
length(A[0], B[0], A[1], B[1]),
747756
)
748757
)
749758
self.import_dialog(

openstereo/ui/circular_properties_ui.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\circular_properties.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

@@ -25,7 +25,6 @@ def setupUi(self, Dialog):
2525
self.roseDiagram = QtWidgets.QWidget()
2626
self.roseDiagram.setObjectName("roseDiagram")
2727
self.verticalLayout = QtWidgets.QVBoxLayout(self.roseDiagram)
28-
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
2928
self.verticalLayout.setObjectName("verticalLayout")
3029
self.gridLayout_2 = QtWidgets.QGridLayout()
3130
self.gridLayout_2.setObjectName("gridLayout_2")
@@ -274,7 +273,6 @@ def setupUi(self, Dialog):
274273
self.tab_3 = QtWidgets.QWidget()
275274
self.tab_3.setObjectName("tab_3")
276275
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.tab_3)
277-
self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
278276
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
279277
self.show_auttitude_data_statistics = QtWidgets.QTextEdit(self.tab_3)
280278
self.show_auttitude_data_statistics.setObjectName("show_auttitude_data_statistics")
@@ -283,7 +281,6 @@ def setupUi(self, Dialog):
283281
self.tab_4 = QtWidgets.QWidget()
284282
self.tab_4.setObjectName("tab_4")
285283
self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.tab_4)
286-
self.horizontalLayout_7.setContentsMargins(0, 0, 0, 0)
287284
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
288285
self.show_auttitude_data_source = QtWidgets.QTextEdit(self.tab_4)
289286
self.show_auttitude_data_source.setObjectName("show_auttitude_data_source")

openstereo/ui/clipboard_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\clipboard.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/difference_vectors_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\difference_vectors.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/fault_data_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\fault_data.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/fault_properties_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\fault_properties.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/import_dialog_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\import_dialog.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/import_ply_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\import_ply.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/item_table_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\item_table.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

openstereo/ui/line_properties_ui.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Form implementation generated from reading ui file 'ui_files\line_properties.ui'
44
#
5-
# Created by: PyQt5 UI code generator 5.6
5+
# Created by: PyQt5 UI code generator 5.9.2
66
#
77
# WARNING! All changes made in this file will be lost!
88

@@ -25,7 +25,6 @@ def setupUi(self, Dialog):
2525
self.tab = QtWidgets.QWidget()
2626
self.tab.setObjectName("tab")
2727
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.tab)
28-
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
2928
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
3029
self.verticalLayout_18 = QtWidgets.QVBoxLayout()
3130
self.verticalLayout_18.setObjectName("verticalLayout_18")
@@ -401,7 +400,6 @@ def setupUi(self, Dialog):
401400
self.tab_2 = QtWidgets.QWidget()
402401
self.tab_2.setObjectName("tab_2")
403402
self.horizontalLayout_12 = QtWidgets.QHBoxLayout(self.tab_2)
404-
self.horizontalLayout_12.setContentsMargins(0, 0, 0, 0)
405403
self.horizontalLayout_12.setObjectName("horizontalLayout_12")
406404
self.verticalLayout_13 = QtWidgets.QVBoxLayout()
407405
self.verticalLayout_13.setObjectName("verticalLayout_13")
@@ -598,7 +596,6 @@ def setupUi(self, Dialog):
598596
self.roseDiagram = QtWidgets.QWidget()
599597
self.roseDiagram.setObjectName("roseDiagram")
600598
self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.roseDiagram)
601-
self.verticalLayout_8.setContentsMargins(0, 0, 0, 0)
602599
self.verticalLayout_8.setObjectName("verticalLayout_8")
603600
self.gridLayout_2 = QtWidgets.QGridLayout()
604601
self.gridLayout_2.setObjectName("gridLayout_2")
@@ -847,7 +844,6 @@ def setupUi(self, Dialog):
847844
self.tab_3 = QtWidgets.QWidget()
848845
self.tab_3.setObjectName("tab_3")
849846
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.tab_3)
850-
self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
851847
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
852848
self.show_auttitude_data_statistics = QtWidgets.QTextEdit(self.tab_3)
853849
self.show_auttitude_data_statistics.setObjectName("show_auttitude_data_statistics")
@@ -856,7 +852,6 @@ def setupUi(self, Dialog):
856852
self.tab_5 = QtWidgets.QWidget()
857853
self.tab_5.setObjectName("tab_5")
858854
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.tab_5)
859-
self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
860855
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
861856
self.verticalLayout_19 = QtWidgets.QVBoxLayout()
862857
self.verticalLayout_19.setObjectName("verticalLayout_19")
@@ -962,7 +957,6 @@ def setupUi(self, Dialog):
962957
self.tab_4 = QtWidgets.QWidget()
963958
self.tab_4.setObjectName("tab_4")
964959
self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.tab_4)
965-
self.horizontalLayout_7.setContentsMargins(0, 0, 0, 0)
966960
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
967961
self.show_auttitude_data_source = QtWidgets.QTextEdit(self.tab_4)
968962
self.show_auttitude_data_source.setObjectName("show_auttitude_data_source")

0 commit comments

Comments
 (0)