Skip to content

Commit

Permalink
Merge pull request #35 from FLO-2DKaren/crs_id
Browse files Browse the repository at this point in the history
Added a CRS selector
  • Loading branch information
FLO-2DKaren authored Jan 24, 2024
2 parents 86087c7 + b0662fb commit a887635
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
1 change: 1 addition & 0 deletions rasterizor/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ changelog=
0.3.1
- Added a new symbology for comparison
- Allowed only rasters layers for comparison
- Added a CRS selector
0.3
- Added the difference between rasters
- Updated style code
Expand Down
60 changes: 55 additions & 5 deletions rasterizor/rasterizor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""
import os
import numpy as np
from qgis._gui import QgsProjectionSelectionWidget
from qgis.core import *
from qgis.utils import iface
from qgis.PyQt.QtCore import Qt, QSettings, QTranslator, QCoreApplication
Expand All @@ -37,6 +38,7 @@
QDialogButtonBox,
QMessageBox
)

from qgis._core import (QgsGradientColorRamp, QgsGradientStop)
# from rast_functions import outTable
# Initialize Qt resources from file resources.py
Expand Down Expand Up @@ -89,8 +91,10 @@ def __init__(self, iface):

# Set the CRS to the widget
self.crs = QgsCoordinateReferenceSystem(QgsProject.instance().crs().authid())
self.dlg.crsselector.setCrs(self.crs)
self.dlg.crsselector_2.setCrs(self.crs)
self.projectionSelector = QgsProjectionSelectionWidget()
# self.dlg.crsselector.setCrs(self.crs)
# self.dlg.crsselector_2.setCrs(self.crs)
# self.projectionSelector.selectCrs()

# Run button
self.dlg.runButton.clicked.connect(self.run)
Expand Down Expand Up @@ -219,9 +223,55 @@ def closeDialog(self):
def open(self):
"""Shows the dialog"""
self.crs = QgsCoordinateReferenceSystem(QgsProject.instance().crs().authid())
self.dlg.crsselector.setCrs(self.crs)
self.dlg.crsselector_2.setCrs(self.crs)
self.dlg.show()
while True:
# Check if it is metric
if not self.crs.isGeographic():
self.dlg.crsselector.setCrs(self.crs)
self.dlg.crsselector_2.setCrs(self.crs)
self.dlg.show()
break # Exit the loop
else:
# Open the CRS selector
self.projectionSelector.selectCrs()

# Check if the user selected a projected CRS
if not self.projectionSelector.crs().isGeographic():
QgsProject.instance().setCrs(self.projectionSelector.crs())
self.crs = self.projectionSelector.crs()
self.dlg.crsselector.setCrs(self.crs)
self.dlg.crsselector_2.setCrs(self.crs)
self.dlg.show()
break # Exit the loop
else:
# Show a warning message
QMessageBox.warning(
self.dlg,
"CRS error",
"Select a Projected Coordinate Reference System!"
)

# # Check if it is metric
# if not self.crs.isGeographic():
# self.dlg.crsselector.setCrs(self.crs)
# self.dlg.crsselector_2.setCrs(self.crs)
# self.dlg.show()
# else:
# # Open the CRS selector
# self.projectionSelector.selectCrs()
# # Check again if the user selected a geographic crs
# if self.projectionSelector.crs().isGeographic():
# QMessageBox.warning(
# self.dlg,
# "CRS error",
# "Select a Projected Coordinate Reference System!"
# )
# else:
# QgsProject.instance().setCrs(self.projectionSelector.crs())
# self.crs = self.projectionSelector.crs()
# self.dlg.crsselector.setCrs(self.crs)
# self.dlg.crsselector_2.setCrs(self.crs)
# self.dlg.show()


# Adapted function from dlg_sampling_xyz_.py
def lidar_to_raster(self, lidar_file, raster_file, nodata_value=-9999):
Expand Down

0 comments on commit a887635

Please sign in to comment.