Skip to content

Commit ae589a8

Browse files
committed
Versão 4.17.27: modifica o merge lines para receber camadas que impedem a quebra e para realizar as operações dentro da moldura
1 parent 3f7ddc5 commit ae589a8

File tree

15 files changed

+590
-21
lines changed

15 files changed

+590
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG
22

3-
## 4.17.26 - dev
3+
## 4.17.27 - dev
44

55
Novas Funcionalidades:
66

@@ -32,6 +32,8 @@ Melhorias:
3232
- Novo formato de exportação para os arquivos de configuração do Snap Hierárquico e Enforce Spatial Rules (os antigos ainda funcionam);
3333
- Configuração de tooltip adicionada na caixa de ferramentas de workflow (é retrocompatível com o formato anterior de descrição no model);
3434
- Melhora o comportamento do algoritmo de identificar linhas pequenas de primeira ordem (exclui casos de linhas que cruzam a moldura);
35+
- O processo de unir linhas agora pode receber camadas ponto e linha que impedem a união caso exista um elemento dessas camadas em um ponto de união;
36+
- O processo de unir linhas agora só une linhas com pontos de união dentro da moldura (quando for informada uma);
3537

3638
Correção de bugs:
3739

DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/cleanGeometriesAlgorithm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def cleanGeometriesInsideGeographicBoundary(
264264
tol=snap,
265265
context=context,
266266
feedback=multiStepFeedback,
267+
geographicBoundsLyr=geographicBoundsLyr,
267268
)
268269
)
269270
outputLyr = algRunner.runRenameField(

DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/hierarchicalSnapLayerOnLayerAndUpdateAlgorithm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def updateOriginalLayers(
413413
outsideLyr=outsideLyr,
414414
tol=auxDict["snap"],
415415
context=context,
416+
geographicBoundaryLyr=geographicBoundaryLyr,
416417
)
417418
outputLyr = self.algRunner.runRenameField(
418419
inputLayer=outputLyr,

DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/mergeLinesAlgorithm.py

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
QgsProcessingException,
3939
QgsProcessingMultiStepFeedback,
4040
QgsWkbTypes,
41+
QgsProcessingParameterMultipleLayers,
4142
)
4243

4344
from .validationAlgorithm import ValidationAlgorithm
@@ -50,6 +51,9 @@ class MergeLinesAlgorithm(ValidationAlgorithm):
5051
IGNORE_VIRTUAL_FIELDS = "IGNORE_VIRTUAL_FIELDS"
5152
IGNORE_PK_FIELDS = "IGNORE_PK_FIELDS"
5253
ALLOW_CLOSED_LINES_ON_OUTPUT = "ALLOW_CLOSED_LINES_ON_OUTPUT"
54+
POINT_FILTER_LAYERS = "POINT_FILTER_LAYERS"
55+
LINE_FILTER_LAYERS = "LINE_FILTER_LAYERS"
56+
GEOGRAPHIC_BOUNDARY = "GEOGRAPHIC_BOUNDARY"
5357

5458
def initAlgorithm(self, config):
5559
"""
@@ -97,6 +101,30 @@ def initAlgorithm(self, config):
97101
defaultValue=False,
98102
)
99103
)
104+
self.addParameter(
105+
QgsProcessingParameterMultipleLayers(
106+
self.POINT_FILTER_LAYERS,
107+
self.tr("Point Filter Layers"),
108+
QgsProcessing.TypeVectorPoint,
109+
optional=True,
110+
)
111+
)
112+
self.addParameter(
113+
QgsProcessingParameterMultipleLayers(
114+
self.LINE_FILTER_LAYERS,
115+
self.tr("Line Filter Layers"),
116+
QgsProcessing.TypeVectorLine,
117+
optional=True,
118+
)
119+
)
120+
self.addParameter(
121+
QgsProcessingParameterVectorLayer(
122+
self.GEOGRAPHIC_BOUNDARY,
123+
self.tr("Geographic Boundary"),
124+
[QgsProcessing.TypeVectorPolygon],
125+
optional=True,
126+
)
127+
)
100128

101129
def processAlgorithm(self, parameters, context, feedback):
102130
"""
@@ -124,7 +152,21 @@ def processAlgorithm(self, parameters, context, feedback):
124152
allowClosedLines = self.parameterAsBool(
125153
parameters, self.ALLOW_CLOSED_LINES_ON_OUTPUT, context
126154
)
127-
nSteps = 8
155+
pointFilterLyrList = self.parameterAsLayerList(
156+
parameters, self.POINT_FILTER_LAYERS, context
157+
)
158+
lineFilterLyrList = self.parameterAsLayerList(
159+
parameters, self.LINE_FILTER_LAYERS, context
160+
)
161+
geographicBoundaryLyr = self.parameterAsVectorLayer(
162+
parameters, self.GEOGRAPHIC_BOUNDARY, context
163+
)
164+
nSteps = (
165+
9
166+
+ 3 * (pointFilterLyrList != [])
167+
+ 3 * (lineFilterLyrList != [])
168+
+ (geographicBoundaryLyr is not None)
169+
)
128170
multiStepFeedback = QgsProcessingMultiStepFeedback(nSteps, feedback)
129171
currentStep = 0
130172
multiStepFeedback.setCurrentStep(currentStep)
@@ -139,6 +181,21 @@ def processAlgorithm(self, parameters, context, feedback):
139181
context=context,
140182
feedback=multiStepFeedback,
141183
)
184+
if localCache.featureCount() == 0:
185+
return {}
186+
currentStep += 1
187+
multiStepFeedback.setCurrentStep(currentStep)
188+
localCache = (
189+
self.algRunner.runExtractByLocation(
190+
inputLyr=localCache,
191+
intersectLyr=geographicBoundaryLyr,
192+
predicate=AlgRunner.Intersects,
193+
context=context,
194+
feedback=multiStepFeedback,
195+
)
196+
if geographicBoundaryLyr is not None
197+
else localCache
198+
)
142199
currentStep += 1
143200
multiStepFeedback.setCurrentStep(currentStep)
144201
nodesLayer = self.algRunner.runExtractSpecificVertices(
@@ -178,6 +235,86 @@ def processAlgorithm(self, parameters, context, feedback):
178235
addEdgeLength=True,
179236
)
180237
currentStep += 1
238+
constraintNodeIds = set()
239+
240+
if pointFilterLyrList:
241+
# Merge point layers if multiple
242+
multiStepFeedback.setCurrentStep(currentStep)
243+
multiStepFeedback.pushInfo(
244+
self.tr("Identifying constraint nodes from point layers...")
245+
)
246+
mergedPointLyr = self.algRunner.runMergeVectorLayers(
247+
pointFilterLyrList, context, multiStepFeedback
248+
)
249+
currentStep += 1
250+
multiStepFeedback.setCurrentStep(currentStep)
251+
self.algRunner.runCreateSpatialIndex(
252+
mergedPointLyr, context, multiStepFeedback, is_child_algorithm=True
253+
)
254+
currentStep += 1
255+
multiStepFeedback.setCurrentStep(currentStep)
256+
# Find nodes that intersect with points
257+
nodesFromPoints = self.algRunner.runExtractByLocation(
258+
inputLyr=nodesLayer,
259+
intersectLyr=mergedPointLyr,
260+
predicate=[self.algRunner.Intersects],
261+
context=context,
262+
feedback=multiStepFeedback,
263+
)
264+
currentStep += 1
265+
266+
for nodeFeat in nodesFromPoints.getFeatures():
267+
geom = nodeFeat.geometry()
268+
geomWkb = geom.asWkb()
269+
constraintNodeIds.add(nodeDict[geomWkb])
270+
271+
if lineFilterLyrList:
272+
# Merge line layers if multiple
273+
multiStepFeedback.setCurrentStep(currentStep)
274+
multiStepFeedback.pushInfo(
275+
self.tr("Identifying constraint nodes from line layers...")
276+
)
277+
mergedLineLyr = self.algRunner.runMergeVectorLayers(
278+
lineFilterLyrList, context, multiStepFeedback
279+
)
280+
currentStep += 1
281+
multiStepFeedback.setCurrentStep(currentStep)
282+
self.algRunner.runCreateSpatialIndex(
283+
mergedLineLyr, context, multiStepFeedback, is_child_algorithm=True
284+
)
285+
currentStep += 1
286+
multiStepFeedback.setCurrentStep(currentStep)
287+
# Find nodes that intersect with lines
288+
nodesFromLines = self.algRunner.runExtractByLocation(
289+
inputLyr=nodesLayer,
290+
intersectLyr=mergedLineLyr,
291+
predicate=[self.algRunner.Intersects],
292+
context=context,
293+
feedback=multiStepFeedback,
294+
)
295+
currentStep += 1
296+
297+
for nodeFeat in nodesFromLines.getFeatures():
298+
geom = nodeFeat.geometry()
299+
geomWkb = geom.asWkb()
300+
constraintNodeIds.add(nodeDict[geomWkb])
301+
if geographicBoundaryLyr is not None:
302+
currentStep += 1
303+
multiStepFeedback.setCurrentStep(currentStep)
304+
# Find nodes that intersect with points
305+
nodesOutsideGeographicBounds = self.algRunner.runExtractByLocation(
306+
inputLyr=nodesLayer,
307+
intersectLyr=geographicBoundaryLyr,
308+
predicate=[self.algRunner.Disjoint],
309+
context=context,
310+
feedback=multiStepFeedback,
311+
)
312+
currentStep += 1
313+
314+
for nodeFeat in nodesOutsideGeographicBounds.getFeatures():
315+
geom = nodeFeat.geometry()
316+
geomWkb = geom.asWkb()
317+
constraintNodeIds.add(nodeDict[geomWkb])
181318
multiStepFeedback.setCurrentStep(currentStep)
182319
multiStepFeedback.pushInfo(self.tr("Finding mergeable edges"))
183320
outputGraphDict = graphHandler.find_mergeable_edges_on_graph(
@@ -211,6 +348,7 @@ def computeLambda(x):
211348
isMulti=QgsWkbTypes.isMultiType(inputLyr.wkbType()),
212349
nodeIdDict=nodeIdDict,
213350
allowClosedLines=allowClosedLines,
351+
constraintNodeIds=constraintNodeIds,
214352
)
215353

216354
futures = set()

DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/topologicalCleanAlgorithm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def topologicalCleanWithGeographicBounds(
277277
tol=snap,
278278
context=context,
279279
feedback=multiStepFeedback,
280+
geographicBoundaryLyr=geographicBoundsLyr,
280281
)
281282
)
282283

DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/topologicalDouglasLineSimplificationAlgorithm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def runTopologicalDouglasWithGeographicBounds(
315315
tol=snap,
316316
context=context,
317317
feedback=multiStepFeedback,
318+
geographicBoundaryLyr=geographicBoundsLyr,
318319
)
319320
)
320321
renamedOutputLyr = algRunner.runRenameField(

DsgTools/core/DSGToolsProcessingAlgs/algRunner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,9 +2184,14 @@ def runDSGToolsMergeLines(
21842184
ignoreVirtualFields=True,
21852185
ignorePkFields=True,
21862186
allowClosed=False,
2187+
pointFilterLyrList=None,
2188+
lineFilterLyrList=None,
2189+
geographicBoundaryLyr=None,
21872190
feedback=None,
21882191
) -> None:
21892192
attributeBlackList = [] if attributeBlackList is None else attributeBlackList
2193+
pointFilterLyrList = [] if pointFilterLyrList is None else pointFilterLyrList
2194+
lineFilterLyrList = [] if lineFilterLyrList is None else lineFilterLyrList
21902195
output = processing.run(
21912196
"dsgtools:mergelineswithsameattributeset",
21922197
{
@@ -2196,6 +2201,9 @@ def runDSGToolsMergeLines(
21962201
"IGNORE_VIRTUAL_FIELDS": ignoreVirtualFields,
21972202
"IGNORE_PK_FIELDS": ignorePkFields,
21982203
"ALLOW_CLOSED": allowClosed,
2204+
"POINT_FILTER_LAYERS": pointFilterLyrList,
2205+
"LINE_FILTER_LAYERS": lineFilterLyrList,
2206+
"GEOGRAPHIC_BOUNDARY": geographicBoundaryLyr,
21992207
},
22002208
context=context,
22012209
feedback=feedback,

0 commit comments

Comments
 (0)