From 8113c9b8fda2e714b2ff87b215ed4069fc718d14 Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 22 Sep 2025 14:45:16 -0300 Subject: [PATCH 1/2] fix identify attribute changes in lines --- .../identifyAttributeChangesInLines.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py b/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py index 846d94c7e..cb8b8dfdb 100644 --- a/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py +++ b/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py @@ -56,14 +56,14 @@ class IdentifyAttributeChangesInLines(ValidationAlgorithm): def initAlgorithm(self, config=None): self.addParameter( QgsProcessingParameterVectorLayer( - "INPUT_LAYER", + self.INPUT_LAYER, self.tr("Input Layer"), types=[QgsProcessing.TypeVectorLine], ) ) self.addParameter( QgsProcessingParameterField( - "INPUT_FIELDS", + self.INPUT_FIELDS, self.tr("Fields to consider"), type=QgsProcessingParameterField.Any, parentLayerParameterName="INPUT_LAYER", @@ -73,7 +73,7 @@ def initAlgorithm(self, config=None): self.addParameter( QgsProcessingParameterNumber( - "INPUT_ANGLE", + self.INPUT_ANGLE, self.tr("Maximum angle between lines"), type=QgsProcessingParameterNumber.Double, minValue=0, @@ -82,7 +82,7 @@ def initAlgorithm(self, config=None): self.addParameter( QgsProcessingParameterNumber( - "INPUT_MAX_SIZE", + self.INPUT_MAX_SIZE, self.tr("Maximum size"), type=QgsProcessingParameterNumber.Double, optional=True, @@ -97,10 +97,10 @@ def initAlgorithm(self, config=None): ) def processAlgorithm(self, parameters, context, feedback): - layer = self.parameterAsVectorLayer(parameters, "INPUT_LAYER", context) - inputFields = self.parameterAsFields(parameters, "INPUT_FIELDS", context) - angle = self.parameterAsDouble(parameters, "INPUT_ANGLE", context) - maxLength = self.parameterAsDouble(parameters, "INPUT_MAX_SIZE", context) + layer = self.parameterAsVectorLayer(parameters, self.INPUT_LAYER, context) + inputFields = self.parameterAsFields(parameters, self.INPUT_FIELDS, context) + angle = self.parameterAsDouble(parameters, self.INPUT_ANGLE, context) + maxLength = self.parameterAsDouble(parameters, self.INPUT_MAX_SIZE, context) algRunner = AlgRunner() self.prepareFlagSink(parameters, layer, QgsWkbTypes.MultiPoint, context) multiStepFeedback = QgsProcessingMultiStepFeedback(4, feedback) @@ -125,9 +125,9 @@ def processAlgorithm(self, parameters, context, feedback): if multiStepFeedback.isCanceled(): return {self.FLAGS: self.flag_id} featGeom = feature.geometry() - for geometry in featGeom.constGet(): - ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) - lineTouched = self.linesTouchedOnPoint(inputLyr, feature, ptFin) + geometry = featGeom.constGet() + ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) + lineTouched = self.linesTouchedOnPoint(inputLyr, feature, ptFin) if len(lineTouched) == 0: continue smallerAngle = 360 @@ -257,9 +257,9 @@ def filterFlagsInMultipleIntersectionsCenario( lineAndPointArray = [] for line in lineLayer.getFeatures(): lineGeom = line.geometry() - for geometry in lineGeom.constGet(): - ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) - ptIni = QgsGeometry.fromPointXY(QgsPointXY(geometry[0])) + geometry = lineGeom.constGet() + ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) + ptIni = QgsGeometry.fromPointXY(QgsPointXY(geometry[0])) if ptFin.intersects(point[0]): lineAndPointArray.append([line, ptFin]) if ptIni.intersects(point[0]): From ca807f891c55fcddc531fc231a6992a2ac057779 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 26 Sep 2025 11:49:21 -0300 Subject: [PATCH 2/2] fix bug multipart and linestring --- CHANGELOG.md | 3 +- .../identifyAttributeChangesInLines.py | 29 +++++++++++++++---- DsgTools/metadata.txt | 2 +- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c596c0b97..ea2405eba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## 4.19.14 - dev +## 4.19.15 - dev Novas Funcionalidades: @@ -30,6 +30,7 @@ Correção de bugs: - Corrige bug no processo de corrigir conectividade de linhas; - Corrige bug no processo de identificação de erros de ângulos pequenos na cobertura; - Corrige bug no carregamento de arquivo json no assign format rules; +- Corrige bug no processo de identificação de mudança de atributos em linhas (permitir a entrada de camada LineString e MultiLineString); ## 4.18.1 - 2025-06-04 diff --git a/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py b/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py index cb8b8dfdb..b1bea1b45 100644 --- a/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py +++ b/DsgTools/core/DSGToolsProcessingAlgs/Algs/ValidationAlgs/identifyAttributeChangesInLines.py @@ -33,6 +33,7 @@ QgsProcessingParameterField, QgsProcessingParameterNumber, QgsGeometry, + QgsLineString, QgsExpression, QgsWkbTypes, QgsVectorLayer, @@ -126,7 +127,11 @@ def processAlgorithm(self, parameters, context, feedback): return {self.FLAGS: self.flag_id} featGeom = feature.geometry() geometry = featGeom.constGet() - ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) + if featGeom.isMultipart(): + for line in geometry: + ptFin = QgsGeometry.fromPointXY(QgsPointXY(line[-1])) + else: + ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) lineTouched = self.linesTouchedOnPoint(inputLyr, feature, ptFin) if len(lineTouched) == 0: continue @@ -202,12 +207,19 @@ def linesTouchedOnPoint( return lines def adjacentPoint(self, line: QgsFeature, point) -> QgsPointXY: - vertexPoint = line.geometry().closestVertexWithContext(point)[1] - adjpoints = line.geometry().adjacentVertices(vertexPoint) + if isinstance(line, QgsFeature): + geometry = line.geometry() + elif isinstance(line, QgsLineString): + geometry = QgsGeometry(line) + else: + print('oi') + pass + vertexPoint = geometry.closestVertexWithContext(point)[1] + adjpoints = geometry.adjacentVertices(vertexPoint) adjptvertex = adjpoints[0] if adjptvertex < 0: adjptvertex = adjpoints[1] - adjpt = line.geometry().vertexAt(adjptvertex) + adjpt = geometry.vertexAt(adjptvertex) return QgsPointXY(adjpt) def anglesBetweenLines( @@ -258,8 +270,13 @@ def filterFlagsInMultipleIntersectionsCenario( for line in lineLayer.getFeatures(): lineGeom = line.geometry() geometry = lineGeom.constGet() - ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) - ptIni = QgsGeometry.fromPointXY(QgsPointXY(geometry[0])) + if lineGeom.isMultipart(): + for l in geometry: + ptFin = QgsGeometry.fromPointXY(QgsPointXY(l[-1])) + ptIni = QgsGeometry.fromPointXY(QgsPointXY(l[0])) + else: + ptFin = QgsGeometry.fromPointXY(QgsPointXY(geometry[-1])) + ptIni = QgsGeometry.fromPointXY(QgsPointXY(geometry[0])) if ptFin.intersects(point[0]): lineAndPointArray.append([line, ptFin]) if ptIni.intersects(point[0]): diff --git a/DsgTools/metadata.txt b/DsgTools/metadata.txt index 68ebbf0d9..59a2d578c 100644 --- a/DsgTools/metadata.txt +++ b/DsgTools/metadata.txt @@ -10,7 +10,7 @@ name=DSG Tools qgisMinimumVersion=3.22 description=Brazilian Army Cartographic Production Tools -version=4.19.14 +version=4.19.15 author=Brazilian Army Geographic Service email=dsgtools@dsg.eb.mil.br about=