Skip to content

Commit

Permalink
add self-defined unit_types, good with QGIS 3.28
Browse files Browse the repository at this point in the history
  • Loading branch information
coolzhao committed Aug 1, 2023
1 parent 7e6ac94 commit fc588ef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/sam_processing_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
from ..ui.icons import QIcon_GeoSAMEncoder
from ..docs import encoder_help

# 0 for meters, 6 for degrees, 9 for unknown
UNIT_METERS = 0
UNIT_DEGREES = 6


class SamProcessingAlgorithm(QgsProcessingAlgorithm):
"""
Expand Down Expand Up @@ -312,7 +316,7 @@ def processAlgorithm(self, parameters, context, feedback):
# self.tr("Only support CRS with the units as meters")
# )

if rlayer.crs().mapUnits() == Qgis.DistanceUnit.Degrees:
if rlayer.crs().mapUnits() == UNIT_DEGREES: # Qgis.DistanceUnit.Degrees:
layer_units = 'degrees'
else:
layer_units = 'meters'
Expand All @@ -322,8 +326,8 @@ def processAlgorithm(self, parameters, context, feedback):
target_units = layer_units
else:
# when given res in meters by users, convert crs to utm if the original crs unit is degree
if crs.mapUnits() != Qgis.DistanceUnit.Meters:
if rlayer.crs().mapUnits() == Qgis.DistanceUnit.Degrees:
if crs.mapUnits() != UNIT_METERS: # Qgis.DistanceUnit.Meters:
if rlayer.crs().mapUnits() == UNIT_DEGREES: # Qgis.DistanceUnit.Degrees:
# estimate utm crs based on layer extent
crs = self.estimate_utm_crs(rlayer.extent())
else:
Expand Down

0 comments on commit fc588ef

Please sign in to comment.