Skip to content

Commit

Permalink
define structure with utils submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep committed Jun 22, 2023
1 parent 330b5b2 commit 3c1ec24
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
5 changes: 3 additions & 2 deletions algs/buildings2sewertAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
import qgis.utils
import processing
import os
from .common_functions import checkExtent, z_sampling
from .utils.check_extent import check_extent
from .utils.z_sampling import z_sampling

pluginPath = os.path.dirname(__file__)

Expand Down Expand Up @@ -153,7 +154,7 @@ def processAlgorithm(self, parameters, context, feedback):
nodes_o = self.parameterAsVectorLayer(parameters, 'MANHOLES', context)
mde = self.parameterAsRasterLayer(parameters, 'DEM', context)

if not checkExtent(parcels_o, mde) or not checkExtent(nodes_o, mde):
if not check_extent(parcels_o, mde) or not check_extent(nodes_o, mde):
feedback.reportError("Some of the layers are out of DEM")
return {}

Expand Down
2 changes: 1 addition & 1 deletion algs/catchmentAreasAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import qgis.utils
import processing
import os
from .common_functions import checkExtent, z_sampling
from .utils.z_sampling import z_sampling

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]

Expand Down
15 changes: 15 additions & 0 deletions algs/utils/check_extent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def check_extent(layer, background):
xMaxL = layer.extent().xMaximum()
xMinL = layer.extent().xMinimum()
yMaxL = layer.extent().yMaximum()
yMinL = layer.extent().yMinimum()

xMaxB = background.extent().xMaximum()
xMinB = background.extent().xMinimum()
yMaxB = background.extent().yMaximum()
yMinB = background.extent().yMinimum()

if xMaxL > xMaxB or xMinL < xMinB or yMaxL > yMaxB or yMinL < yMinB:
return False
else:
return True
22 changes: 1 addition & 21 deletions algs/common_functions.py → algs/utils/z_sampling.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
from qgis.PyQt.QtCore import *
from PyQt5.QtGui import QIcon
from qgis.core import *
import qgis.utils
import processing

def checkExtent(layer, background):
xMaxL = layer.extent().xMaximum()
xMinL = layer.extent().xMinimum()
yMaxL = layer.extent().yMaximum()
yMinL = layer.extent().yMinimum()

xMaxB = background.extent().xMaximum()
xMinB = background.extent().xMinimum()
yMaxB = background.extent().yMaximum()
yMinB = background.extent().yMinimum()

if xMaxL > xMaxB or xMinL < xMinB or yMaxL > yMaxB or yMinL < yMinB:
return False
else:
return True

def z_sampling(points, mde, feedback):

#set the progressbar
Expand Down Expand Up @@ -58,4 +38,4 @@ def z_sampling(points, mde, feedback):

#update progressbar
feedback.setProgress(int(current * total))
return mem_layer
return mem_layer

0 comments on commit 3c1ec24

Please sign in to comment.