Skip to content

Commit

Permalink
Remove logging temporarily and fix
Browse files Browse the repository at this point in the history
bathymetry loading when folders have
dots in the name

Signed-off-by: Rui Correia <[email protected]>
  • Loading branch information
Rui Correia committed Feb 1, 2023
1 parent 7aabd3b commit cb067f9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mohid_qgis/core/utils/bathymetryConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def saveGenerateMohidFile(outPath, batFilepath, gridPath, xyzPaths, landPaths):
f.write(f"GRID_LIMITS_PERCENTAGE : 0.25\n")

def MOHIDBathymetry2shp(input_path, data = None):

# TODO: filename with dots are not advised, account for this in the future
readFile = False
if data is None:
readFile = True
Expand Down
20 changes: 10 additions & 10 deletions mohid_qgis/plugin/mohid_qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@
'class': 'logging.StreamHandler',
'formatter': 'console',
},
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'formatter': 'file',
'filename': 'mohid_qgis.log'
},
# 'file': {
# 'level': 'INFO',
# 'class': 'logging.FileHandler',
# 'formatter': 'file',
# 'filename': 'mohid_qgis.log'
# },
},
'loggers':{
'mohid_qgis.plugin': {
'handlers': ['console', 'file'],
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'mohid_qgis.core': {
'handlers': ['console', 'file'],
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
},
'root': {
'handlers': ['console', 'file'],
'handlers': ['console'],
'level': 'DEBUG',
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ def __init__(self, iface):

# debug

debug = False
debug = True
waitForAttach = True

if debug:
Expand Down
2 changes: 1 addition & 1 deletion mohid_qgis/plugin/tab_bathymetry/tab_bathymetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def generateBatMohidFile(self):

gridPaths = []
itemCtn = self.bat_gridTree.topLevelItemCount()
for id in range(0, 1):
for id in range(0, itemCtn):
gridPaths.append(self.bat_gridTree.topLevelItem(id).text(1))

xyzPaths = []
Expand Down
2 changes: 1 addition & 1 deletion mohid_qgis/plugin/tab_load/mohidBathymetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MOHIDBathymetry(Grid):
def __init__(self, filepath):

self._filepath = filepath
self.filename = os.path.basename(filepath).split(".")[0]
self.filename = os.path.basename(filepath).strip(".dat")
self.grid = Grid()
self.gridData = {}
self.readMohidBathymetry(filepath)
Expand Down
9 changes: 5 additions & 4 deletions mohid_qgis/plugin/tab_load/tab_Load.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def loadGridToLayer(self):
if not shpPath:
return
# shpPath = self.bat_gridPath.text().split(".")[0] + ".shp"
filename = os.path.basename(shpPath).split(".")[0]
filename = os.path.basename(shpPath).strip(".shp")
vlayer = self.iface.addVectorLayer(shpPath, f"MOHID Grid - {filename}", "ogr")

if not vlayer:
Expand Down Expand Up @@ -110,7 +110,7 @@ def loadXYZToLayer(self):

shpPath = XYZ2shp(file)
# shpPath = self.bat_XYZPath.text().split(".")[0] + ".shp"
filename = os.path.basename(shpPath).split(".")[0]
filename = os.path.basename(shpPath).strip(".shp")
vlayer = self.iface.addVectorLayer(shpPath, f"MOHID Points - {filename}", "ogr")

if not vlayer:
Expand Down Expand Up @@ -139,7 +139,7 @@ def loadLandToLayer(self):
# check file type

shpPath = polygon2shp(file)
filename = os.path.basename(shpPath).split(".")[0]
filename = os.path.basename(shpPath).strip(".shp")
vlayer = self.iface.addVectorLayer(shpPath, f"MOHID Land - {filename}", "ogr")

if not vlayer:
Expand Down Expand Up @@ -194,9 +194,10 @@ def loadBatToLayer(self):
for filepath in filepaths:
if filepath != "":
# check file type
# logger.debug(f"Invalid MOHID file")
bat = MOHIDBathymetry(filepath)
MOHIDBathymetry2shp(filepath, bat.gridData)
shpPath = filepath.split(".")[0] + ".shp"
shpPath = filepath.strip(".dat") + ".shp"
vlayer = self.iface.addVectorLayer(
shpPath,
f"MOHID Bathymetry - {bat.filename}",
Expand Down

0 comments on commit cb067f9

Please sign in to comment.