Skip to content
Snippets Groups Projects
Commit 3035f6b0 authored by Kien Le's avatar Kien Le
Browse files

Implement showing GPS ranges in meter

parent d06eb7cb
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !53. Comments created here will be created in the context of that merge request.
...@@ -351,7 +351,7 @@ class MSeed(DataTypeModel): ...@@ -351,7 +351,7 @@ class MSeed(DataTypeModel):
# If location data is missing, we set them to 0. # If location data is missing, we set them to 0.
if gps_status_lines[5] == 'Latitude: ': if gps_status_lines[5] == 'Latitude: ':
return GPSPoint(last_timemark, fix_type, 0, 0, 0, 0) return GPSPoint(last_timemark, fix_type, 0, 0, 0, 0, '')
num_sats_used = int(gps_status_lines[8].split(': ')[1]) num_sats_used = int(gps_status_lines[8].split(': ')[1])
......
import math
import sys import sys
from pathlib import Path from pathlib import Path
from typing import List from typing import List
...@@ -46,8 +47,22 @@ class GPSWidget(QtWidgets.QWidget): ...@@ -46,8 +47,22 @@ class GPSWidget(QtWidgets.QWidget):
max_longitude = max(all_longitudes) max_longitude = max(all_longitudes)
min_longitude = min(all_longitudes) min_longitude = min(all_longitudes)
latitude_range = max_latitude - min_latitude
longitude_range = max_longitude - min_longitude
longitude_range = convert_longitude_degree_to_meter(longitude_range,
latitude_range)
latitude_range = convert_latitude_degree_to_meter(latitude_range)
self.ax.plot(all_longitudes, all_latitudes, 'ws', markersize=4, self.ax.plot(all_longitudes, all_latitudes, 'ws', markersize=4,
markeredgecolor='black', picker=True, pickradius=4) markeredgecolor='black', picker=True, pickradius=4)
range_text = (
f'Lat range: {latitude_range:.2f}m '
f'Long range: {longitude_range:.2f}m'
)
self.ax.text(
0.01, 0.96, range_text, color='white', size=10,
transform=self.ax.transAxes
)
latitude_range = max_latitude - min_latitude latitude_range = max_latitude - min_latitude
longitude_range = max_longitude - min_longitude longitude_range = max_longitude - min_longitude
...@@ -181,14 +196,41 @@ class GPSDialog(QtWidgets.QWidget): ...@@ -181,14 +196,41 @@ class GPSDialog(QtWidgets.QWidget):
outfile.write(line) outfile.write(line)
# We use the WGS-84's version of the Earth ellipsoid as a reference point for
# converting latitude and longitude differences from degree to meter.
# The constants below are obtained from here
# https://en.wikipedia.org/wiki/Earth_ellipsoid#Historical_Earth_ellipsoids.
# In order to use other models of the Earth ellipsoid, simply change these
# constants.
POLAR_CIRCUMFERENCE = 40007863
EQUATORIAL_CIRCUMFERENCE = 40075017
def convert_latitude_degree_to_meter(lat: float) -> float:
# A whole circumference is 360 degrees, so we can get the length of one
# degree by dividing the circumference by 360.
lat_degree_length_in_meter = POLAR_CIRCUMFERENCE / 360
return lat * lat_degree_length_in_meter
def convert_longitude_degree_to_meter(long: float, lat: float) -> float:
# A whole circumference is 360 degrees, so we can get the length of one
# degree by dividing the circumference by 360.
long_degree_length_in_meter = EQUATORIAL_CIRCUMFERENCE / 360
# The length of a longitude degree varies with the latitude, being greatest
# around the equator and approaching 0 near to the poles.
adjustment_for_latitude = math.cos(lat)
return long * long_degree_length_in_meter * adjustment_for_latitude
if __name__ == '__main__': if __name__ == '__main__':
import os import os
os.chdir('/Users/kle/PycharmProjects/sohstationviewer') os.chdir('/Users/kle/PycharmProjects/sohstationviewer')
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
data_path = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/Q330-sample' # data_path = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/Q330-sample'
# data_path = '/Users/kle/Documents/SOHView data/Q330/Q330_5281.sdr' data_path = '/Users/kle/Documents/SOHView data/Q330/Q330_5281.sdr'
data = MSeed(QtWidgets.QTextBrowser(), data_path) data = MSeed(QtWidgets.QTextBrowser(), data_path)
wnd = GPSDialog() wnd = GPSDialog()
...@@ -197,3 +239,6 @@ if __name__ == '__main__': ...@@ -197,3 +239,6 @@ if __name__ == '__main__':
wnd.show() wnd.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment