├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── images ├── README2023-05-31-12-05-39.png ├── lista_de_ferramentas_processing.png ├── modelo_importacao_recart.png └── relation_replicator.gif ├── qgis2CartTop-example.png ├── qgis2CartTop ├── __init__.py ├── metadata.txt ├── processing_provider │ ├── __init__.py │ ├── criar_nos_ferroviarios.py │ ├── criar_nos_hidrograficos.py │ ├── criar_nos_rodoviarios.py │ ├── exportar_agua_lentica.py │ ├── exportar_area_agricola_florestal_mato.py │ ├── exportar_area_infra_trans_aereo.py │ ├── exportar_area_infra_trans_cabo.py │ ├── exportar_area_infra_trans_ferrov.py │ ├── exportar_area_infra_trans_rodov.py │ ├── exportar_area_infra_trans_via_navegavel.py │ ├── exportar_area_trabalho.py │ ├── exportar_areas_artificializadas.py │ ├── exportar_barreira.py │ ├── exportar_cabo_eletrico.py │ ├── exportar_conduta_de_agua.py │ ├── exportar_constru_polig.py │ ├── exportar_construcao_linear.py │ ├── exportar_curso_de_agua_area.py │ ├── exportar_curso_de_agua_eixo.py │ ├── exportar_curvas_de_nivel.py │ ├── exportar_designacao_local.py │ ├── exportar_edificio.py │ ├── exportar_elem_assoc_pgq.py │ ├── exportar_elem_assoc_telecomunicacoes.py │ ├── exportar_elemento_associado_de_agua.py │ ├── exportar_elemento_associado_de_eletricidade.py │ ├── exportar_fronteira.py │ ├── exportar_fronteira_terra_agua.py │ ├── exportar_infra_trans_aereo.py │ ├── exportar_infra_trans_ferrov.py │ ├── exportar_infra_trans_rodov.py │ ├── exportar_infra_trans_via_navegavel.py │ ├── exportar_linhas_de_quebra.py │ ├── exportar_margem.py │ ├── exportar_mob_urbano_sinal.py │ ├── exportar_nascente.py │ ├── exportar_no_hidrografico.py │ ├── exportar_no_trans_ferrov.py │ ├── exportar_no_trans_rodov.py │ ├── exportar_obra_arte.py │ ├── exportar_oleoduto_gasoduto_subtancias_quimicas.py │ ├── exportar_ponto_interesse.py │ ├── exportar_pontos_cotados.py │ ├── exportar_queda_de_agua.py │ ├── exportar_seg_via_cabo.py │ ├── exportar_seg_via_ferrea.py │ ├── exportar_seg_via_rodov.py │ ├── exportar_sinal_geodesico.py │ ├── exportar_unidades_administrativas.py │ ├── exportar_via_rodov_limite.py │ ├── exportar_zona_humida.py │ ├── extras │ │ └── listas_codigos.json │ ├── provider.py │ └── utils.py └── processing_provider_validacao │ ├── __init__.py │ ├── consolidar_curso_agua_eixo.py │ ├── consolidar_curso_agua_eixo.sql │ ├── consolidar_curvas_de_nivel.py │ ├── consolidar_curvas_de_nivel.sql │ ├── consolidar_fronteira_terra_agua.py │ ├── consolidar_fronteira_terra_agua.sql │ ├── consolidar_linha_de_quebra.py │ ├── consolidar_linha_de_quebra.sql │ ├── consolidar_seg_via_rodov.py │ ├── consolidar_seg_via_rodov.sql │ ├── consolidar_via_rodov_limite.py │ ├── consolidar_via_rodov_limite.sql │ ├── homogenizar_z_aguas_lenticas.py │ ├── homogenizar_z_aguas_lenticas.sql │ └── provider_validacao.py └── tools ├── processing_tool_stub.pys └── recart_object.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # Visual Studio Code 107 | .vscode/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "RECART"] 2 | path = RECART 3 | url = https://github.com/dgterritorio/RECART.git 4 | -------------------------------------------------------------------------------- /images/README2023-05-31-12-05-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/images/README2023-05-31-12-05-39.png -------------------------------------------------------------------------------- /images/lista_de_ferramentas_processing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/images/lista_de_ferramentas_processing.png -------------------------------------------------------------------------------- /images/modelo_importacao_recart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/images/modelo_importacao_recart.png -------------------------------------------------------------------------------- /images/relation_replicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/images/relation_replicator.gif -------------------------------------------------------------------------------- /qgis2CartTop-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/qgis2CartTop-example.png -------------------------------------------------------------------------------- /qgis2CartTop/__init__.py: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------- 2 | # Copyright (C) 2019 Alexandre Neto 3 | #----------------------------------------------------------- 4 | # Licensed under the terms of GNU GPL 3 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Plugin structure based on Martin Dobias Minimal plugin 12 | # https://github.com/wonder-sk/qgis-minimal-plugin 13 | #--------------------------------------------------------------------- 14 | 15 | from PyQt5.QtWidgets import QAction, QMessageBox 16 | from qgis.core import QgsApplication 17 | from .processing_provider.provider import Provider 18 | from .processing_provider_validacao.provider_validacao import Provider_validacao 19 | 20 | def classFactory(iface): 21 | return qgis2CartTop(iface) 22 | 23 | 24 | class qgis2CartTop: 25 | def __init__(self, iface): 26 | self.iface = iface 27 | 28 | def initProcessing(self): 29 | self.provider = Provider() 30 | QgsApplication.processingRegistry().addProvider(self.provider) 31 | self.provider_validacao = Provider_validacao() 32 | QgsApplication.processingRegistry().addProvider(self.provider_validacao) 33 | 34 | def initGui(self): 35 | self.initProcessing() 36 | 37 | def unload(self): 38 | QgsApplication.processingRegistry().removeProvider(self.provider) 39 | QgsApplication.processingRegistry().removeProvider(self.provider_validacao) -------------------------------------------------------------------------------- /qgis2CartTop/metadata.txt: -------------------------------------------------------------------------------- 1 | [general] 2 | name=QGIS2CartTop (sponsors) 3 | description=(EN) QGIS plugin containing tools for data importation, validation 4 | and correction in a CartTop2/RECART database. 5 | (PT) Plugin QGIS com ferramentas para importação, validação e correcção 6 | de dados numa base de dados cartTop2/RECART 7 | about=(EN) QGIS Plugin to help import data into a PostgreSQL/PostGIS database 8 | following the data model defined by "Normas e Especificações Técnicas 9 | para a Cartografia Vectorial e de Imagem" (CartTop / ReCart) from 10 | Direcção-Geral do Território (Portugal). Also contains tools for eficient 11 | editing and improve data consistency. 12 | 13 | (PT) Plugin QGIS para ajudar na importação de dados numa base de dados 14 | PostgreSQL/PostGIS segundo o modelo de dados definido pelas "Normas e 15 | Especificações Técnicas para a Cartografia Vectorial e de Imagem" 16 | (CartTop / ReCart) da Direcção-Geral do Território (Portugal). Contém 17 | também ferramentas para uma edição mais eficiente e melhoria da 18 | consistência dos dados. 19 | version=0.3.1 20 | qgisMinimumVersion=3.0 21 | author=Alexandre Neto (NaturalGIS) co-funded by (Inforgeo, ArTop, Geoglobal, Geolayer) 22 | email=alexandre.neto@naturalgis.pt 23 | repository=https://github.com/SrNetoChan/qgis2CartTop 24 | tracker=https://github.com/SrNetoChan/qgis2CartTop/issues 25 | homepage=https://naturalgis.pt/qgis2carttop 26 | experimental=True 27 | hasProcessingProvider=yes 28 | tags=carttop, PostgreSQL, PostGIS, RECART, Processing 29 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/qgis2CartTop/processing_provider/__init__.py -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/criar_nos_ferroviarios.py: -------------------------------------------------------------------------------- 1 | from qgis.core import QgsProcessing 2 | from qgis.core import QgsProcessingAlgorithm 3 | from qgis.core import QgsProcessingMultiStepFeedback 4 | from qgis.core import QgsProcessingParameterVectorLayer 5 | from qgis.core import QgsProcessingParameterFeatureSink 6 | from qgis.PyQt.QtCore import QCoreApplication 7 | import processing 8 | 9 | 10 | class CriarNosFerroviarios(QgsProcessingAlgorithm): 11 | 12 | def initAlgorithm(self, config=None): 13 | self.addParameter(QgsProcessingParameterVectorLayer('readetrabalho', 'Área de trabalho', types=[QgsProcessing.TypeVectorPolygon], defaultValue=None)) 14 | self.addParameter(QgsProcessingParameterVectorLayer('segmentovia', 'Segmento de via-férrea', types=[QgsProcessing.TypeVectorLine], defaultValue=None)) 15 | self.addParameter(QgsProcessingParameterFeatureSink('NosTransporteFerroviario', 'Nós transporte ferroviário', type=QgsProcessing.TypeVectorAnyGeometry, createByDefault=True, supportsAppend=True, defaultValue=None)) 16 | 17 | def processAlgorithm(self, parameters, context, model_feedback): 18 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 19 | # overall progress through the model 20 | feedback = QgsProcessingMultiStepFeedback(7, model_feedback) 21 | results = {} 22 | outputs = {} 23 | 24 | # Refactor fields 25 | alg_params = { 26 | 'FIELDS_MAPPING': [{'expression': '$id','length': 0,'name': 'id','precision': 0,'type': 4}], 27 | 'INPUT': parameters['segmentovia'], 28 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 29 | } 30 | outputs['RefactorFields'] = processing.run('native:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 31 | 32 | feedback.setCurrentStep(1) 33 | if feedback.isCanceled(): 34 | return {} 35 | 36 | # Extrair vértices específicos 37 | alg_params = { 38 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 39 | 'VERTICES': '0, -1', 40 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 41 | } 42 | outputs['ExtrairVrticesEspecficos'] = processing.run('native:extractspecificvertices', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 43 | 44 | feedback.setCurrentStep(2) 45 | if feedback.isCanceled(): 46 | return {} 47 | 48 | # Eliminar geometrias duplicadas 49 | alg_params = { 50 | 'INPUT': outputs['ExtrairVrticesEspecficos']['OUTPUT'], 51 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 52 | } 53 | outputs['EliminarGeometriasDuplicadas'] = processing.run('qgis:deleteduplicategeometries', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 54 | 55 | feedback.setCurrentStep(3) 56 | if feedback.isCanceled(): 57 | return {} 58 | 59 | # Unir atributos pela localização (sumário) 60 | alg_params = { 61 | 'DISCARD_NONMATCHING': False, 62 | 'INPUT': outputs['EliminarGeometriasDuplicadas']['OUTPUT'], 63 | 'JOIN': outputs['RefactorFields']['OUTPUT'], 64 | 'JOIN_FIELDS': ['id'], 65 | 'PREDICATE': [0], 66 | 'SUMMARIES': [0], 67 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 68 | } 69 | outputs['UnirAtributosPelaLocalizaoSumrio'] = processing.run('qgis:joinbylocationsummary', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 70 | 71 | feedback.setCurrentStep(4) 72 | if feedback.isCanceled(): 73 | return {} 74 | 75 | # Clip 76 | alg_params = { 77 | 'INPUT': outputs['UnirAtributosPelaLocalizaoSumrio']['OUTPUT'], 78 | 'OVERLAY': parameters['readetrabalho'], 79 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 80 | } 81 | outputs['Clip'] = processing.run('native:clip', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 82 | 83 | feedback.setCurrentStep(5) 84 | if feedback.isCanceled(): 85 | return {} 86 | 87 | # Multipart to single part 88 | alg_params = { 89 | 'INPUT': outputs['Clip']['OUTPUT'], 90 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 91 | } 92 | outputs['MultipartToSingleparts'] = processing.run('native:multiparttosingleparts', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 93 | 94 | feedback.setCurrentStep(6) 95 | if feedback.isCanceled(): 96 | return {} 97 | 98 | # Refactor fields 99 | alg_params = { 100 | 'FIELDS_MAPPING': [{'expression': 'CASE WHEN id_count = 1 THEN \n\t\'4\' -- fim de via\nWHEN id_count = 2 THEN\n\'3\' --pseudo-no\nWHEN id_count > 2 THEN\n\'1\' -- juncao\nEND','length': 10,'name': 'valor_tipo_no_trans_ferrov','precision': 0,'type': 10}], 101 | 'INPUT': outputs['MultipartToSingleparts']['OUTPUT'], 102 | 'OUTPUT': parameters['NosTransporteFerroviario'] 103 | } 104 | outputs['RefactorFields'] = processing.run('native:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 105 | results['NosTransporteFerroviario'] = outputs['RefactorFields']['OUTPUT'] 106 | 107 | context.layerToLoadOnCompletionDetails(results['NosTransporteFerroviario']).name = "Nós Ferroviários" 108 | return results 109 | 110 | def name(self): 111 | return 'criar_nos_ferroviarios' 112 | 113 | def displayName(self): 114 | return '06. Criar nós ferroviários' 115 | 116 | def group(self): 117 | return '05 - Transportes (Transporte Ferroviário)' 118 | 119 | def groupId(self): 120 | return '05TransporteFerroviario' 121 | 122 | def createInstance(self): 123 | return CriarNosFerroviarios() 124 | 125 | def tr(self, string): 126 | """ 127 | Returns a translatable string with the self.tr() function. 128 | """ 129 | return QCoreApplication.translate('Processing', string) 130 | 131 | def shortHelpString(self): 132 | return self.tr("Cria camada de nós de transporte ferroviário com base " \ 133 | "numa camada de segmentos de via-férrea. \n\n Usando o número de " \ 134 | "ligações que o nó estabelece, tenta adivinhar o tipo" \ 135 | "de nó (2 ou mais ligações: junção; 1 ligação: pseudo-no " \ 136 | "; nenhuma ligação: fim de via). \n\n" \ 137 | "Nós fora da área de trabalho são eliminados." 138 | ) 139 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/criar_nos_rodoviarios.py: -------------------------------------------------------------------------------- 1 | from qgis.core import QgsProcessing 2 | from qgis.core import QgsProcessingAlgorithm 3 | from qgis.core import QgsProcessingMultiStepFeedback 4 | from qgis.core import QgsProcessingParameterVectorLayer 5 | from qgis.core import QgsProcessingParameterFeatureSink 6 | from qgis.PyQt.QtCore import QCoreApplication 7 | import processing 8 | 9 | 10 | class CriarNosRodoviarios(QgsProcessingAlgorithm): 11 | 12 | def initAlgorithm(self, config=None): 13 | self.addParameter(QgsProcessingParameterVectorLayer('readetrabalho', 'Área de trabalho', types=[QgsProcessing.TypeVectorPolygon], defaultValue=None)) 14 | self.addParameter(QgsProcessingParameterVectorLayer('segmentovia', 'Segmento de via rodoviária', types=[QgsProcessing.TypeVectorLine], defaultValue=None)) 15 | self.addParameter(QgsProcessingParameterFeatureSink('NsTransporteRodovirio', 'Nós transporte rodoviário', type=QgsProcessing.TypeVectorAnyGeometry, createByDefault=True, supportsAppend=True, defaultValue=None)) 16 | 17 | def processAlgorithm(self, parameters, context, model_feedback): 18 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 19 | # overall progress through the model 20 | feedback = QgsProcessingMultiStepFeedback(7, model_feedback) 21 | results = {} 22 | outputs = {} 23 | 24 | # Refactor fields 25 | alg_params = { 26 | 'FIELDS_MAPPING': [{'expression': '$id','length': 0,'name': 'id','precision': 0,'type': 4}], 27 | 'INPUT': parameters['segmentovia'], 28 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 29 | } 30 | outputs['RefactorFields'] = processing.run('native:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 31 | 32 | feedback.setCurrentStep(1) 33 | if feedback.isCanceled(): 34 | return {} 35 | 36 | # Extrair vértices específicos 37 | alg_params = { 38 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 39 | 'VERTICES': '0, -1', 40 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 41 | } 42 | outputs['ExtrairVrticesEspecficos'] = processing.run('native:extractspecificvertices', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 43 | 44 | feedback.setCurrentStep(2) 45 | if feedback.isCanceled(): 46 | return {} 47 | 48 | # Eliminar geometrias duplicadas 49 | alg_params = { 50 | 'INPUT': outputs['ExtrairVrticesEspecficos']['OUTPUT'], 51 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 52 | } 53 | outputs['EliminarGeometriasDuplicadas'] = processing.run('qgis:deleteduplicategeometries', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 54 | 55 | feedback.setCurrentStep(3) 56 | if feedback.isCanceled(): 57 | return {} 58 | 59 | # Unir atributos pela localização (sumário) 60 | alg_params = { 61 | 'DISCARD_NONMATCHING': False, 62 | 'INPUT': outputs['EliminarGeometriasDuplicadas']['OUTPUT'], 63 | 'JOIN': outputs['RefactorFields']['OUTPUT'], 64 | 'JOIN_FIELDS': ['id'], 65 | 'PREDICATE': [0], 66 | 'SUMMARIES': [0], 67 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 68 | } 69 | outputs['UnirAtributosPelaLocalizaoSumrio'] = processing.run('qgis:joinbylocationsummary', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 70 | 71 | feedback.setCurrentStep(4) 72 | if feedback.isCanceled(): 73 | return {} 74 | 75 | # Clip 76 | alg_params = { 77 | 'INPUT': outputs['UnirAtributosPelaLocalizaoSumrio']['OUTPUT'], 78 | 'OVERLAY': parameters['readetrabalho'], 79 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 80 | } 81 | outputs['Clip'] = processing.run('native:clip', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 82 | 83 | feedback.setCurrentStep(5) 84 | if feedback.isCanceled(): 85 | return {} 86 | 87 | # Multipart to single part 88 | alg_params = { 89 | 'INPUT': outputs['Clip']['OUTPUT'], 90 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 91 | } 92 | outputs['MultipartToSingleparts'] = processing.run('native:multiparttosingleparts', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 93 | 94 | feedback.setCurrentStep(6) 95 | if feedback.isCanceled(): 96 | return {} 97 | 98 | # Refactor fields 99 | alg_params = { 100 | 'FIELDS_MAPPING': [{'expression': 'CASE WHEN id_count = 1 THEN \n\t\'4\' -- fim de via\nWHEN id_count = 2 THEN\n\'3\' --pseudo-no\nWHEN id_count > 2 THEN\n\'1\' -- juncao\nEND','length': 10,'name': 'valor_tipo_no_trans_rodov','precision': 0,'type': 10}], 101 | 'INPUT': outputs['MultipartToSingleparts']['OUTPUT'], 102 | 'OUTPUT': parameters['NsTransporteRodovirio'] 103 | } 104 | outputs['RefactorFields'] = processing.run('native:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 105 | results['NsTransporteRodovirio'] = outputs['RefactorFields']['OUTPUT'] 106 | 107 | context.layerToLoadOnCompletionDetails(results['NsTransporteRodovirio']).name = "Nós Rodoviários" 108 | return results 109 | 110 | def name(self): 111 | return 'criar_nos_rodoviarios' 112 | 113 | def displayName(self): 114 | return '14. Criar nós rodoviários' 115 | 116 | def group(self): 117 | return '05 - Transportes (Transporte Rodoviário)' 118 | 119 | def groupId(self): 120 | return '05TransporteRodoviario' 121 | 122 | def createInstance(self): 123 | return CriarNosRodoviarios() 124 | 125 | def tr(self, string): 126 | """ 127 | Returns a translatable string with the self.tr() function. 128 | """ 129 | return QCoreApplication.translate('Processing', string) 130 | 131 | def shortHelpString(self): 132 | return self.tr("Cria camada de nós de transporte rodoviário com base " \ 133 | "numa camada de segmentos de via. \n\n Usando o número de " \ 134 | "ligações que o nó estabelece, tenta adivinhar o tipo" \ 135 | "de nó (2 ou mais ligações: junção; 1 ligação: pseudo-no " \ 136 | "; nenhuma ligação: fim de via). \n\n" \ 137 | "Nós fora da área de trabalho são eliminados." 138 | ) 139 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_area_agricola_florestal_mato.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarAreaAgricolaFlorestalMato(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_AREAS_AGRICOLAS_FLORESTAIS_MATOS = 'VALOR_AREAS_AGRICOLAS_FLORESTAIS_MATOS' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vaafm_keys, self.vaafm_values = get_lista_codigos('valorAreasAgricolasFlorestaisMatos') 47 | 48 | self.addParameter( 49 | QgsProcessingParameterEnum( 50 | self.VALOR_AREAS_AGRICOLAS_FLORESTAIS_MATOS, 51 | self.tr('Valor Areas Agricolas Florestais Matos'), 52 | self.vaafm_keys, 53 | defaultValue=0, 54 | optional=False, 55 | ) 56 | ) 57 | 58 | 59 | 60 | def processAlgorithm(self, parameters, context, model_feedback): 61 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 62 | # overall progress through the model 63 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 64 | results = {} 65 | outputs = {} 66 | 67 | # Convert enumerator to actual value 68 | valor_areas_agricolas_florestais_matos = self.vaafm_values[ 69 | self.parameterAsEnum( 70 | parameters, 71 | self.VALOR_AREAS_AGRICOLAS_FLORESTAIS_MATOS, 72 | context 73 | ) 74 | ] 75 | 76 | # Refactor fields 77 | alg_params = { 78 | 'FIELDS_MAPPING': [{ 79 | 'expression': 'now()', 80 | 'length': -1, 81 | 'name': 'inicio_objeto', 82 | 'precision': -1, 83 | 'type': 14 84 | 85 | },{ 86 | 'expression': f'\'{valor_areas_agricolas_florestais_matos}\'', 87 | 'length': 255, 88 | 'name': 'valor_areas_agricolas_florestais_matos', 89 | 'precision': -1, 90 | 'type': 10 91 | }], 92 | 'INPUT': parameters['INPUT'], 93 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 94 | } 95 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 96 | 97 | feedback.setCurrentStep(1) 98 | if feedback.isCanceled(): 99 | return {} 100 | 101 | alg_params = { 102 | 'ADDFIELDS': False, 103 | 'APPEND': True, 104 | 'A_SRS': None, 105 | 'CLIP': False, 106 | 'DATABASE': parameters[self.LIGACAO_RECART], 107 | 'DIM': 0, 108 | 'GEOCOLUMN': 'geometria', 109 | 'GT': '', 110 | 'GTYPE': 0, 111 | 'INDEX': False, 112 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 113 | 'LAUNDER': False, 114 | 'OPTIONS': '', 115 | 'OVERWRITE': False, 116 | 'PK': '', 117 | 'PRECISION': True, 118 | 'PRIMARY_KEY': 'identificador', 119 | 'PROMOTETOMULTI': False, 120 | 'SCHEMA': 'public', 121 | 'SEGMENTIZE': '', 122 | 'SHAPE_ENCODING': '', 123 | 'SIMPLIFY': '', 124 | 'SKIPFAILURES': False, 125 | 'SPAT': None, 126 | 'S_SRS': None, 127 | 'TABLE': 'area_agricola_florestal_mato', 128 | 'T_SRS': None, 129 | 'WHERE': '' 130 | } 131 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 132 | return results 133 | 134 | def name(self): 135 | return 'exportar_area_agricola_florestal_mato' 136 | 137 | def displayName(self): 138 | return '01. Exportar Área agrícola, florestal ou mato' 139 | 140 | def group(self): 141 | return '07 - Ocupação Do Solo' 142 | 143 | def groupId(self): 144 | return '07OcupacaoDoSolo' 145 | 146 | def createInstance(self): 147 | return ExportarAreaAgricolaFlorestalMato() 148 | 149 | def tr(self, string): 150 | """ 151 | Returns a translatable string with the self.tr() function. 152 | """ 153 | return QCoreApplication.translate('Processing', string) 154 | 155 | def shortHelpString(self): 156 | return self.tr("Exporta elementos do tipo Área agrícola, florestal ou mato para a base " \ 157 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 158 | "já configurada.\n\n" \ 159 | "A camada vectorial de input deve ser do tipo polígono 2D." 160 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_area_infra_trans_aereo.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarAreaInfraTransAereo(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_AREA_INFRA_TRANS_AEREO = 'VALOR_TIPO_AREA_INFRA_TRANS_AEREO' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtaita_keys, self.vtaita_values = get_lista_codigos('valorTipoAreaInfraTransAereo') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_AREA_INFRA_TRANS_AEREO, 50 | self.tr('Valor Tipo Area Infra Trans Aereo'), 51 | self.vtaita_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_area_infra_trans_aereo = self.vtaita_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_AREA_INFRA_TRANS_AEREO, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_area_infra_trans_aereo, 86 | 'length': 255, 87 | 'name': 'valor_tipo_area_infra_trans_aereo', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'area_infra_trans_aereo', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_area_infra_trans_aereo' 135 | 136 | def displayName(self): 137 | return '01. Exportar Área Infraestrutura Transporte Aéreo' 138 | 139 | def group(self): 140 | return '05 - Transportes (Transporte Aéreo)' 141 | 142 | def groupId(self): 143 | return '05TransporteAereo' 144 | 145 | def createInstance(self): 146 | return ExportarAreaInfraTransAereo() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Area Infra Trans Aereo para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_area_infra_trans_cabo.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarAreaInfraTransCabo(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | 26 | def initAlgorithm(self, config=None): 27 | self.addParameter( 28 | QgsProcessingParameterProviderConnection( 29 | self.LIGACAO_RECART, 30 | 'Ligação PostgreSQL', 31 | 'postgres', 32 | defaultValue=None 33 | ) 34 | ) 35 | 36 | input_layer = self.addParameter( 37 | QgsProcessingParameterFeatureSource( 38 | self.INPUT, 39 | self.tr(' Camada de polígono de entrada'), 40 | types=[QgsProcessing.TypeVectorPolygon], 41 | defaultValue=None 42 | ) 43 | ) 44 | 45 | 46 | def processAlgorithm(self, parameters, context, model_feedback): 47 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 48 | # overall progress through the model 49 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 50 | results = {} 51 | outputs = {} 52 | 53 | 54 | # Refactor fields 55 | alg_params = { 56 | 'FIELDS_MAPPING': [{ 57 | 'expression': 'now()', 58 | 'length': -1, 59 | 'name': 'inicio_objeto', 60 | 'precision': -1, 61 | 'type': 14 62 | 63 | }], 64 | 'INPUT': parameters['INPUT'], 65 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 66 | } 67 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 68 | 69 | feedback.setCurrentStep(1) 70 | if feedback.isCanceled(): 71 | return {} 72 | 73 | alg_params = { 74 | 'ADDFIELDS': False, 75 | 'APPEND': True, 76 | 'A_SRS': None, 77 | 'CLIP': False, 78 | 'DATABASE': parameters[self.LIGACAO_RECART], 79 | 'DIM': 0, 80 | 'GEOCOLUMN': 'geometria', 81 | 'GT': '', 82 | 'GTYPE': 0, 83 | 'INDEX': False, 84 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 85 | 'LAUNDER': False, 86 | 'OPTIONS': '', 87 | 'OVERWRITE': False, 88 | 'PK': '', 89 | 'PRECISION': True, 90 | 'PRIMARY_KEY': 'identificador', 91 | 'PROMOTETOMULTI': False, 92 | 'SCHEMA': 'public', 93 | 'SEGMENTIZE': '', 94 | 'SHAPE_ENCODING': '', 95 | 'SIMPLIFY': '', 96 | 'SKIPFAILURES': False, 97 | 'SPAT': None, 98 | 'S_SRS': None, 99 | 'TABLE': 'area_infra_trans_cabo', 100 | 'T_SRS': None, 101 | 'WHERE': '' 102 | } 103 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 104 | return results 105 | 106 | def name(self): 107 | return 'exportar_area_infra_trans_cabo' 108 | 109 | def displayName(self): 110 | return '08. Exportar Área da infraestrutura de transporte por cabo' 111 | 112 | def group(self): 113 | return '05 - Transportes (Transporte Por Cabo)' 114 | 115 | def groupId(self): 116 | return '05TransportesPorCabo' 117 | 118 | def createInstance(self): 119 | return ExportarAreaInfraTransCabo() 120 | 121 | def tr(self, string): 122 | """ 123 | Returns a translatable string with the self.tr() function. 124 | """ 125 | return QCoreApplication.translate('Processing', string) 126 | 127 | def shortHelpString(self): 128 | return self.tr("Exporta elementos do tipo Área da infraestrutura de transporte por cabo para a base " \ 129 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 130 | "já configurada.\n\n" \ 131 | "A camada vectorial de input deve ser do tipo polígono 2D." 132 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_area_infra_trans_ferrov.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean, 12 | QgsProcessingParameterField) 13 | 14 | import processing 15 | from .utils import get_lista_codigos 16 | 17 | 18 | class ExportarAreaInfraTransFerrov(QgsProcessingAlgorithm): 19 | 20 | # Constants used to refer to parameters and outputs. They will be 21 | # used when calling the algorithm from another algorithm, or when 22 | # calling from the QGIS console. 23 | 24 | LIGACAO_RECART = 'LIGACAO_RECART' 25 | INPUT = 'INPUT' 26 | CAMPO_COM_INFRA_TRANS_FERROV_ID = 'CAMPO_COM_INFRA_TRANS_FERROV_ID' 27 | 28 | def initAlgorithm(self, config=None): 29 | self.addParameter( 30 | QgsProcessingParameterProviderConnection( 31 | self.LIGACAO_RECART, 32 | 'Ligação PostgreSQL', 33 | 'postgres', 34 | defaultValue=None 35 | ) 36 | ) 37 | 38 | input_layer = self.addParameter( 39 | QgsProcessingParameterFeatureSource( 40 | self.INPUT, 41 | self.tr(' Camada de polígono de entrada'), 42 | types=[QgsProcessing.TypeVectorPolygon], 43 | defaultValue=None 44 | ) 45 | ) 46 | 47 | self.addParameter( 48 | QgsProcessingParameterField( 49 | self.CAMPO_COM_INFRA_TRANS_FERROV_ID, 50 | self.tr(' Campo com ID da Infraestrutura de Transporte Ferroviário'), 51 | type=QgsProcessingParameterField.String, 52 | parentLayerParameterName=self.INPUT, 53 | allowMultiple=False, 54 | defaultValue='' 55 | ) 56 | ) 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Get the name of the selected fields 67 | campo_com_infra_trans_ferrov_id = self.parameterAsString( 68 | parameters, 69 | self.CAMPO_COM_INFRA_TRANS_FERROV_ID, 70 | context 71 | ) 72 | 73 | # Refactor fields 74 | alg_params = { 75 | 'FIELDS_MAPPING': [{ 76 | 'expression': 'now()', 77 | 'length': -1, 78 | 'name': 'inicio_objeto', 79 | 'precision': -1, 80 | 'type': 14 81 | 82 | },{ 83 | 'expression': f'\"{campo_com_infra_trans_ferrov_id}\"', 84 | 'length': 255, 85 | 'name': 'infra_trans_ferrov_id', 86 | 'precision': 0, 87 | 'type': 10 88 | }], 89 | 'INPUT': parameters['INPUT'], 90 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 91 | } 92 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 93 | 94 | feedback.setCurrentStep(1) 95 | if feedback.isCanceled(): 96 | return {} 97 | 98 | alg_params = { 99 | 'ADDFIELDS': False, 100 | 'APPEND': True, 101 | 'A_SRS': None, 102 | 'CLIP': False, 103 | 'DATABASE': parameters[self.LIGACAO_RECART], 104 | 'DIM': 0, 105 | 'GEOCOLUMN': 'geometria', 106 | 'GT': '', 107 | 'GTYPE': 0, 108 | 'INDEX': False, 109 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 110 | 'LAUNDER': False, 111 | 'OPTIONS': '', 112 | 'OVERWRITE': False, 113 | 'PK': '', 114 | 'PRECISION': True, 115 | 'PRIMARY_KEY': 'identificador', 116 | 'PROMOTETOMULTI': False, 117 | 'SCHEMA': 'public', 118 | 'SEGMENTIZE': '', 119 | 'SHAPE_ENCODING': '', 120 | 'SIMPLIFY': '', 121 | 'SKIPFAILURES': False, 122 | 'SPAT': None, 123 | 'S_SRS': None, 124 | 'TABLE': 'area_infra_trans_ferrov', 125 | 'T_SRS': None, 126 | 'WHERE': '' 127 | } 128 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 129 | return results 130 | 131 | def name(self): 132 | return 'exportar_area_infra_trans_ferrov' 133 | 134 | def displayName(self): 135 | return '03. Exportar Area Infra Trans Ferrov' 136 | 137 | def group(self): 138 | return '05 - Transportes (Transporte Ferroviário)' 139 | 140 | def groupId(self): 141 | return '05TransporteFerroviario' 142 | 143 | def createInstance(self): 144 | return ExportarAreaInfraTransFerrov() 145 | 146 | def tr(self, string): 147 | """ 148 | Returns a translatable string with the self.tr() function. 149 | """ 150 | return QCoreApplication.translate('Processing', string) 151 | 152 | def shortHelpString(self): 153 | return self.tr("Exporta elementos do tipo Area Infra Trans Ferrov para a base " \ 154 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 155 | "já configurada.\n\n" \ 156 | "A camada vectorial de input deve ser do tipo polígono 2D." 157 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_area_infra_trans_rodov.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean, 12 | QgsProcessingParameterFieldMapping, 13 | QgsProcessingParameterField) 14 | 15 | import processing 16 | from .utils import get_lista_codigos 17 | 18 | 19 | class ExportarAreaInfraTransRodov(QgsProcessingAlgorithm): 20 | 21 | # Constants used to refer to parameters and outputs. They will be 22 | # used when calling the algorithm from another algorithm, or when 23 | # calling from the QGIS console. 24 | 25 | LIGACAO_RECART = 'LIGACAO_RECART' 26 | INPUT = 'INPUT' 27 | CAMPO_COM_INFRA_TRANS_RODOV_ID = 'CAMPO_COM_INFRA_TRANS_RODOV_ID' 28 | 29 | def initAlgorithm(self, config=None): 30 | self.addParameter( 31 | QgsProcessingParameterProviderConnection( 32 | self.LIGACAO_RECART, 33 | 'Ligação PostgreSQL', 34 | 'postgres', 35 | defaultValue=None 36 | ) 37 | ) 38 | 39 | input_layer = self.addParameter( 40 | QgsProcessingParameterFeatureSource( 41 | self.INPUT, 42 | self.tr(' Camada de polígono de entrada'), 43 | types=[QgsProcessing.TypeVectorPolygon], 44 | defaultValue=None 45 | ) 46 | ) 47 | 48 | 49 | self.addParameter( 50 | QgsProcessingParameterField( 51 | self.CAMPO_COM_INFRA_TRANS_RODOV_ID, 52 | self.tr(' Campo com ID da Infraestrutura de Transporte Rodoviário'), 53 | type=QgsProcessingParameterField.String, 54 | parentLayerParameterName=self.INPUT, 55 | allowMultiple=False, 56 | defaultValue='' 57 | ) 58 | ) 59 | 60 | def processAlgorithm(self, parameters, context, model_feedback): 61 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 62 | # overall progress through the model 63 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 64 | results = {} 65 | outputs = {} 66 | 67 | 68 | # Get the name of the selected fields 69 | campo_com_infra_trans_rodov_id = self.parameterAsString( 70 | parameters, 71 | self.CAMPO_COM_INFRA_TRANS_RODOV_ID, 72 | context 73 | ) 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': f'\"{campo_com_infra_trans_rodov_id}\"', 86 | 'length': 255, 87 | 'name': 'infra_trans_rodov_id', 88 | 'precision': 0, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'area_infra_trans_rodov', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_area_infra_trans_rodov' 135 | 136 | def displayName(self): 137 | return '12. Exportar Área da infraestrutura de transporte rodoviário' 138 | 139 | def group(self): 140 | return '05 - Transportes (Transporte Rodoviário)' 141 | 142 | def groupId(self): 143 | return '05TransporteRodoviario' 144 | 145 | def createInstance(self): 146 | return ExportarAreaInfraTransRodov() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Área da infraestrutura de transporte rodoviário para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo polígono 2D e deve conter um campo com o id "\ 159 | "da respectiva Infraestrutura de transporte rodoviário" 160 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_area_infra_trans_via_navegavel.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarAreaInfraTransViaNavegavel(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_AREA_INFRA_TRANS_VIA_NAVEGAVEL = 'VALOR_TIPO_AREA_INFRA_TRANS_VIA_NAVEGAVEL' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtaitvn_keys, self.vtaitvn_values = get_lista_codigos('valorTipoAreaInfraTransViaNavegavel') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_AREA_INFRA_TRANS_VIA_NAVEGAVEL, 50 | self.tr('Valor Tipo Area Infra Trans Via Navegavel'), 51 | self.vtaitvn_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_area_infra_trans_via_navegavel = self.vtaitvn_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_AREA_INFRA_TRANS_VIA_NAVEGAVEL, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_area_infra_trans_via_navegavel, 86 | 'length': 255, 87 | 'name': 'valor_tipo_area_infra_trans_via_navegavel', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'area_infra_trans_via_navegavel', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_area_infra_trans_via_navegavel' 135 | 136 | def displayName(self): 137 | return '10. Exportar Área da infraestrutura de transporte por via navegável' 138 | 139 | def group(self): 140 | return '05 - Transportes (Transporte Por Via Navegável)' 141 | 142 | def groupId(self): 143 | return '05TransportePorViaNavegavel' 144 | 145 | def createInstance(self): 146 | return ExportarAreaInfraTransViaNavegavel() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Área da infraestrutura de transporte por via navegável para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_areas_artificializadas.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarAreasArtificializadas(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_AREAS_ARTIFICIALIZADAS = 'VALOR_AREAS_ARTIFICIALIZADAS' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vaa_keys, self.vaa_values = get_lista_codigos('valorAreasArtificializadas') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_AREAS_ARTIFICIALIZADAS, 50 | self.tr('Valor Areas Artificializadas'), 51 | self.vaa_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_areas_artificializadas = self.vaa_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_AREAS_ARTIFICIALIZADAS, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_areas_artificializadas, 86 | 'length': 255, 87 | 'name': 'valor_areas_artificializadas', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'areas_artificializadas', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_areas_artificializadas' 135 | 136 | def displayName(self): 137 | return '02. Exportar Área artificializada' 138 | 139 | def group(self): 140 | return '07 - Ocupação Do Solo' 141 | 142 | def groupId(self): 143 | return '07OcupacaoDoSolo' 144 | 145 | def createInstance(self): 146 | return ExportarAreasArtificializadas() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Área artificializada para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_barreira.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarBarreira(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_BARREIRA = 'VALOR_BARREIRA' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de linha ou polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorLine, QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vb_keys, self.vb_values = get_lista_codigos('valorBarreira') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_BARREIRA, 50 | self.tr('Valor Barreira'), 51 | self.vb_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_barreira = self.vb_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_BARREIRA, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_barreira, 86 | 'length': 255, 87 | 'name': 'valor_barreira', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'barreira', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_barreira' 135 | 136 | def displayName(self): 137 | return '02. Exportar Barreira' 138 | 139 | def group(self): 140 | return '04 - Hidrografia' 141 | 142 | def groupId(self): 143 | return '04Hidrografia' 144 | 145 | def createInstance(self): 146 | return ExportarBarreira() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Barreira para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo linha ou polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_constru_polig.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarConstruPolig(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_CONSTRUCAO = 'VALOR_TIPO_CONSTRUCAO' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto ou polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint, QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtc_keys, self.vtc_values = get_lista_codigos('valorTipoConstrucao') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_CONSTRUCAO, 50 | self.tr('Valor Tipo Construcao'), 51 | self.vtc_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_construcao = self.vtc_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_CONSTRUCAO, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_construcao, 86 | 'length': 255, 87 | 'name': 'valor_tipo_construcao', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'constru_polig', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_constru_polig' 135 | 136 | def displayName(self): 137 | return '02. Exportar Construção poligonal' 138 | 139 | def group(self): 140 | return '06 - Construções' 141 | 142 | def groupId(self): 143 | return '06Construcoes' 144 | 145 | def createInstance(self): 146 | return ExportarConstruPolig() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Construção poligonal para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto ou polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_curso_de_agua_area.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarCursoDeAguaArea(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | DELIMITACAO_CONHECIDA = 'DELIMITACAO_CONHECIDA' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.addParameter( 47 | QgsProcessingParameterBoolean( 48 | self.DELIMITACAO_CONHECIDA, 49 | self.tr('Delimitacao Conhecida'), 50 | defaultValue=0, 51 | optional=False, 52 | ) 53 | ) 54 | 55 | 56 | 57 | def processAlgorithm(self, parameters, context, model_feedback): 58 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 59 | # overall progress through the model 60 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 61 | results = {} 62 | outputs = {} 63 | 64 | 65 | # Refactor fields 66 | alg_params = { 67 | 'FIELDS_MAPPING': [{ 68 | 'expression': 'now()', 69 | 'length': -1, 70 | 'name': 'inicio_objeto', 71 | 'precision': -1, 72 | 'type': 14 73 | 74 | },{ 75 | 'expression': f"\'{parameters['DELIMITACAO_CONHECIDA']}\'", 76 | 'length': 255, 77 | 'name': 'delimitacao_conhecida', 78 | 'precision': -1, 79 | 'type': 1 80 | }], 81 | 'INPUT': parameters['INPUT'], 82 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 83 | } 84 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 85 | 86 | feedback.setCurrentStep(1) 87 | if feedback.isCanceled(): 88 | return {} 89 | 90 | alg_params = { 91 | 'ADDFIELDS': False, 92 | 'APPEND': True, 93 | 'A_SRS': None, 94 | 'CLIP': False, 95 | 'DATABASE': parameters[self.LIGACAO_RECART], 96 | 'DIM': 1, 97 | 'GEOCOLUMN': 'geometria', 98 | 'GT': '', 99 | 'GTYPE': 0, 100 | 'INDEX': False, 101 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 102 | 'LAUNDER': False, 103 | 'OPTIONS': '', 104 | 'OVERWRITE': False, 105 | 'PK': '', 106 | 'PRECISION': True, 107 | 'PRIMARY_KEY': 'identificador', 108 | 'PROMOTETOMULTI': False, 109 | 'SCHEMA': 'public', 110 | 'SEGMENTIZE': '', 111 | 'SHAPE_ENCODING': '', 112 | 'SIMPLIFY': '', 113 | 'SKIPFAILURES': False, 114 | 'SPAT': None, 115 | 'S_SRS': None, 116 | 'TABLE': 'curso_de_agua_area', 117 | 'T_SRS': None, 118 | 'WHERE': '' 119 | } 120 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 121 | return results 122 | 123 | def name(self): 124 | return 'exportar_curso_de_agua_area' 125 | 126 | def displayName(self): 127 | return '03. Exportar Curso de água (área)' 128 | 129 | def group(self): 130 | return '04 - Hidrografia' 131 | 132 | def groupId(self): 133 | return '04Hidrografia' 134 | 135 | def createInstance(self): 136 | return ExportarCursoDeAguaArea() 137 | 138 | def tr(self, string): 139 | """ 140 | Returns a translatable string with the self.tr() function. 141 | """ 142 | return QCoreApplication.translate('Processing', string) 143 | 144 | def shortHelpString(self): 145 | return self.tr("Exporta elementos do tipo Curso De Agua Area para a base " \ 146 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 147 | "já configurada.\n\n" \ 148 | "A camada vectorial de input deve ser do tipo polígono 3D." 149 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_elem_assoc_pgq.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarElemAssocPGQ(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_ELEMENTO_ASSOCIADO_PGQ = 'VALOR_ELEMENTO_ASSOCIADO_PGQ' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto ou polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint, QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.veap_keys, self.veap_values = get_lista_codigos('valorElementoAssociadoPGQ') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_ELEMENTO_ASSOCIADO_PGQ, 50 | self.tr('Valor Elemento Associado Pgq'), 51 | self.veap_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_elemento_associado_pgq = self.veap_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_ELEMENTO_ASSOCIADO_PGQ, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': f'\'{valor_elemento_associado_pgq}\'', 86 | 'length': 255, 87 | 'name': 'valor_elemento_associado_pgq', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'elem_assoc_pgq', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_elem_assoc_pgq' 135 | 136 | def displayName(self): 137 | return '06. Exportar Elemento associado de petróleo, gás e substâncias químicas' 138 | 139 | def group(self): 140 | return '08 - Infraestruturas e serviços' 141 | 142 | def groupId(self): 143 | return '08infraestruturas' 144 | 145 | def createInstance(self): 146 | return ExportarElemAssocPGQ() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Elemento associado de petróleo, gás e substâncias químicas para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto ou polígono -." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_elem_assoc_telecomunicacoes.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarElemAssocTelecomunicacoes(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_ELEMENTO_ASSOCIADO_TELECOMUNICACOES = 'VALOR_ELEMENTO_ASSOCIADO_TELECOMUNICACOES' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.veat_keys, self.veat_values = get_lista_codigos('valorElementoAssociadoTelecomunicacoes') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_ELEMENTO_ASSOCIADO_TELECOMUNICACOES, 50 | self.tr('Valor Elemento Associado Telecomunicacoes'), 51 | self.veat_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_elemento_associado_telecomunicacoes = self.veat_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_ELEMENTO_ASSOCIADO_TELECOMUNICACOES, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_elemento_associado_telecomunicacoes, 86 | 'length': 255, 87 | 'name': 'valor_elemento_associado_telecomunicacoes', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'elem_assoc_telecomunicacoes', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_elem_assoc_telecomunicacoes' 135 | 136 | def displayName(self): 137 | return '07. Exportar Elemento associado de telecomunicações' 138 | 139 | def group(self): 140 | return '08 - Infraestruturas e serviços' 141 | 142 | def groupId(self): 143 | return '08infraestruturas' 144 | 145 | def createInstance(self): 146 | return ExportarElemAssocTelecomunicacoes() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Elemento associado de telecomunicações para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_fronteira.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProperty, 10 | QgsProcessingParameterBoolean) 11 | import processing 12 | from .utils import get_lista_codigos 13 | 14 | 15 | class ExportarFronteira(QgsProcessingAlgorithm): 16 | 17 | # Constants used to refer to parameters and outputs. They will be 18 | # used when calling the algorithm from another algorithm, or when 19 | # calling from the QGIS console. 20 | 21 | LIGACAO_RECART = 'LIGACAO_RECART' 22 | INPUT = 'INPUT' 23 | VALOR_ESTADO_FRONTEIRA = 'VALOR_ESTADO_FRONTEIRA' 24 | DATA_PUBLICACAO = 'DATA_PUBLICACAO' 25 | 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr('Camada de Linhas de Entrada'), 41 | types=[QgsProcessing.TypeVectorLine], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vef_keys, self.vef_values = get_lista_codigos('valorEstadoFronteira') 47 | 48 | self.addParameter( 49 | QgsProcessingParameterEnum( 50 | self.VALOR_ESTADO_FRONTEIRA, 51 | self.tr('Valor Estado Fronteira'), 52 | self.vef_keys, 53 | defaultValue=0, 54 | optional=False, 55 | ) 56 | ) 57 | 58 | self.addParameter( 59 | QgsProcessingParameterString( 60 | self.DATA_PUBLICACAO, 61 | 'Data de publicação', 62 | multiLine=False, 63 | defaultValue='2021-02-05' 64 | ) 65 | ) 66 | 67 | def processAlgorithm(self, parameters, context, model_feedback): 68 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 69 | # overall progress through the model 70 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 71 | results = {} 72 | outputs = {} 73 | 74 | # Convert enumerator to actual value 75 | valor_estado_fronteira = self.vef_values[ 76 | self.parameterAsEnum( 77 | parameters, 78 | self.VALOR_ESTADO_FRONTEIRA, 79 | context 80 | ) 81 | ] 82 | 83 | # Refactor fields 84 | alg_params = { 85 | 'FIELDS_MAPPING': [{ 86 | 'expression': 'now()', 87 | 'length': -1, 88 | 'name': 'inicio_objeto', 89 | 'precision': -1, 90 | 'type': 14 91 | },{ 92 | 'expression': valor_estado_fronteira, 93 | 'length': 255, 94 | 'name': 'valor_estado_fronteira', 95 | 'precision': -1, 96 | 'type': 10 97 | },{ 98 | 'expression': f"\'{parameters['DATA_PUBLICACAO']}\'", 99 | 'length': 255, 100 | 'name': 'data_publicacao', 101 | 'precision': 0, 102 | 'type': 14 103 | }], 104 | 'INPUT': parameters['INPUT'], 105 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 106 | } 107 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 108 | 109 | feedback.setCurrentStep(1) 110 | if feedback.isCanceled(): 111 | return {} 112 | 113 | alg_params = { 114 | 'ADDFIELDS': False, 115 | 'APPEND': True, 116 | 'A_SRS': None, 117 | 'CLIP': False, 118 | 'DATABASE': parameters[self.LIGACAO_RECART], 119 | 'DIM': 0, 120 | 'GEOCOLUMN': 'geometria', 121 | 'GT': '', 122 | 'GTYPE': 4, 123 | 'INDEX': True, 124 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 125 | 'LAUNDER': True, 126 | 'OPTIONS': '', 127 | 'OVERWRITE': False, 128 | 'PK': '', 129 | 'PRECISION': True, 130 | 'PRIMARY_KEY': 'identificador', 131 | 'PROMOTETOMULTI': True, 132 | 'SCHEMA': 'public', 133 | 'SEGMENTIZE': '', 134 | 'SHAPE_ENCODING': '', 135 | 'SIMPLIFY': '', 136 | 'SKIPFAILURES': False, 137 | 'SPAT': None, 138 | 'S_SRS': None, 139 | 'TABLE': 'fronteira', 140 | 'T_SRS': None, 141 | 'WHERE': '' 142 | } 143 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 144 | return results 145 | 146 | def name(self): 147 | return 'exportar_fronteira' 148 | 149 | def displayName(self): 150 | return '04. Exportar fronteira' 151 | 152 | def group(self): 153 | return '01 - Unidades Administrativas' 154 | 155 | def groupId(self): 156 | return '01UnidadesAdministrativas' 157 | 158 | def createInstance(self): 159 | return ExportarFronteira() 160 | 161 | def tr(self, string): 162 | """ 163 | Returns a translatable string with the self.tr() function. 164 | """ 165 | return QCoreApplication.translate('Processing', string) 166 | 167 | def shortHelpString(self): 168 | return self.tr("Exporta elementos do tipo fronteira para a base " \ 169 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 170 | "já configurada.\n\n" \ 171 | "A camada vectorial de input deve ser do tipo linha 2D." 172 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_fronteira_terra_agua.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarFronteiraTerraAgua(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | DATA_FONTE_DADOS = 'DATA_FONTE_DADOS' 26 | ILHA = 'ILHA' 27 | 28 | def initAlgorithm(self, config=None): 29 | self.addParameter( 30 | QgsProcessingParameterProviderConnection( 31 | self.LIGACAO_RECART, 32 | 'Ligação PostgreSQL', 33 | 'postgres', 34 | defaultValue=None 35 | ) 36 | ) 37 | 38 | input_layer = self.addParameter( 39 | QgsProcessingParameterFeatureSource( 40 | self.INPUT, 41 | self.tr(' Camada de linha de entrada'), 42 | types=[QgsProcessing.TypeVectorLine], 43 | defaultValue=None 44 | ) 45 | ) 46 | 47 | self.addParameter( 48 | QgsProcessingParameterString( 49 | self.DATA_FONTE_DADOS, 50 | self.tr('Data Fonte Dados'), 51 | defaultValue='1900-01-01', 52 | optional=False, 53 | ) 54 | ) 55 | 56 | 57 | self.addParameter( 58 | QgsProcessingParameterBoolean( 59 | self.ILHA, 60 | self.tr('Ilha'), 61 | defaultValue=0, 62 | optional=False, 63 | ) 64 | ) 65 | 66 | 67 | 68 | def processAlgorithm(self, parameters, context, model_feedback): 69 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 70 | # overall progress through the model 71 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 72 | results = {} 73 | outputs = {} 74 | 75 | 76 | # Refactor fields 77 | alg_params = { 78 | 'FIELDS_MAPPING': [{ 79 | 'expression': 'now()', 80 | 'length': -1, 81 | 'name': 'inicio_objeto', 82 | 'precision': -1, 83 | 'type': 14 84 | 85 | },{ 86 | 'expression': f"\'{parameters['DATA_FONTE_DADOS']}\'", 87 | 'length': 255, 88 | 'name': 'data_fonte_dados', 89 | 'precision': -1, 90 | 'type': 14 91 | },{ 92 | 'expression': f"\'{parameters['ILHA']}\'", 93 | 'length': 255, 94 | 'name': 'ilha', 95 | 'precision': -1, 96 | 'type': 1 97 | }], 98 | 'INPUT': parameters['INPUT'], 99 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 100 | } 101 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 102 | 103 | feedback.setCurrentStep(1) 104 | if feedback.isCanceled(): 105 | return {} 106 | 107 | alg_params = { 108 | 'ADDFIELDS': False, 109 | 'APPEND': True, 110 | 'A_SRS': None, 111 | 'CLIP': False, 112 | 'DATABASE': parameters[self.LIGACAO_RECART], 113 | 'DIM': 1, 114 | 'GEOCOLUMN': 'geometria', 115 | 'GT': '', 116 | 'GTYPE': 0, 117 | 'INDEX': False, 118 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 119 | 'LAUNDER': False, 120 | 'OPTIONS': '', 121 | 'OVERWRITE': False, 122 | 'PK': '', 123 | 'PRECISION': True, 124 | 'PRIMARY_KEY': 'identificador', 125 | 'PROMOTETOMULTI': False, 126 | 'SCHEMA': 'public', 127 | 'SEGMENTIZE': '', 128 | 'SHAPE_ENCODING': '', 129 | 'SIMPLIFY': '', 130 | 'SKIPFAILURES': False, 131 | 'SPAT': None, 132 | 'S_SRS': None, 133 | 'TABLE': 'fronteira_terra_agua', 134 | 'T_SRS': None, 135 | 'WHERE': '' 136 | } 137 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 138 | return results 139 | 140 | def name(self): 141 | return 'exportar_fronteira_terra_agua' 142 | 143 | def displayName(self): 144 | return '05. Exportar Fronteira Terra-Água' 145 | 146 | def group(self): 147 | return '04 - Hidrografia' 148 | 149 | def groupId(self): 150 | return '04Hidrografia' 151 | 152 | def createInstance(self): 153 | return ExportarFronteiraTerraAgua() 154 | 155 | def tr(self, string): 156 | """ 157 | Returns a translatable string with the self.tr() function. 158 | """ 159 | return QCoreApplication.translate('Processing', string) 160 | 161 | def shortHelpString(self): 162 | return self.tr("Exporta elementos do tipo Fronteira Terra Agua para a base " \ 163 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 164 | "já configurada.\n\n" \ 165 | "A camada vectorial de input deve ser do tipo linha 3D." 166 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_infra_trans_ferrov.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarInfraTransFerrov(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_INFRA_TRANS_FERROV = 'VALOR_TIPO_INFRA_TRANS_FERROV' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtitf_keys, self.vtitf_values = get_lista_codigos('valorTipoInfraTransFerrov') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_INFRA_TRANS_FERROV, 50 | self.tr('Valor Tipo Infra Trans Ferrov'), 51 | self.vtitf_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_infra_trans_ferrov = self.vtitf_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_INFRA_TRANS_FERROV, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_infra_trans_ferrov, 86 | 'length': 255, 87 | 'name': 'valor_tipo_infra_trans_ferrov', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'infra_trans_ferrov', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_infra_trans_ferrov' 135 | 136 | def displayName(self): 137 | return '02. Exportar Infra Trans Ferrov' 138 | 139 | def group(self): 140 | return '04 - Transportes (Transporte Ferroviário)' 141 | 142 | def groupId(self): 143 | return '05TransporteFerroviario' 144 | 145 | def createInstance(self): 146 | return ExportarInfraTransFerrov() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Infra Trans Ferrov para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_infra_trans_rodov.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarInfraTransRodov(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_INFRA_TRANS_RODOV = 'VALOR_TIPO_INFRA_TRANS_RODOV' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtitr_keys, self.vtitr_values = get_lista_codigos('valorTipoInfraTransRodov') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_INFRA_TRANS_RODOV, 50 | self.tr('Valor Tipo Infra Trans Rodov'), 51 | self.vtitr_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_infra_trans_rodov = self.vtitr_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_INFRA_TRANS_RODOV, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_infra_trans_rodov, 86 | 'length': 255, 87 | 'name': 'valor_tipo_infra_trans_rodov', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'infra_trans_rodov', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_infra_trans_rodov' 135 | 136 | def displayName(self): 137 | return '13. Exportar Infraestrutura de transporte rodoviário' 138 | 139 | def group(self): 140 | return '05 - Transportes (Transporte Rodoviário)' 141 | 142 | def groupId(self): 143 | return '05TransporteRodoviario' 144 | 145 | def createInstance(self): 146 | return ExportarInfraTransRodov() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Infraestrutura de transporte rodoviário para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_infra_trans_via_navegavel.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarInfraTransViaNavegavel(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_INFRA_TRANS_VIA_NAVEGAVEL = 'VALOR_TIPO_INFRA_TRANS_VIA_NAVEGAVEL' 26 | NOME = 'NOME' 27 | 28 | def initAlgorithm(self, config=None): 29 | self.addParameter( 30 | QgsProcessingParameterProviderConnection( 31 | self.LIGACAO_RECART, 32 | 'Ligação PostgreSQL', 33 | 'postgres', 34 | defaultValue=None 35 | ) 36 | ) 37 | 38 | input_layer = self.addParameter( 39 | QgsProcessingParameterFeatureSource( 40 | self.INPUT, 41 | self.tr(' Camada de ponto de entrada'), 42 | types=[QgsProcessing.TypeVectorPoint], 43 | defaultValue=None 44 | ) 45 | ) 46 | 47 | self.vtitvn_keys, self.vtitvn_values = get_lista_codigos('valorTipoInfraTransViaNavegavel') 48 | self.addParameter( 49 | QgsProcessingParameterEnum( 50 | self.VALOR_TIPO_INFRA_TRANS_VIA_NAVEGAVEL, 51 | self.tr('Valor Tipo Infra Trans Via Navegavel'), 52 | self.vtitvn_keys, 53 | defaultValue=0, 54 | optional=False, 55 | ) 56 | ) 57 | 58 | 59 | self.addParameter( 60 | QgsProcessingParameterString( 61 | self.NOME, 62 | self.tr('Nome'), 63 | defaultValue='', 64 | optional=False, 65 | ) 66 | ) 67 | 68 | 69 | 70 | def processAlgorithm(self, parameters, context, model_feedback): 71 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 72 | # overall progress through the model 73 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 74 | results = {} 75 | outputs = {} 76 | 77 | # Convert enumerator to actual value 78 | valor_tipo_infra_trans_via_navegavel = self.vtitvn_values[ 79 | self.parameterAsEnum( 80 | parameters, 81 | self.VALOR_TIPO_INFRA_TRANS_VIA_NAVEGAVEL, 82 | context 83 | ) 84 | ] 85 | 86 | # Refactor fields 87 | alg_params = { 88 | 'FIELDS_MAPPING': [{ 89 | 'expression': 'now()', 90 | 'length': -1, 91 | 'name': 'inicio_objeto', 92 | 'precision': -1, 93 | 'type': 14 94 | 95 | },{ 96 | 'expression': valor_tipo_infra_trans_via_navegavel, 97 | 'length': 255, 98 | 'name': 'valor_tipo_infra_trans_via_navegavel', 99 | 'precision': -1, 100 | 'type': 10 101 | },{ 102 | 'expression': f"\'{parameters['NOME']}\'", 103 | 'length': 255, 104 | 'name': 'nome', 105 | 'precision': -1, 106 | 'type': 10 107 | }], 108 | 'INPUT': parameters['INPUT'], 109 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 110 | } 111 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 112 | 113 | feedback.setCurrentStep(1) 114 | if feedback.isCanceled(): 115 | return {} 116 | 117 | alg_params = { 118 | 'ADDFIELDS': False, 119 | 'APPEND': True, 120 | 'A_SRS': None, 121 | 'CLIP': False, 122 | 'DATABASE': parameters[self.LIGACAO_RECART], 123 | 'DIM': 0, 124 | 'GEOCOLUMN': 'geometria', 125 | 'GT': '', 126 | 'GTYPE': 0, 127 | 'INDEX': False, 128 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 129 | 'LAUNDER': False, 130 | 'OPTIONS': '', 131 | 'OVERWRITE': False, 132 | 'PK': '', 133 | 'PRECISION': True, 134 | 'PRIMARY_KEY': 'identificador', 135 | 'PROMOTETOMULTI': False, 136 | 'SCHEMA': 'public', 137 | 'SEGMENTIZE': '', 138 | 'SHAPE_ENCODING': '', 139 | 'SIMPLIFY': '', 140 | 'SKIPFAILURES': False, 141 | 'SPAT': None, 142 | 'S_SRS': None, 143 | 'TABLE': 'infra_trans_via_navegavel', 144 | 'T_SRS': None, 145 | 'WHERE': '' 146 | } 147 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 148 | return results 149 | 150 | def name(self): 151 | return 'exportar_infra_trans_via_navegavel' 152 | 153 | def displayName(self): 154 | return '11. Exportar Infraestrutura de transporte por via navegável' 155 | 156 | def group(self): 157 | return '05 - Transportes (Transporte Por Via Navegável)' 158 | 159 | def groupId(self): 160 | return '05TransportePorViaNavegavel' 161 | 162 | def createInstance(self): 163 | return ExportarInfraTransViaNavegavel() 164 | 165 | def tr(self, string): 166 | """ 167 | Returns a translatable string with the self.tr() function. 168 | """ 169 | return QCoreApplication.translate('Processing', string) 170 | 171 | def shortHelpString(self): 172 | return self.tr("Exporta elementos do tipo Infraestrutura de transporte por via navegável para a base " \ 173 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 174 | "já configurada.\n\n" \ 175 | "A camada vectorial de input deve ser do tipo ponto 2D." 176 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_margem.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarMargem(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_MARGEM = 'VALOR_TIPO_MARGEM' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtm_keys, self.vtm_values = get_lista_codigos('valorTipoMargem') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_MARGEM, 50 | self.tr('Valor Tipo Margem'), 51 | self.vtm_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_margem = self.vtm_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_MARGEM, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_margem, 86 | 'length': 255, 87 | 'name': 'valor_tipo_margem', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'margem', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_margem' 135 | 136 | def displayName(self): 137 | return '06. Exportar Margem' 138 | 139 | def group(self): 140 | return '04 - Hidrografia' 141 | 142 | def groupId(self): 143 | return '04Hidrografia' 144 | 145 | def createInstance(self): 146 | return ExportarMargem() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Margem para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_mob_urbano_sinal.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarMobUrbanoSinal(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_MOB_URB_SINAL = 'VALOR_TIPO_MOB_URB_SINAL' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto ou polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint, QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtmus_keys, self.vtmus_values = get_lista_codigos('valorTipoMobUrbSinal') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_MOB_URB_SINAL, 50 | self.tr('Valor Tipo Mob Urb Sinal'), 51 | self.vtmus_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_mob_urb_sinal = self.vtmus_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_MOB_URB_SINAL, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_mob_urb_sinal, 86 | 'length': 255, 87 | 'name': 'valor_tipo_de_mob_urbano_sinal', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'mob_urbano_sinal', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_mob_urbano_sinal' 135 | 136 | def displayName(self): 137 | return '01. Exportar Mobiliário Urbano e sinalização' 138 | 139 | def group(self): 140 | return '09 - Mobiliário Urbano E Sinalização' 141 | 142 | def groupId(self): 143 | return '09MobiliarioUrbanoSinalizacao' 144 | 145 | def createInstance(self): 146 | return ExportarMobUrbanoSinal() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Mobiliário Urbano e sinalização para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto ou polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_nascente.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarNascente(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | 26 | def initAlgorithm(self, config=None): 27 | self.addParameter( 28 | QgsProcessingParameterProviderConnection( 29 | self.LIGACAO_RECART, 30 | 'Ligação PostgreSQL', 31 | 'postgres', 32 | defaultValue=None 33 | ) 34 | ) 35 | 36 | input_layer = self.addParameter( 37 | QgsProcessingParameterFeatureSource( 38 | self.INPUT, 39 | self.tr(' Camada de ponto de entrada'), 40 | types=[QgsProcessing.TypeVectorPoint], 41 | defaultValue=None 42 | ) 43 | ) 44 | 45 | 46 | def processAlgorithm(self, parameters, context, model_feedback): 47 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 48 | # overall progress through the model 49 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 50 | results = {} 51 | outputs = {} 52 | 53 | 54 | # Refactor fields 55 | alg_params = { 56 | 'FIELDS_MAPPING': [{ 57 | 'expression': 'now()', 58 | 'length': -1, 59 | 'name': 'inicio_objeto', 60 | 'precision': -1, 61 | 'type': 14 62 | 63 | }], 64 | 'INPUT': parameters['INPUT'], 65 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 66 | } 67 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 68 | 69 | feedback.setCurrentStep(1) 70 | if feedback.isCanceled(): 71 | return {} 72 | 73 | alg_params = { 74 | 'ADDFIELDS': False, 75 | 'APPEND': True, 76 | 'A_SRS': None, 77 | 'CLIP': False, 78 | 'DATABASE': parameters[self.LIGACAO_RECART], 79 | 'DIM': 1, 80 | 'GEOCOLUMN': 'geometria', 81 | 'GT': '', 82 | 'GTYPE': 0, 83 | 'INDEX': False, 84 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 85 | 'LAUNDER': False, 86 | 'OPTIONS': '', 87 | 'OVERWRITE': False, 88 | 'PK': '', 89 | 'PRECISION': True, 90 | 'PRIMARY_KEY': 'identificador', 91 | 'PROMOTETOMULTI': False, 92 | 'SCHEMA': 'public', 93 | 'SEGMENTIZE': '', 94 | 'SHAPE_ENCODING': '', 95 | 'SIMPLIFY': '', 96 | 'SKIPFAILURES': False, 97 | 'SPAT': None, 98 | 'S_SRS': None, 99 | 'TABLE': 'nascente', 100 | 'T_SRS': None, 101 | 'WHERE': '' 102 | } 103 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 104 | return results 105 | 106 | def name(self): 107 | return 'exportar_nascente' 108 | 109 | def displayName(self): 110 | return '07. Exportar Nascente' 111 | 112 | def group(self): 113 | return '04 - Hidrografia' 114 | 115 | def groupId(self): 116 | return '04Hidrografia' 117 | 118 | def createInstance(self): 119 | return ExportarNascente() 120 | 121 | def tr(self, string): 122 | """ 123 | Returns a translatable string with the self.tr() function. 124 | """ 125 | return QCoreApplication.translate('Processing', string) 126 | 127 | def shortHelpString(self): 128 | return self.tr("Exporta elementos do tipo Nascente para a base " \ 129 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 130 | "já configurada.\n\n" \ 131 | "A camada vectorial de input deve ser do tipo ponto 3D." 132 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_obra_arte.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarObraArte(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_OBRA_ARTE = 'VALOR_TIPO_OBRA_ARTE' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtoa_keys, self.vtoa_values = get_lista_codigos('valorTipoObraArte') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_OBRA_ARTE, 50 | self.tr('Valor Tipo Obra Arte'), 51 | self.vtoa_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_obra_arte = self.vtoa_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_OBRA_ARTE, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_obra_arte, 86 | 'length': 255, 87 | 'name': 'valor_tipo_obra_arte', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 1, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'obra_arte', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_obra_arte' 135 | 136 | def displayName(self): 137 | return '18. Exportar Obra de arte' 138 | 139 | def group(self): 140 | return '05 - Transportes (Obra De Arte)' 141 | 142 | def groupId(self): 143 | return '05TransporteObraArte' 144 | 145 | def createInstance(self): 146 | return ExportarObraArte() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Obra de arte para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo polígono 3D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_ponto_interesse.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarPontoInteresse(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_PONTO_INTERESSE = 'VALOR_TIPO_PONTO_INTERESSE' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de ponto ou polígono de entrada'), 41 | types=[QgsProcessing.TypeVectorPoint, QgsProcessing.TypeVectorPolygon], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtpi_keys, self.vtpi_values = get_lista_codigos('valorTipoPontoInteresse') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_PONTO_INTERESSE, 50 | self.tr('Valor Tipo Ponto Interesse'), 51 | self.vtpi_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_ponto_interesse = self.vtpi_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_PONTO_INTERESSE, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_ponto_interesse, 86 | 'length': 255, 87 | 'name': 'valor_tipo_ponto_interesse', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 0, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'ponto_interesse', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_ponto_interesse' 135 | 136 | def displayName(self): 137 | return '04. Exportar Ponto de interesse' 138 | 139 | def group(self): 140 | return '06 - Construções' 141 | 142 | def groupId(self): 143 | return '06Construcoes' 144 | 145 | def createInstance(self): 146 | return ExportarPontoInteresse() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Ponto de interesse para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo ponto ou polígono 2D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_pontos_cotados.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProperty, 8 | QgsProcessingParameterBoolean, 9 | QgsProcessingParameterProviderConnection) 10 | import processing 11 | from .utils import get_lista_codigos 12 | 13 | 14 | class Exportar_pontos_cotados(QgsProcessingAlgorithm): 15 | 16 | # Constants used to refer to parameters and outputs. They will be 17 | # used when calling the algorithm from another algorithm, or when 18 | # calling from the QGIS console. 19 | 20 | LIGACAO_RECART = 'LIGACAO_RECART' 21 | INPUT = 'INPUT' 22 | VALOR_CLASSIFICA_LAS = 'VALOR_CLASSIFICA_LAS' 23 | 24 | 25 | def initAlgorithm(self, config=None): 26 | self.addParameter( 27 | QgsProcessingParameterProviderConnection( 28 | self.LIGACAO_RECART, 29 | 'Ligação PostgreSQL', 30 | 'postgres', 31 | defaultValue=None 32 | ) 33 | ) 34 | 35 | self.addParameter( 36 | QgsProcessingParameterFeatureSource( 37 | self.INPUT, 38 | self.tr('Camada de Pontos de Entrada (3D)'), 39 | types=[QgsProcessing.TypeVectorPoint], 40 | defaultValue=None 41 | ) 42 | ) 43 | 44 | self.vcl_keys, self.vcl_values = get_lista_codigos('valorClassificaLAS') 45 | 46 | self.addParameter( 47 | QgsProcessingParameterEnum( 48 | self.VALOR_CLASSIFICA_LAS, 49 | self.tr('Valor Classifica LAS'), 50 | self.vcl_keys, 51 | defaultValue=0, 52 | optional=False, 53 | ) 54 | ) 55 | 56 | def processAlgorithm(self, parameters, context, model_feedback): 57 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 58 | # overall progress through the model 59 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 60 | results = {} 61 | outputs = {} 62 | 63 | # Convert enumerator to actual value 64 | valor_classifica_las = self.vcl_values[ 65 | self.parameterAsEnum( 66 | parameters, 67 | self.VALOR_CLASSIFICA_LAS, 68 | context 69 | ) 70 | ] 71 | 72 | # Refactor fields 73 | alg_params = { 74 | 'FIELDS_MAPPING': [{ 75 | 'expression': 'now()', 76 | 'length': -1, 77 | 'name': 'inicio_objeto', 78 | 'precision': -1, 79 | 'type': 14 80 | },{ 81 | 'expression': valor_classifica_las, 82 | 'length': 255, 83 | 'name': 'valor_classifica_las', 84 | 'precision': -1, 85 | 'type': 10 86 | }], 87 | 'INPUT': parameters['INPUT'], 88 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 89 | } 90 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 91 | 92 | feedback.setCurrentStep(1) 93 | if feedback.isCanceled(): 94 | return {} 95 | 96 | # Export to PostgreSQL (available connections) 97 | 98 | alg_params = { 99 | 'ADDFIELDS': False, 100 | 'APPEND': True, 101 | 'A_SRS': None, 102 | 'CLIP': False, 103 | 'DATABASE': parameters[self.LIGACAO_RECART], 104 | 'DIM': 1, 105 | 'GEOCOLUMN': 'geometria', 106 | 'GT': '', 107 | 'GTYPE': 3, 108 | 'INDEX': True, 109 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 110 | 'LAUNDER': True, 111 | 'OPTIONS': '', 112 | 'OVERWRITE': False, 113 | 'PK': '', 114 | 'PRECISION': True, 115 | 'PRIMARY_KEY': 'identificador', 116 | 'PROMOTETOMULTI': True, 117 | 'SCHEMA': 'public', 118 | 'SEGMENTIZE': '', 119 | 'SHAPE_ENCODING': '', 120 | 'SIMPLIFY': '', 121 | 'SKIPFAILURES': False, 122 | 'SPAT': None, 123 | 'S_SRS': None, 124 | 'TABLE': 'ponto_cotado', 125 | 'T_SRS': None, 126 | 'WHERE': '' 127 | } 128 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 129 | return results 130 | 131 | def name(self): 132 | return 'exportar_postos_cotados' 133 | 134 | def displayName(self): 135 | return '03. Exportar pontos cotados' 136 | 137 | def group(self): 138 | return '03 - Altimetria' 139 | 140 | def groupId(self): 141 | return '03altimetria' 142 | 143 | def createInstance(self): 144 | return Exportar_pontos_cotados() 145 | 146 | def tr(self, string): 147 | """ 148 | Returns a translatable string with the self.tr() function. 149 | """ 150 | return QCoreApplication.translate('Processing', string) 151 | 152 | def shortHelpString(self): 153 | return self.tr("Exporta elementos do tipo ponto cotado para a base " \ 154 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 155 | "já configurada.\n\n" \ 156 | "A camada vectorial de input deve ser do tipo ponto 3D." 157 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_queda_de_agua.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarQuedaDeAgua(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | 26 | def initAlgorithm(self, config=None): 27 | self.addParameter( 28 | QgsProcessingParameterProviderConnection( 29 | self.LIGACAO_RECART, 30 | 'Ligação PostgreSQL', 31 | 'postgres', 32 | defaultValue=None 33 | ) 34 | ) 35 | 36 | input_layer = self.addParameter( 37 | QgsProcessingParameterFeatureSource( 38 | self.INPUT, 39 | self.tr(' Camada de ponto de entrada'), 40 | types=[QgsProcessing.TypeVectorPoint], 41 | defaultValue=None 42 | ) 43 | ) 44 | 45 | 46 | def processAlgorithm(self, parameters, context, model_feedback): 47 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 48 | # overall progress through the model 49 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 50 | results = {} 51 | outputs = {} 52 | 53 | 54 | # Refactor fields 55 | alg_params = { 56 | 'FIELDS_MAPPING': [{ 57 | 'expression': 'now()', 58 | 'length': -1, 59 | 'name': 'inicio_objeto', 60 | 'precision': -1, 61 | 'type': 14 62 | 63 | }], 64 | 'INPUT': parameters['INPUT'], 65 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 66 | } 67 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 68 | 69 | feedback.setCurrentStep(1) 70 | if feedback.isCanceled(): 71 | return {} 72 | 73 | alg_params = { 74 | 'ADDFIELDS': False, 75 | 'APPEND': True, 76 | 'A_SRS': None, 77 | 'CLIP': False, 78 | 'DATABASE': parameters[self.LIGACAO_RECART], 79 | 'DIM': 1, 80 | 'GEOCOLUMN': 'geometria', 81 | 'GT': '', 82 | 'GTYPE': 0, 83 | 'INDEX': False, 84 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 85 | 'LAUNDER': False, 86 | 'OPTIONS': '', 87 | 'OVERWRITE': False, 88 | 'PK': '', 89 | 'PRECISION': True, 90 | 'PRIMARY_KEY': 'identificador', 91 | 'PROMOTETOMULTI': False, 92 | 'SCHEMA': 'public', 93 | 'SEGMENTIZE': '', 94 | 'SHAPE_ENCODING': '', 95 | 'SIMPLIFY': '', 96 | 'SKIPFAILURES': False, 97 | 'SPAT': None, 98 | 'S_SRS': None, 99 | 'TABLE': 'queda_de_agua', 100 | 'T_SRS': None, 101 | 'WHERE': '' 102 | } 103 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 104 | return results 105 | 106 | def name(self): 107 | return 'exportar_queda_de_agua' 108 | 109 | def displayName(self): 110 | return '09. Exportar Queda de Água' 111 | 112 | def group(self): 113 | return '04 - Hidrografia' 114 | 115 | def groupId(self): 116 | return '04Hidrografia' 117 | 118 | def createInstance(self): 119 | return ExportarQuedaDeAgua() 120 | 121 | def tr(self, string): 122 | """ 123 | Returns a translatable string with the self.tr() function. 124 | """ 125 | return QCoreApplication.translate('Processing', string) 126 | 127 | def shortHelpString(self): 128 | return self.tr("Exporta elementos do tipo Queda De Agua para a base " \ 129 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 130 | "já configurada.\n\n" \ 131 | "A camada vectorial de input deve ser do tipo ponto 3D." 132 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_seg_via_cabo.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarSegViaCabo(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | 26 | def initAlgorithm(self, config=None): 27 | self.addParameter( 28 | QgsProcessingParameterProviderConnection( 29 | self.LIGACAO_RECART, 30 | 'Ligação PostgreSQL', 31 | 'postgres', 32 | defaultValue=None 33 | ) 34 | ) 35 | 36 | input_layer = self.addParameter( 37 | QgsProcessingParameterFeatureSource( 38 | self.INPUT, 39 | self.tr(' Camada de linha de entrada'), 40 | types=[QgsProcessing.TypeVectorLine], 41 | defaultValue=None 42 | ) 43 | ) 44 | 45 | 46 | def processAlgorithm(self, parameters, context, model_feedback): 47 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 48 | # overall progress through the model 49 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 50 | results = {} 51 | outputs = {} 52 | 53 | 54 | # Refactor fields 55 | alg_params = { 56 | 'FIELDS_MAPPING': [{ 57 | 'expression': 'now()', 58 | 'length': -1, 59 | 'name': 'inicio_objeto', 60 | 'precision': -1, 61 | 'type': 14 62 | 63 | }], 64 | 'INPUT': parameters['INPUT'], 65 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 66 | } 67 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 68 | 69 | feedback.setCurrentStep(1) 70 | if feedback.isCanceled(): 71 | return {} 72 | 73 | alg_params = { 74 | 'ADDFIELDS': False, 75 | 'APPEND': True, 76 | 'A_SRS': None, 77 | 'CLIP': False, 78 | 'DATABASE': parameters[self.LIGACAO_RECART], 79 | 'DIM': 0, 80 | 'GEOCOLUMN': 'geometria', 81 | 'GT': '', 82 | 'GTYPE': 0, 83 | 'INDEX': False, 84 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 85 | 'LAUNDER': False, 86 | 'OPTIONS': '', 87 | 'OVERWRITE': False, 88 | 'PK': '', 89 | 'PRECISION': True, 90 | 'PRIMARY_KEY': 'identificador', 91 | 'PROMOTETOMULTI': False, 92 | 'SCHEMA': 'public', 93 | 'SEGMENTIZE': '', 94 | 'SHAPE_ENCODING': '', 95 | 'SIMPLIFY': '', 96 | 'SKIPFAILURES': False, 97 | 'SPAT': None, 98 | 'S_SRS': None, 99 | 'TABLE': 'seg_via_cabo', 100 | 'T_SRS': None, 101 | 'WHERE': '' 102 | } 103 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 104 | return results 105 | 106 | def name(self): 107 | return 'exportar_seg_via_cabo' 108 | 109 | def displayName(self): 110 | return '09. Exportar Segmento da via por cabo' 111 | 112 | def group(self): 113 | return '05 - Transportes (Transporte Por Cabo)' 114 | 115 | def groupId(self): 116 | return '05TransportesPorCabo' 117 | 118 | def createInstance(self): 119 | return ExportarSegViaCabo() 120 | 121 | def tr(self, string): 122 | """ 123 | Returns a translatable string with the self.tr() function. 124 | """ 125 | return QCoreApplication.translate('Processing', string) 126 | 127 | def shortHelpString(self): 128 | return self.tr("Exporta elementos do tipo Segmento da via por cabo para a base " \ 129 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 130 | "já configurada.\n\n" \ 131 | "A camada vectorial de input deve ser do tipo linha 2D." 132 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_via_rodov_limite.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarViaRodovLimite(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_TIPO_LIMITE = 'VALOR_TIPO_LIMITE' 26 | 27 | def initAlgorithm(self, config=None): 28 | self.addParameter( 29 | QgsProcessingParameterProviderConnection( 30 | self.LIGACAO_RECART, 31 | 'Ligação PostgreSQL', 32 | 'postgres', 33 | defaultValue=None 34 | ) 35 | ) 36 | 37 | input_layer = self.addParameter( 38 | QgsProcessingParameterFeatureSource( 39 | self.INPUT, 40 | self.tr(' Camada de linha de entrada'), 41 | types=[QgsProcessing.TypeVectorLine], 42 | defaultValue=None 43 | ) 44 | ) 45 | 46 | self.vtl_keys, self.vtl_values = get_lista_codigos('valorTipoLimite') 47 | self.addParameter( 48 | QgsProcessingParameterEnum( 49 | self.VALOR_TIPO_LIMITE, 50 | self.tr('Valor Tipo Limite'), 51 | self.vtl_keys, 52 | defaultValue=0, 53 | optional=False, 54 | ) 55 | ) 56 | 57 | 58 | 59 | def processAlgorithm(self, parameters, context, model_feedback): 60 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 61 | # overall progress through the model 62 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 63 | results = {} 64 | outputs = {} 65 | 66 | # Convert enumerator to actual value 67 | valor_tipo_limite = self.vtl_values[ 68 | self.parameterAsEnum( 69 | parameters, 70 | self.VALOR_TIPO_LIMITE, 71 | context 72 | ) 73 | ] 74 | 75 | # Refactor fields 76 | alg_params = { 77 | 'FIELDS_MAPPING': [{ 78 | 'expression': 'now()', 79 | 'length': -1, 80 | 'name': 'inicio_objeto', 81 | 'precision': -1, 82 | 'type': 14 83 | 84 | },{ 85 | 'expression': valor_tipo_limite, 86 | 'length': 255, 87 | 'name': 'valor_tipo_limite', 88 | 'precision': -1, 89 | 'type': 10 90 | }], 91 | 'INPUT': parameters['INPUT'], 92 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 93 | } 94 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 95 | 96 | feedback.setCurrentStep(1) 97 | if feedback.isCanceled(): 98 | return {} 99 | 100 | alg_params = { 101 | 'ADDFIELDS': False, 102 | 'APPEND': True, 103 | 'A_SRS': None, 104 | 'CLIP': False, 105 | 'DATABASE': parameters[self.LIGACAO_RECART], 106 | 'DIM': 1, 107 | 'GEOCOLUMN': 'geometria', 108 | 'GT': '', 109 | 'GTYPE': 0, 110 | 'INDEX': False, 111 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 112 | 'LAUNDER': False, 113 | 'OPTIONS': '', 114 | 'OVERWRITE': False, 115 | 'PK': '', 116 | 'PRECISION': True, 117 | 'PRIMARY_KEY': 'identificador', 118 | 'PROMOTETOMULTI': False, 119 | 'SCHEMA': 'public', 120 | 'SEGMENTIZE': '', 121 | 'SHAPE_ENCODING': '', 122 | 'SIMPLIFY': '', 123 | 'SKIPFAILURES': False, 124 | 'SPAT': None, 125 | 'S_SRS': None, 126 | 'TABLE': 'via_rodov_limite', 127 | 'T_SRS': None, 128 | 'WHERE': '' 129 | } 130 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 131 | return results 132 | 133 | def name(self): 134 | return 'exportar_via_rodov_limite' 135 | 136 | def displayName(self): 137 | return '16. Exportar Via rodoviária - Limite' 138 | 139 | def group(self): 140 | return '05 - Transportes (Transporte Rodoviário)' 141 | 142 | def groupId(self): 143 | return '05TransporteRodoviario' 144 | 145 | def createInstance(self): 146 | return ExportarViaRodovLimite() 147 | 148 | def tr(self, string): 149 | """ 150 | Returns a translatable string with the self.tr() function. 151 | """ 152 | return QCoreApplication.translate('Processing', string) 153 | 154 | def shortHelpString(self): 155 | return self.tr("Exporta elementos do tipo Via rodoviária - Limite para a base " \ 156 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 157 | "já configurada.\n\n" \ 158 | "A camada vectorial de input deve ser do tipo linha 3D." 159 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/exportar_zona_humida.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProcessingParameterFeatureSource, 6 | QgsProcessingParameterEnum, 7 | QgsProcessingParameterProviderConnection, 8 | QgsProcessingParameterString, 9 | QgsProcessingParameterNumber, 10 | QgsProperty, 11 | QgsProcessingParameterBoolean) 12 | 13 | import processing 14 | from .utils import get_lista_codigos 15 | 16 | 17 | class ExportarZonaHumida(QgsProcessingAlgorithm): 18 | 19 | # Constants used to refer to parameters and outputs. They will be 20 | # used when calling the algorithm from another algorithm, or when 21 | # calling from the QGIS console. 22 | 23 | LIGACAO_RECART = 'LIGACAO_RECART' 24 | INPUT = 'INPUT' 25 | VALOR_ZONA_HUMIDA = 'VALOR_ZONA_HUMIDA' 26 | MARE = 'MARE' 27 | 28 | def initAlgorithm(self, config=None): 29 | self.addParameter( 30 | QgsProcessingParameterProviderConnection( 31 | self.LIGACAO_RECART, 32 | 'Ligação PostgreSQL', 33 | 'postgres', 34 | defaultValue=None 35 | ) 36 | ) 37 | 38 | input_layer = self.addParameter( 39 | QgsProcessingParameterFeatureSource( 40 | self.INPUT, 41 | self.tr(' Camada de polígono de entrada'), 42 | types=[QgsProcessing.TypeVectorPolygon], 43 | defaultValue=None 44 | ) 45 | ) 46 | 47 | self.vzh_keys, self.vzh_values = get_lista_codigos('valorZonaHumida') 48 | self.addParameter( 49 | QgsProcessingParameterEnum( 50 | self.VALOR_ZONA_HUMIDA, 51 | self.tr('Valor Zona Humida'), 52 | self.vzh_keys, 53 | defaultValue=0, 54 | optional=False, 55 | ) 56 | ) 57 | 58 | 59 | self.addParameter( 60 | QgsProcessingParameterBoolean( 61 | self.MARE, 62 | self.tr('Mare'), 63 | defaultValue=0, 64 | optional=False, 65 | ) 66 | ) 67 | 68 | 69 | 70 | def processAlgorithm(self, parameters, context, model_feedback): 71 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 72 | # overall progress through the model 73 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 74 | results = {} 75 | outputs = {} 76 | 77 | # Convert enumerator to actual value 78 | valor_zona_humida = self.vzh_values[ 79 | self.parameterAsEnum( 80 | parameters, 81 | self.VALOR_ZONA_HUMIDA, 82 | context 83 | ) 84 | ] 85 | 86 | # Refactor fields 87 | alg_params = { 88 | 'FIELDS_MAPPING': [{ 89 | 'expression': 'now()', 90 | 'length': -1, 91 | 'name': 'inicio_objeto', 92 | 'precision': -1, 93 | 'type': 14 94 | 95 | },{ 96 | 'expression': valor_zona_humida, 97 | 'length': 255, 98 | 'name': 'valor_zona_humida', 99 | 'precision': -1, 100 | 'type': 10 101 | },{ 102 | 'expression': f"\'{parameters['MARE']}\'", 103 | 'length': 255, 104 | 'name': 'mare', 105 | 'precision': -1, 106 | 'type': 1 107 | }], 108 | 'INPUT': parameters['INPUT'], 109 | 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT 110 | } 111 | outputs['RefactorFields'] = processing.run('qgis:refactorfields', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 112 | 113 | feedback.setCurrentStep(1) 114 | if feedback.isCanceled(): 115 | return {} 116 | 117 | alg_params = { 118 | 'ADDFIELDS': False, 119 | 'APPEND': True, 120 | 'A_SRS': None, 121 | 'CLIP': False, 122 | 'DATABASE': parameters[self.LIGACAO_RECART], 123 | 'DIM': 1, 124 | 'GEOCOLUMN': 'geometria', 125 | 'GT': '', 126 | 'GTYPE': 0, 127 | 'INDEX': False, 128 | 'INPUT': outputs['RefactorFields']['OUTPUT'], 129 | 'LAUNDER': False, 130 | 'OPTIONS': '', 131 | 'OVERWRITE': False, 132 | 'PK': '', 133 | 'PRECISION': True, 134 | 'PRIMARY_KEY': 'identificador', 135 | 'PROMOTETOMULTI': False, 136 | 'SCHEMA': 'public', 137 | 'SEGMENTIZE': '', 138 | 'SHAPE_ENCODING': '', 139 | 'SIMPLIFY': '', 140 | 'SKIPFAILURES': False, 141 | 'SPAT': None, 142 | 'S_SRS': None, 143 | 'TABLE': 'zona_humida', 144 | 'T_SRS': None, 145 | 'WHERE': '' 146 | } 147 | outputs['ExportToPostgresqlAvailableConnections'] = processing.run('gdal:importvectorintopostgisdatabaseavailableconnections', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 148 | return results 149 | 150 | def name(self): 151 | return 'exportar_zona_humida' 152 | 153 | def displayName(self): 154 | return '10. Exportar Zona Húmida' 155 | 156 | def group(self): 157 | return '04 - Hidrografia' 158 | 159 | def groupId(self): 160 | return '04Hidrografia' 161 | 162 | def createInstance(self): 163 | return ExportarZonaHumida() 164 | 165 | def tr(self, string): 166 | """ 167 | Returns a translatable string with the self.tr() function. 168 | """ 169 | return QCoreApplication.translate('Processing', string) 170 | 171 | def shortHelpString(self): 172 | return self.tr("Exporta elementos do tipo Zona Humida para a base " \ 173 | "de dados RECART usando uma ligação PostgreSQL/PostGIS " \ 174 | "já configurada.\n\n" \ 175 | "A camada vectorial de input deve ser do tipo polígono 3D." 176 | ) -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider/utils.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QSettings 2 | from json import load 3 | import os 4 | 5 | def get_lista_codigos(nome_lista_codigos): 6 | listas_codigos_path = os.path.join(os.path.dirname( __file__ ) 7 | , 'extras' 8 | , 'listas_codigos.json') 9 | with open(listas_codigos_path) as f: 10 | data = load(f) 11 | 12 | dict = data[nome_lista_codigos] 13 | 14 | return list(dict.keys()), list(dict.values()) 15 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SrNetoChan/qgis2CartTop/bb665fc2b78983deec46e4a5e8577d0b32677168/qgis2CartTop/processing_provider_validacao/__init__.py -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_curso_agua_eixo.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class Consolidar_curso_agua_eixo(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente (CUIDADO!!)' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'consolidar_curso_agua_eixo.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': 'DROP TABLE IF EXISTS backup.curso_de_agua_eixo_bk;' 62 | } 63 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 64 | 65 | 66 | # PostgreSQL execute SQL 67 | alg_params = { 68 | 'DATABASE': ligacao_recart, 69 | 'SQL': sql_command 70 | } 71 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 72 | 73 | feedback.setCurrentStep(1) 74 | if feedback.isCanceled(): 75 | return {} 76 | 77 | return results 78 | 79 | def name(self): 80 | return 'consolidar_curso_agua_eixo' 81 | 82 | def displayName(self): 83 | return 'Consolidar curso de água - eixo' 84 | 85 | def group(self): 86 | return '04 - Hidrografia' 87 | 88 | def groupId(self): 89 | return '04hidrografia' 90 | 91 | def createInstance(self): 92 | return Consolidar_curso_agua_eixo() 93 | 94 | def tr(self, string): 95 | """ 96 | Returns a translatable string with the self.tr() function. 97 | """ 98 | return QCoreApplication.translate('Processing', string) 99 | 100 | def shortHelpString(self): 101 | return self.tr( 102 | "

