Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Public
PASSOFT
SOHViewer
Commits
f6f51377
Commit
f6f51377
authored
2 years ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Implement plotting GPS points.
parent
6e7a64d8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sohstationviewer/view/plotting/gps_dialog.py
+74
-20
74 additions, 20 deletions
sohstationviewer/view/plotting/gps_dialog.py
with
74 additions
and
20 deletions
sohstationviewer/view/plotting/gps_dialog.py
+
74
−
20
View file @
f6f51377
...
...
@@ -2,20 +2,63 @@ import sys
from
pathlib
import
Path
from
typing
import
List
from
model.gps_point
import
GPSPoint
from
model.mseed.mseed
import
MSeed
from
view.plotting.plotting_widget.plotting_widget
import
PlottingWidget
from
sohstationviewer.model.gps_point
import
GPSPoint
from
sohstationviewer.model.mseed.mseed
import
MSeed
from
PySide2
import
QtWidgets
,
QtCore
from
matplotlib.backends.backend_qt5agg
import
(
FigureCanvasQTAgg
as
Canvas
)
from
matplotlib.figure
import
Figure
from
matplotlib.axes
import
Axes
class
GPSWidget
(
PlottingWidget
):
def
__init__
(
self
,
parent
,
tracking_box
):
super
().
__init__
(
parent
,
tracking_box
)
class
GPSWidget
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
parent
,
tracking_box
,
gps_points
):
super
().
__init__
(
parent
)
self
.
tracking_box
=
tracking_box
self
.
gps_points
=
gps_points
self
.
fig
=
Figure
(
figsize
=
(
6
,
6
),
dpi
=
100
)
self
.
ax
:
Axes
=
self
.
fig
.
add_axes
((
0
,
0
,
1
,
1
))
self
.
ax
.
set_facecolor
(
"
dimgray
"
)
self
.
canvas
=
Canvas
(
self
.
fig
)
@QtCore.Slot
()
def
plot_gps
(
self
):
pass
good_gps_points
=
[
point
for
point
in
self
.
gps_points
if
not
point
.
is_bad_point
()]
all_latitudes
=
[
point
.
latitude
for
point
in
good_gps_points
]
all_longitudes
=
[
point
.
longitude
for
point
in
good_gps_points
]
max_latitude
=
max
(
all_latitudes
)
min_latitude
=
min
(
all_latitudes
)
max_longitude
=
max
(
all_longitudes
)
min_longitude
=
min
(
all_longitudes
)
latitude_range
=
max_latitude
-
min_latitude
longitude_range
=
max_longitude
-
min_longitude
if
latitude_range
>
longitude_range
:
longitude_average
=
(
min_longitude
+
max_longitude
)
/
2
min_longitude
=
longitude_average
-
latitude_range
/
2
max_longitude
=
longitude_average
+
latitude_range
/
2
else
:
latitude_average
=
(
min_latitude
+
max_latitude
)
/
2
min_latitude
=
latitude_average
-
longitude_range
/
2
max_latitude
=
latitude_average
+
longitude_range
/
2
self
.
ax
.
set_yticks
([])
self
.
ax
.
set_xticks
([])
self
.
ax
.
spines
[
'
right
'
].
set_visible
(
False
)
self
.
ax
.
spines
[
'
left
'
].
set_visible
(
False
)
self
.
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
self
.
ax
.
spines
[
'
bottom
'
].
set_visible
(
False
)
self
.
ax
.
plot
(
all_longitudes
,
all_latitudes
,
'
ws
'
,
markersize
=
3
,
markeredgecolor
=
'
black
'
)
if
latitude_range
>
longitude_range
:
self
.
ax
.
set_xlim
(
min_longitude
,
max_longitude
)
else
:
self
.
ax
.
set_ylim
(
min_latitude
,
max_latitude
)
self
.
ax
.
set_box_aspect
(
1
)
class
GPSDialog
(
QtWidgets
.
QWidget
):
...
...
@@ -26,17 +69,28 @@ class GPSDialog(QtWidgets.QWidget):
self
.
data_path
=
None
self
.
info_text_browser
=
QtWidgets
.
QTextBrowser
(
self
)
self
.
setGeometry
(
300
,
300
,
400
,
500
)
# The height of the dialog is chosen so that the GPS plot is flush with
# the edges of the dialog.
dialog_height
=
518
self
.
setGeometry
(
300
,
300
,
400
,
dialog_height
)
self
.
setWindowTitle
(
"
GPS Plot
"
)
main_layout
=
QtWidgets
.
QVBoxLayout
()
self
.
setLayout
(
main_layout
)
main_layout
.
setContentsMargins
(
5
,
5
,
5
,
5
)
main_layout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
main_layout
.
setSpacing
(
0
)
self
.
plotting_widget
=
GPSWidget
(
self
,
self
.
info_text_browser
)
main_layout
.
addWidget
(
self
.
plotting_widget
,
2
)
self
,
self
.
info_text_browser
,
gps_points
)
main_layout
.
addWidget
(
self
.
plotting_widget
.
canvas
)
# Add a 1-pixel high widget to the main layout so that there is a
# visible border between the GPS plot and the button. QTextBrowser
# is used because it is known to have a visible border.
invisible_widget
=
QtWidgets
.
QTextBrowser
()
invisible_widget
.
setFixedHeight
(
1
)
main_layout
.
addWidget
(
invisible_widget
)
button_layout
=
QtWidgets
.
QHBoxLayout
()
button_layout
.
setContentsMargins
(
100
,
0
,
100
,
0
)
...
...
@@ -72,10 +126,7 @@ class GPSDialog(QtWidgets.QWidget):
with
open
(
outside_folder
/
f
'
{
folder_name
}
.gps.dat
'
,
'
w+
'
)
as
outfile
:
outfile
.
write
(
f
'
# GPS data points for
{
folder_name
}
\n
'
)
for
point
in
self
.
gps_points
:
is_bad_point
=
(
point
.
height
==
0
and
point
.
longitude
==
0
and
point
.
longitude
==
0
and
point
.
num_satellite_used
==
0
)
if
is_bad_point
:
if
point
.
is_bad_point
():
continue
line
=
(
f
'
{
point
.
last_timemark
}
\t
{
point
.
fix_type
}
\t
'
...
...
@@ -89,9 +140,12 @@ if __name__ == '__main__':
import
os
os
.
chdir
(
'
/Users/kle/PycharmProjects/sohstationviewer
'
)
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
data
=
MSeed
(
QtWidgets
.
QTextBrowser
(),
'
/Users/kle/Documents/SOHView data/Q330/Q330_5281.sdr
'
)
# data_path = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/Q330-sample'
data_path
=
'
/Users/kle/Documents/SOHView data/Q330/Q330_5281.sdr
'
data
=
MSeed
(
QtWidgets
.
QTextBrowser
(),
data_path
)
wnd
=
GPSDialog
(
None
,
data
.
gps_points
)
wnd
.
data_path
=
Path
(
'
/Users/kle/Documents/SOHView data/Q330/Q330_5281.sdr
'
)
wnd
.
export_button
.
click
()
# wnd.show()
# sys.exit(app.exec_())
wnd
.
data_path
=
Path
(
data_path
)
wnd
.
show
()
wnd
.
read_button
.
click
()
sys
.
exit
(
app
.
exec_
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment