Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
fix small bug when opening a new file
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Blacher <[email protected]>
  • Loading branch information
Benjamin Blacher committed Feb 20, 2022
1 parent 8c3fa96 commit 7eed81d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# TODO don't spawn a terminal window
# TODO check screen res for map view
# TODO allow zoom & pan on map view
# TODO fix datatypes, plotcolor on "open file"
# TODO close all child windows on main window close

# TODO fix datatypes, plotcolor on "open file"

from csv import reader
from datetime import datetime
from random import randint
Expand Down Expand Up @@ -31,6 +32,7 @@
context = staticmaps.Context()
context.set_tile_provider(staticmaps.tile_provider_OSM)


def plots_update_views():
global plots
for noofplots in range(1, len(plots) - 1):
Expand Down Expand Up @@ -97,7 +99,6 @@ def save_map(self):
path = path + ".svg"
copy(os.getcwd() + "/temp/map_tmp.svg", path)


def map_satellite(self):
context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery)
self.draw_map()
Expand Down Expand Up @@ -216,8 +217,7 @@ def populate_table(self, tabledata):
def draw_map(self):
gps_data = data[1:, int(datatypes[5, 7]) + 1:]
gps_data = np.asarray(gps_data, dtype=float)
context.add_object(
staticmaps.Line([staticmaps.create_latlng(lat, lng) for lat, lng in gps_data], width=1))
context.add_object(staticmaps.Line([staticmaps.create_latlng(lat, lng) for lat, lng in gps_data], width=1))
image = context.render_svg(1800, 900, 19)
image.saveas("temp/map_tmp.svg")
map_pixmap = QPixmap("temp/map_tmp.svg")
Expand All @@ -238,12 +238,13 @@ def toggle_fullscreen(self):
self.showFullScreen()

def openfile(self):
self.pageswitcher.setCurrentIndex(0)
self.mapdisplay.setVisible(0)
self.saveImage.setVisible(0)
self.MapLoadButton.setVisible(1)
self.styleSatellite.setVisible(0)
self.styleMap.setVisible(0)
filepath = QFileDialog.getOpenFileName(self, self.tr("Open Data"), QDir.homePath(), self.tr("*.txt *.csv"))
filepath = QFileDialog.getOpenFileName(self, "Open Data", QDir.homePath(), "*.txt *.csv")
try:
datafile = open(filepath[0], 'r')
except:
Expand All @@ -268,14 +269,14 @@ def openfile(self):
self.actionMap_View.setEnabled(0)
self.overview_to_map.setEnabled(0)
errortypes.remove("Coordinates")
msgBox = QMessageBox()
msgBox.setText("There are errors in your gps data, Map View is not available.")
msgBox.exec()
msg_box = QMessageBox()
msg_box.setText("There are errors in your gps data, Map View is not available.")
msg_box.exec()

if not errortypes == []:
msgBox = QMessageBox()
msgBox.setText("There are errors in your datafile, the following categories are not available for plotting: " + str(errortypes))
msgBox.exec()
msg_box = QMessageBox()
msg_box.setText("There are errors in your datafile, the following categories are not available for plotting: " + str(errortypes))
msg_box.exec()

data = tempdata
self.table_tableview.resizeColumnsToContents()
Expand Down Expand Up @@ -316,7 +317,7 @@ def show_window(self):
self.dropdown_trace.model().item(elements).setEnabled(False)
includingerrors = True

if includingerrors == True:
if includingerrors:
self.dropdown_trace.setCurrentIndex(3)
self.dropdown_axis.setEnabled(0)
self.refresh_visibility_button()
Expand Down

0 comments on commit 7eed81d

Please sign in to comment.