Agrega todas as linestrings adjacentes (em Z, Y e Z) com atributos comuns

" 103 | "

ATENÇÃO: Esta ferramenta altera directamente a tabela curso_de_agua_eixo, sendo criado um backup no schema backups

" 104 | "

CUIDADO!: Se a opção Substituir backup existente for usada, não existe forma de recuperar os dados originais!

" 105 | ) 106 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_curso_agua_eixo.sql: -------------------------------------------------------------------------------- 1 | /*-- Consolidar linestrings da tabela curso de água eixo sempre que adjaentes 2 | (em X, Y e Z) e os seus attributos iguais. */ 3 | 4 | /* Guardar camadas originais em backup */ 5 | CREATE SCHEMA IF NOT EXISTS backup; 6 | 7 | CREATE TABLE backup.curso_de_agua_eixo_bk (like public.curso_de_agua_eixo); 8 | INSERT INTO backup.curso_de_agua_eixo_bk 9 | SELECT * FROM public.curso_de_agua_eixo; 10 | 11 | BEGIN; 12 | 13 | /* Unir todas as linhas com atributos iguais, guardando em arrays as ligações a outras 14 | tabelas*/ 15 | CREATE SCHEMA IF NOT EXISTS temp; 16 | CREATE TABLE temp.curso_de_agua_eixo_temp (like public.curso_de_agua_eixo INCLUDING DEFAULTS); 17 | 18 | INSERT INTO temp.curso_de_agua_eixo_temp ( 19 | inicio_objeto, 20 | nome, 21 | comprimento, 22 | delimitacao_conhecida, 23 | ficticio, 24 | largura, 25 | id_hidrografico, 26 | id_curso_de_agua_area, 27 | ordem_hidrologica, 28 | origem_natural, 29 | valor_curso_de_agua, 30 | valor_persistencia_hidrologica, 31 | valor_posicao_vertical, 32 | geometria) 33 | WITH multilines AS ( 34 | SELECT 35 | nome, 36 | comprimento, 37 | delimitacao_conhecida, 38 | ficticio, 39 | largura, 40 | id_hidrografico, 41 | id_curso_de_agua_area, 42 | ordem_hidrologica, 43 | origem_natural, 44 | valor_curso_de_agua, 45 | valor_persistencia_hidrologica, 46 | valor_posicao_vertical, 47 | ST_COLLECT(geometria) AS geometria 48 | FROM public.curso_de_agua_eixo cae 49 | GROUP BY 50 | nome, 51 | comprimento, 52 | delimitacao_conhecida, 53 | ficticio, 54 | largura, 55 | id_hidrografico, 56 | id_curso_de_agua_area, 57 | ordem_hidrologica, 58 | origem_natural, 59 | valor_curso_de_agua, 60 | valor_persistencia_hidrologica, 61 | valor_posicao_vertical 62 | ) 63 | SELECT 64 | now(), 65 | nome, 66 | comprimento, 67 | delimitacao_conhecida, 68 | ficticio, 69 | largura, 70 | id_hidrografico, 71 | id_curso_de_agua_area, 72 | ordem_hidrologica, 73 | origem_natural, 74 | valor_curso_de_agua, 75 | valor_persistencia_hidrologica, 76 | valor_posicao_vertical, 77 | (ST_DUMP(st_linemerge(geometria))).geom AS geometria 78 | FROM multilines; 79 | 80 | CREATE INDEX ON temp.curso_de_agua_eixo_temp (identificador); 81 | CREATE INDEX ON temp.curso_de_agua_eixo_temp USING gist(geometria); 82 | 83 | /*-- Reunir pontos de intersecção entre linhas para cortar entroncamentos e cruzamentos 84 | ao mesmo nível */ 85 | 86 | DROP TABLE IF EXISTS temp.cutting_temp; 87 | 88 | CREATE TABLE temp.cutting_temp as 89 | SELECT 90 | (st_dump(st_collect(st_endpoint(geometria),st_startpoint(geometria)))).geom AS geometria 91 | FROM temp.curso_de_agua_eixo_temp 92 | UNION ALL 93 | SELECT (st_dump(st_intersection(caet1.geometria, caet2.geometria))).geom AS geometria 94 | FROM temp.curso_de_agua_eixo_temp AS caet1 95 | JOIN temp.curso_de_agua_eixo_temp AS caet2 96 | ON (caet1.identificador > caet2.identificador) AND st_crosses(caet1.geometria,caet2.geometria) AND caet1.valor_posicao_vertical = caet2.valor_posicao_vertical; 97 | 98 | CREATE INDEX ON temp.cutting_temp USING GIST(geometria); 99 | 100 | /* cortar linhas previamente unidas com os pontos de corte */ 101 | 102 | CREATE TABLE temp.curso_de_agua_eixo_cortados (like temp.curso_de_agua_eixo_temp INCLUDING DEFAULTS); 103 | 104 | INSERT INTO temp.curso_de_agua_eixo_cortados ( 105 | inicio_objeto, 106 | nome, 107 | comprimento, 108 | delimitacao_conhecida, 109 | ficticio, 110 | largura, 111 | id_hidrografico, 112 | id_curso_de_agua_area, 113 | ordem_hidrologica, 114 | origem_natural, 115 | valor_curso_de_agua, 116 | valor_persistencia_hidrologica, 117 | valor_posicao_vertical, 118 | geometria 119 | ) 120 | WITH intersection_points AS ( 121 | SELECT identificador, st_collect(ct.geometria) AS geometria 122 | FROM temp.curso_de_agua_eixo_temp caet 123 | JOIN temp.cutting_temp ct ON st_intersects(caet.geometria, ct.geometria) 124 | GROUP BY identificador 125 | ) 126 | SELECT 127 | inicio_objeto, 128 | nome, 129 | comprimento, 130 | delimitacao_conhecida, 131 | ficticio, 132 | largura, 133 | id_hidrografico, 134 | id_curso_de_agua_area, 135 | ordem_hidrologica, 136 | origem_natural, 137 | valor_curso_de_agua, 138 | valor_persistencia_hidrologica, 139 | valor_posicao_vertical, 140 | (st_dump(st_split(caet.geometria, sp.geometria))).geom AS geometria 141 | FROM temp.curso_de_agua_eixo_temp caet JOIN intersection_points AS sp ON caet.identificador = sp.identificador; 142 | 143 | /* Apagar todos os elementos da tabela original e substituir por novos já unidos e 144 | e cortados nas junções com 3 ou mais linhas */ 145 | 146 | TRUNCATE TABLE public.curso_de_agua_eixo CASCADE; 147 | 148 | INSERT INTO public.curso_de_agua_eixo ( 149 | inicio_objeto, 150 | nome, 151 | comprimento, 152 | delimitacao_conhecida, 153 | ficticio, 154 | largura, 155 | id_hidrografico, 156 | id_curso_de_agua_area, 157 | ordem_hidrologica, 158 | origem_natural, 159 | valor_curso_de_agua, 160 | valor_persistencia_hidrologica, 161 | valor_posicao_vertical, 162 | geometria) 163 | SELECT 164 | inicio_objeto, 165 | nome, 166 | comprimento, 167 | delimitacao_conhecida, 168 | ficticio, 169 | largura, 170 | id_hidrografico, 171 | id_curso_de_agua_area, 172 | ordem_hidrologica, 173 | origem_natural, 174 | valor_curso_de_agua, 175 | valor_persistencia_hidrologica, 176 | valor_posicao_vertical, 177 | geometria 178 | FROM temp.curso_de_agua_eixo_cortados; 179 | 180 | DROP SCHEMA IF EXISTS temp CASCADE; 181 | 182 | END; -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_curvas_de_nivel.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class Consolidar_curvas_de_nivel(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'consolidar_curvas_de_nivel.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': 'DROP TABLE IF EXISTS backup.curva_de_nivel_bk;' 62 | } 63 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 64 | 65 | 66 | # PostgreSQL execute SQL 67 | alg_params = { 68 | 'DATABASE': ligacao_recart, 69 | 'SQL': sql_command 70 | } 71 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 72 | 73 | feedback.setCurrentStep(1) 74 | if feedback.isCanceled(): 75 | return {} 76 | 77 | return results 78 | 79 | def name(self): 80 | return 'consolidar_curvas_de_nivel' 81 | 82 | def displayName(self): 83 | return 'Consolidar curvas de nível' 84 | 85 | def group(self): 86 | return '01 - Altimetria' 87 | 88 | def groupId(self): 89 | return '01altimetria' 90 | 91 | def createInstance(self): 92 | return Consolidar_curvas_de_nivel() 93 | 94 | def tr(self, string): 95 | """ 96 | Returns a translatable string with the self.tr() function. 97 | """ 98 | return QCoreApplication.translate('Processing', string) 99 | 100 | def shortHelpString(self): 101 | return self.tr( 102 | "Agrega todas as linestrings adjacentes (em Z, Y e Z) com atributos comuns\n\n" 103 | "ATENÇÃO: Altera directamente a tabela curva_de_nivel<\b>" 104 | ) 105 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_curvas_de_nivel.sql: -------------------------------------------------------------------------------- 1 | /*-- Consolidar linestrings da tabela curvas de nível sempre adjaentes 2 | (em X, Y e Z) e os seus attributos iguais.*/ 3 | 4 | CREATE SCHEMA IF NOT EXISTS backup; 5 | CREATE TABLE backup.curva_de_nivel_bk (like public.curva_de_nivel); 6 | INSERT INTO backup.curva_de_nivel_bk 7 | SELECT * FROM public.curva_de_nivel; 8 | 9 | BEGIN; 10 | 11 | CREATE SCHEMA IF NOT EXISTS temp ; 12 | CREATE TABLE temp.curva_de_nivel_temp (like public.curva_de_nivel INCLUDING DEFAULTS); 13 | 14 | INSERT INTO temp.curva_de_nivel_temp ( 15 | inicio_objeto, 16 | valor_tipo_curva, 17 | geometria) 18 | WITH collect_lines AS ( 19 | SELECT 20 | valor_tipo_curva, 21 | ST_COLLECT(geometria) AS geometria 22 | FROM public.curva_de_nivel cdn 23 | GROUP BY 24 | valor_tipo_curva 25 | ) 26 | SELECT 27 | now(), 28 | valor_tipo_curva, 29 | (ST_DUMP(st_linemerge(geometria))).geom AS geometria 30 | FROM collect_lines; 31 | 32 | TRUNCATE TABLE public.curva_de_nivel; 33 | 34 | INSERT INTO public.curva_de_nivel ( 35 | inicio_objeto, 36 | valor_tipo_curva, 37 | geometria) 38 | SELECT 39 | inicio_objeto, 40 | valor_tipo_curva, 41 | geometria 42 | FROM temp.curva_de_nivel_temp cdnt; 43 | 44 | DROP TABLE IF EXISTS temp.curva_de_nivel_temp; 45 | 46 | END; -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_fronteira_terra_agua.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class Consolidar_fronteira_terra_agua(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'consolidar_fronteira_terra_agua.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': 'DROP TABLE IF EXISTS backup.fronteira_terra_agua_bk;' 62 | } 63 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 64 | 65 | 66 | # PostgreSQL execute SQL 67 | alg_params = { 68 | 'DATABASE': ligacao_recart, 69 | 'SQL': sql_command 70 | } 71 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 72 | 73 | feedback.setCurrentStep(1) 74 | if feedback.isCanceled(): 75 | return {} 76 | 77 | return results 78 | 79 | def name(self): 80 | return 'consolidar_fronteira_terra_agua' 81 | 82 | def displayName(self): 83 | return 'Consolidar fronteira terra-água' 84 | 85 | def group(self): 86 | return '04 - Hidrografia' 87 | 88 | def groupId(self): 89 | return '04hidrografia' 90 | 91 | def createInstance(self): 92 | return Consolidar_fronteira_terra_agua() 93 | 94 | def tr(self, string): 95 | """ 96 | Returns a translatable string with the self.tr() function. 97 | """ 98 | return QCoreApplication.translate('Processing', string) 99 | 100 | def shortHelpString(self): 101 | return self.tr( 102 | "Agrega todas as linestrings adjacentes (em Z, Y e Z) com atributos comuns\n\n" 103 | "ATENÇÃO: Altera directamente a tabela fronteira_terra_agua<\b>" 104 | ) 105 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_fronteira_terra_agua.sql: -------------------------------------------------------------------------------- 1 | /*-- Consolidar linestrings da tabela fronteira terra-agua sempre adjaentes 2 | (em X, Y e Z) e os seus attributos iguais.*/ 3 | 4 | CREATE SCHEMA IF NOT EXISTS backup; 5 | CREATE TABLE backup.fronteira_terra_agua_bk (like public.fronteira_terra_agua); 6 | INSERT INTO backup.fronteira_terra_agua_bk 7 | SELECT * FROM public.fronteira_terra_agua; 8 | 9 | BEGIN; 10 | 11 | CREATE SCHEMA IF NOT EXISTS temp ; 12 | CREATE TABLE temp.fronteira_terra_agua_temp (like public.fronteira_terra_agua INCLUDING DEFAULTS); 13 | 14 | INSERT INTO temp.fronteira_terra_agua_temp ( 15 | inicio_objeto, 16 | data_fonte_dados, 17 | ilha, 18 | geometria) 19 | WITH collect_lines AS ( 20 | SELECT 21 | data_fonte_dados, 22 | ilha, 23 | ST_COLLECT(geometria) AS geometria 24 | FROM public.fronteira_terra_agua cdn 25 | GROUP BY 26 | data_fonte_dados, 27 | ilha 28 | ) 29 | SELECT 30 | now(), 31 | data_fonte_dados, 32 | ilha, 33 | (ST_DUMP(st_linemerge(geometria))).geom AS geometria 34 | FROM collect_lines; 35 | 36 | TRUNCATE TABLE public.fronteira_terra_agua; 37 | 38 | INSERT INTO public.fronteira_terra_agua ( 39 | inicio_objeto, 40 | data_fonte_dados, 41 | ilha, 42 | geometria) 43 | SELECT 44 | inicio_objeto, 45 | data_fonte_dados, 46 | ilha, 47 | geometria 48 | FROM temp.fronteira_terra_agua_temp cdnt; 49 | 50 | DROP TABLE IF EXISTS temp.fronteira_terra_agua_temp; 51 | 52 | END; -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_linha_de_quebra.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class Consolidar_quebra_de_linha(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'consolidar_linha_de_quebra.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': 'DROP TABLE IF EXISTS backup.linha_de_quebra_bk;' 62 | } 63 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 64 | 65 | 66 | # PostgreSQL execute SQL 67 | alg_params = { 68 | 'DATABASE': ligacao_recart, 69 | 'SQL': sql_command 70 | } 71 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 72 | 73 | feedback.setCurrentStep(1) 74 | if feedback.isCanceled(): 75 | return {} 76 | 77 | return results 78 | 79 | def name(self): 80 | return 'consolidar_quebra_de_linha' 81 | 82 | def displayName(self): 83 | return 'Consolidar linhas de quebra' 84 | 85 | def group(self): 86 | return '01 - Altimetria' 87 | 88 | def groupId(self): 89 | return '01altimetria' 90 | 91 | def createInstance(self): 92 | return Consolidar_quebra_de_linha() 93 | 94 | def tr(self, string): 95 | """ 96 | Returns a translatable string with the self.tr() function. 97 | """ 98 | return QCoreApplication.translate('Processing', string) 99 | 100 | def shortHelpString(self): 101 | return self.tr( 102 | "Agrega todas as linestrings adjacentes (em Z, Y e Z) com atributos comuns\n\n" 103 | "ATENÇÃO: Altera directamente a tabela linha_de_quebra<\b>" 104 | ) 105 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_linha_de_quebra.sql: -------------------------------------------------------------------------------- 1 | /*-- Consolidar linestrings da tabela linha de quebra sempre adjaentes 2 | (em X, Y e Z) e os seus attributos iguais.*/ 3 | 4 | CREATE SCHEMA IF NOT EXISTS backup; 5 | CREATE TABLE backup.linha_de_quebra_bk (like public.linha_de_quebra); 6 | INSERT INTO backup.linha_de_quebra_bk 7 | SELECT * FROM public.linha_de_quebra; 8 | 9 | BEGIN; 10 | 11 | CREATE SCHEMA IF NOT EXISTS temp ; 12 | CREATE TABLE temp.linha_de_quebra_temp (like public.linha_de_quebra INCLUDING DEFAULTS); 13 | 14 | INSERT INTO temp.linha_de_quebra_temp ( 15 | inicio_objeto, 16 | valor_classifica, 17 | valor_natureza_linha, 18 | artificial, 19 | geometria) 20 | WITH collect_lines AS ( 21 | SELECT 22 | valor_classifica, 23 | valor_natureza_linha, 24 | artificial, 25 | ST_COLLECT(geometria) AS geometria 26 | FROM public.linha_de_quebra cdn 27 | GROUP BY 28 | valor_classifica, 29 | valor_natureza_linha, 30 | artificial 31 | ) 32 | SELECT 33 | now(), 34 | valor_classifica, 35 | valor_natureza_linha, 36 | artificial, 37 | (ST_DUMP(st_linemerge(geometria))).geom AS geometria 38 | FROM collect_lines; 39 | 40 | TRUNCATE TABLE public.linha_de_quebra; 41 | 42 | INSERT INTO public.linha_de_quebra ( 43 | inicio_objeto, 44 | valor_classifica, 45 | valor_natureza_linha, 46 | artificial, 47 | geometria) 48 | SELECT 49 | inicio_objeto, 50 | valor_classifica, 51 | valor_natureza_linha, 52 | artificial, 53 | geometria 54 | FROM temp.linha_de_quebra_temp cdnt; 55 | 56 | DROP TABLE IF EXISTS temp.linha_de_quebra_temp; 57 | 58 | END; -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_seg_via_rodov.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class Consolidar_seg_via_rodov(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente (CUIDADO!!)' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'consolidar_seg_via_rodov.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': ('DROP TABLE IF EXISTS backup.seg_via_rodov_bk;' 62 | 'DROP TABLE IF EXISTS backup.lig_valor_tipo_circulacao_seg_via_rodov_bk;' 63 | 'DROP TABLE IF EXISTS backup.lig_segviarodov_viarodov_bk;' 64 | 'DROP TABLE IF EXISTS backup.lig_segviarodov_viarodovlimite_bk;') 65 | } 66 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 67 | 68 | 69 | # PostgreSQL execute SQL 70 | alg_params = { 71 | 'DATABASE': ligacao_recart, 72 | 'SQL': sql_command 73 | } 74 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 75 | 76 | feedback.setCurrentStep(1) 77 | if feedback.isCanceled(): 78 | return {} 79 | 80 | return results 81 | 82 | def name(self): 83 | return 'consolidar_seg_via_rodov' 84 | 85 | def displayName(self): 86 | return 'Consolidar Segmento de via rodoviária' 87 | 88 | def group(self): 89 | return '05 - Transportes' 90 | 91 | def groupId(self): 92 | return '05transportes' 93 | 94 | def createInstance(self): 95 | return Consolidar_seg_via_rodov() 96 | 97 | def tr(self, string): 98 | """ 99 | Returns a translatable string with the self.tr() function. 100 | """ 101 | return QCoreApplication.translate('Processing', string) 102 | 103 | def shortHelpString(self): 104 | return self.tr( 105 | "

Agrega todas as linestrings adjacentes (em Z, Y e Z) com atributos comuns

" 106 | "

ATENÇÃO: Esta ferramenta altera directamente as tabelas seg_via_rodov, lig_valor_tipo_circulacao_seg_via_rodov e lig_segviarodov_viarodov sendo criado um backup no schema backups

" 107 | "

CUIDADO!: Se a opção Substituir backup existente for usada, não existe forma de recuperar os dados originais!

" 108 | ) 109 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_via_rodov_limite.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class Consolidar_via_rodov_limite(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente (CUIDADO!!)' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'consolidar_via_rodov_limite.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': ('DROP TABLE IF EXISTS backup.via_rodov_limite_bk;' 62 | 'DROP TABLE IF EXISTS backup.lig_segviarodov_viarodovlimite_bk;') 63 | } 64 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 65 | 66 | 67 | # PostgreSQL execute SQL 68 | alg_params = { 69 | 'DATABASE': ligacao_recart, 70 | 'SQL': sql_command 71 | } 72 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 73 | 74 | feedback.setCurrentStep(1) 75 | if feedback.isCanceled(): 76 | return {} 77 | 78 | return results 79 | 80 | def name(self): 81 | return 'consolidar_via_rodov_limite' 82 | 83 | def displayName(self): 84 | return 'Consolidar limites de via rodoviária' 85 | 86 | def group(self): 87 | return '05 - Transportes' 88 | 89 | def groupId(self): 90 | return '05transportes' 91 | 92 | def createInstance(self): 93 | return Consolidar_via_rodov_limite() 94 | 95 | def tr(self, string): 96 | """ 97 | Returns a translatable string with the self.tr() function. 98 | """ 99 | return QCoreApplication.translate('Processing', string) 100 | 101 | def shortHelpString(self): 102 | return self.tr( 103 | "

Agrega todas as linestrings adjacentes (em Z, Y e Z) com atributos comuns

" 104 | "

ATENÇÃO: Esta ferramenta altera directamente as tabelas via_rodov_limite e lig_segviarodov_viarodovlimite sendo criado um backup no schema backups

" 105 | "

CUIDADO!: Se a opção Substituir backup existente for usada, não existe forma de recuperar os dados originais!

" 106 | ) 107 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/consolidar_via_rodov_limite.sql: -------------------------------------------------------------------------------- 1 | /*-- Consolidar linestrings da tabela limites de via rodoviaria sempre que adjaentes 2 | (em X, Y e Z) e os seus attributos iguais. Por existirem atributos dependentes 3 | de ligações com outras tabelas, também essas ligações têm de ser acauteladas*/ 4 | 5 | 6 | /* Guardar camadas originais em backup */ 7 | CREATE SCHEMA IF NOT EXISTS backup; 8 | 9 | CREATE TABLE backup.via_rodov_limite_bk (like public.via_rodov_limite); 10 | INSERT INTO backup.via_rodov_limite_bk 11 | SELECT * FROM public.via_rodov_limite; 12 | 13 | CREATE TABLE backup.lig_segviarodov_viarodovlimite_bk (like public.lig_segviarodov_viarodovlimite); 14 | INSERT INTO backup.lig_segviarodov_viarodovlimite_bk 15 | SELECT * FROM public.lig_segviarodov_viarodovlimite; 16 | 17 | 18 | /* Unir todas as linhas com atributos iguais, guardando em arrays as ligações a outras 19 | tabelas*/ 20 | CREATE SCHEMA IF NOT EXISTS temp ; 21 | CREATE TABLE temp.via_rodov_limite_temp (like public.via_rodov_limite INCLUDING DEFAULTS); 22 | 23 | ALTER TABLE temp.via_rodov_limite_temp 24 | ADD COLUMN seg_via_rodov_agg uuid[]; 25 | 26 | INSERT INTO temp.via_rodov_limite_temp ( 27 | inicio_objeto, 28 | valor_tipo_limite, 29 | geometria, 30 | seg_via_rodov_agg) 31 | WITH via_rodov_agg AS 32 | (SELECT lsv.via_rodov_limite_id , array_agg(DISTINCT lsv.seg_via_rodov_id) AS seg_via_rodov_agg 33 | FROM public.lig_segviarodov_viarodovlimite lsv 34 | GROUP BY lsv.via_rodov_limite_id) 35 | , multilines AS ( 36 | SELECT 37 | valor_tipo_limite, 38 | st_collect(vrl.geometria) AS geometria, 39 | seg_via_rodov_agg 40 | FROM public.via_rodov_limite vrl 41 | LEFT JOIN via_rodov_agg vra ON (vra.via_rodov_limite_id = vrl.identificador) 42 | GROUP BY 43 | valor_tipo_limite, 44 | seg_via_rodov_agg 45 | ) 46 | SELECT 47 | now(), 48 | valor_tipo_limite, 49 | (ST_DUMP(st_linemerge(geometria))).geom AS geometria, 50 | seg_via_rodov_agg 51 | FROM multilines; 52 | 53 | CREATE INDEX ON temp.via_rodov_limite_temp (identificador); 54 | CREATE INDEX ON temp.via_rodov_limite_temp USING gist(geometria); 55 | 56 | /*-- Reunir pontos de intersecção entre linhas para cortar entroncamentos e cruzamentos 57 | ao mesmo nível */ 58 | 59 | DROP TABLE IF EXISTS temp.cutting_temp; 60 | 61 | CREATE TABLE temp.cutting_temp as 62 | SELECT 63 | (st_dump(st_collect(st_endpoint(geometria),st_startpoint(geometria)))).geom AS geometria 64 | FROM temp.via_rodov_limite_temp; 65 | 66 | CREATE INDEX ON temp.cutting_temp USING GIST(geometria); 67 | 68 | /* cortar linhas previamente unidas com os pontos de corte */ 69 | 70 | CREATE TABLE temp.via_rodov_limite_cortados (like temp.via_rodov_limite_temp INCLUDING DEFAULTS); 71 | 72 | INSERT INTO temp.via_rodov_limite_cortados ( 73 | inicio_objeto, 74 | valor_tipo_limite, 75 | geometria, 76 | seg_via_rodov_agg 77 | ) 78 | WITH intersection_points AS ( 79 | SELECT identificador, st_collect(ct.geometria) AS geometria 80 | FROM temp.via_rodov_limite_temp vrlt 81 | JOIN temp.cutting_temp ct ON st_intersects(vrlt.geometria, ct.geometria) 82 | GROUP BY identificador 83 | ) 84 | SELECT 85 | inicio_objeto, 86 | valor_tipo_limite, 87 | (st_dump(st_split(vrlt.geometria, sp.geometria))).geom AS geometria, 88 | seg_via_rodov_agg 89 | FROM temp.via_rodov_limite_temp vrlt JOIN intersection_points AS sp ON vrlt.identificador = sp.identificador; 90 | 91 | /* Apagar todos os elementos da tabela original e substituir por novos já unidos e 92 | e cortados nas junções com 3 ou mais linhas */ 93 | 94 | TRUNCATE TABLE public.via_rodov_limite CASCADE; 95 | 96 | INSERT INTO public.via_rodov_limite ( 97 | identificador, 98 | inicio_objeto, 99 | valor_tipo_limite, 100 | geometria) 101 | SELECT 102 | identificador, 103 | inicio_objeto, 104 | valor_tipo_limite, 105 | geometria 106 | FROM temp.via_rodov_limite_cortados; 107 | 108 | /* Repor as ligações com as novas linhas */ 109 | 110 | INSERT INTO public.lig_segviarodov_viarodovlimite (via_rodov_limite_id, seg_via_rodov_id) 111 | SELECT identificador AS via_rodov_limite_id, UNNEST(seg_via_rodov_agg) AS seg_via_rodov_id 112 | FROM temp.via_rodov_limite_cortados; 113 | 114 | DROP SCHEMA IF EXISTS temp CASCADE; -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/homogenizar_z_aguas_lenticas.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import QCoreApplication 2 | from qgis.core import (QgsProcessing, 3 | QgsProcessingAlgorithm, 4 | QgsProcessingMultiStepFeedback, 5 | QgsProperty, 6 | QgsProcessingParameterBoolean, 7 | QgsProcessingParameterProviderConnection) 8 | import processing, os 9 | 10 | 11 | class homogenizar_z_aguas_lenticas(QgsProcessingAlgorithm): 12 | 13 | # Constants used to refer to parameters and outputs. They will be 14 | # used when calling the algorithm from another algorithm, or when 15 | # calling from the QGIS console. 16 | 17 | LIGACAO_RECART = 'LIGACAO_RECART' 18 | SUBSTITUIR_BACKUP = 'SUBSTITUIR_BACKUP' 19 | 20 | def initAlgorithm(self, config=None): 21 | self.addParameter( 22 | QgsProcessingParameterProviderConnection( 23 | self.LIGACAO_RECART, 24 | 'Ligação PostgreSQL', 25 | 'postgres', 26 | defaultValue=None 27 | ) 28 | ) 29 | 30 | self.addParameter( 31 | QgsProcessingParameterBoolean( 32 | self.SUBSTITUIR_BACKUP, 33 | 'Substituir backup existente' 34 | ) 35 | ) 36 | 37 | 38 | def processAlgorithm(self, parameters, context, model_feedback): 39 | # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the 40 | # overall progress through the model 41 | feedback = QgsProcessingMultiStepFeedback(2, model_feedback) 42 | results = {} 43 | outputs = {} 44 | 45 | ligacao_recart = parameters[self.LIGACAO_RECART] 46 | substituir_backup = parameters[self.SUBSTITUIR_BACKUP] 47 | 48 | script_path = os.path.dirname(os.path.realpath(__file__)) 49 | sql_path = os.path.join(script_path, 'homogenizar_z_aguas_lenticas.sql') 50 | 51 | with open(sql_path) as f: 52 | base_sql = f.read() 53 | 54 | sql_command = base_sql 55 | 56 | # Delete backup table 57 | if substituir_backup: 58 | # PostgreSQL execute SQL 59 | alg_params = { 60 | 'DATABASE': ligacao_recart, 61 | 'SQL': 'DROP TABLE IF EXISTS backup.agua_lentica_bk;' 62 | } 63 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 64 | 65 | 66 | # PostgreSQL execute SQL 67 | alg_params = { 68 | 'DATABASE': ligacao_recart, 69 | 'SQL': sql_command 70 | } 71 | outputs['PostgresqlExecuteSql'] = processing.run('qgis:postgisexecutesql', alg_params, context=context, feedback=feedback, is_child_algorithm=True) 72 | 73 | feedback.setCurrentStep(1) 74 | if feedback.isCanceled(): 75 | return {} 76 | 77 | return results 78 | 79 | def name(self): 80 | return 'homogenizar_z_aguas_lenticas' 81 | 82 | def displayName(self): 83 | return 'Homogenizar_z_aguas_lenticas' 84 | 85 | def group(self): 86 | return '04 - Hidrografia' 87 | 88 | def groupId(self): 89 | return '04hidrografia' 90 | 91 | def createInstance(self): 92 | return homogenizar_z_aguas_lenticas() 93 | 94 | def tr(self, string): 95 | """ 96 | Returns a translatable string with the self.tr() function. 97 | """ 98 | return QCoreApplication.translate('Processing', string) 99 | 100 | def shortHelpString(self): 101 | return self.tr( 102 | """

Garante um valor Z constante em todos os vértices da geometria da tabela agua_lentica. 103 | Em cada elemento, o valor de Z usado representa a moda dos valores Z de todos os seus vertices originais.<\p> 104 |

ATENÇÃO: Altera directamente a tabela agua_lentica<\b><\p> 105 |

CUIDADO!: Se a opção Substituir backup existente for usada, não existe forma de recuperar os dados originais!<\p>""" 106 | ) 107 | -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/homogenizar_z_aguas_lenticas.sql: -------------------------------------------------------------------------------- 1 | /*-- Homogeniza os valores de Z das geometrias da tabeka agua_lentica 2 | Todos os vertices tomam o valor do calculo da moda de todos os valores*/ 3 | 4 | CREATE SCHEMA IF NOT EXISTS backup; 5 | CREATE TABLE backup.agua_lentica_bk (like public.agua_lentica); 6 | INSERT INTO backup.agua_lentica_bk 7 | SELECT * FROM public.agua_lentica; 8 | 9 | BEGIN; 10 | 11 | WITH vertices AS ( 12 | SELECT al.identificador, st_z((st_dumppoints(al.geometria)).geom) AS z 13 | FROM agua_lentica al 14 | ), 15 | moda AS ( 16 | SELECT identificador, 17 | MODE() WITHIN GROUP (ORDER BY z) AS moda_z 18 | FROM vertices 19 | GROUP BY identificador 20 | ) 21 | UPDATE public.agua_lentica al 22 | SET geometria = st_translate(st_force3d(st_force2d(geometria)), 0, 0, moda_z) 23 | FROM moda m 24 | WHERE m.identificador = al.identificador; 25 | 26 | END; -------------------------------------------------------------------------------- /qgis2CartTop/processing_provider_validacao/provider_validacao.py: -------------------------------------------------------------------------------- 1 | import imp 2 | from qgis.core import QgsProcessingProvider 3 | from qgis2CartTop.processing_provider_validacao.consolidar_seg_via_rodov import Consolidar_seg_via_rodov 4 | from .consolidar_curvas_de_nivel import Consolidar_curvas_de_nivel 5 | from .consolidar_linha_de_quebra import Consolidar_quebra_de_linha 6 | from .consolidar_fronteira_terra_agua import Consolidar_fronteira_terra_agua 7 | from .consolidar_seg_via_rodov import Consolidar_seg_via_rodov 8 | from .consolidar_via_rodov_limite import Consolidar_via_rodov_limite 9 | from .consolidar_curso_agua_eixo import Consolidar_curso_agua_eixo 10 | from .homogenizar_z_aguas_lenticas import homogenizar_z_aguas_lenticas 11 | 12 | class Provider_validacao(QgsProcessingProvider): 13 | 14 | def loadAlgorithms(self, *args, **kwargs): 15 | self.addAlgorithm(Consolidar_curvas_de_nivel()) 16 | self.addAlgorithm(Consolidar_quebra_de_linha()) 17 | self.addAlgorithm(Consolidar_fronteira_terra_agua()) 18 | self.addAlgorithm(Consolidar_seg_via_rodov()) 19 | self.addAlgorithm(Consolidar_via_rodov_limite()) 20 | self.addAlgorithm(Consolidar_curso_agua_eixo()) 21 | self.addAlgorithm(homogenizar_z_aguas_lenticas()) 22 | # add additional algorithms here 23 | # self.addAlgorithm(MyOtherAlgorithm()) 24 | 25 | def id(self, *args, **kwargs): 26 | """The ID of your plugin, used for identifying the provider. 27 | 28 | This string should be a unique, short, character only string, 29 | eg "qgis" or "gdal". This string should not be localised. 30 | """ 31 | return 'carttop_validacao' 32 | 33 | def name(self, *args, **kwargs): 34 | """The human friendly name of your plugin in Processing. 35 | 36 | This string should be as short as possible (e.g. "Lastools", not 37 | "Lastools version 1.0.1 64-bit") and localised. 38 | """ 39 | return self.tr('QGIS to CartTop (Validação\Correcção)') 40 | 41 | def icon(self): 42 | """Should return a QIcon which is used for your provider inside 43 | the Processing toolbox. 44 | """ 45 | return QgsProcessingProvider.icon(self) 46 | --------------------------------------------------------------------------------