Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- ***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************
- """
- from PyQt5.QtCore import QCoreApplication
- from qgis.core import (QgsProcessing,
- QgsFeatureSink,
- QgsProcessingException,
- QgsProcessingAlgorithm,
- QgsProcessingParameterFeatureSource,
- QgsVectorLayer,
- QgsRasterLayer,
- QgsProject,
- QgsProcessingUtils)
- import processing
- class ExampleProcessingAlgorithm(QgsProcessingAlgorithm):
- INPUT = 'INPUT'
- OUTPUT = 'OUTPUT'
- def tr(self, string):
- """
- Returns a translatable string with the self.tr() function.
- """
- return QCoreApplication.translate('Processing', string)
- def createInstance(self):
- return ExampleProcessingAlgorithm()
- def name(self):
- return 'myscript'
- def displayName(self):
- return self.tr('My Script')
- def group(self):
- return self.tr('Example scripts')
- def groupId(self):
- return 'examplescripts'
- def shortHelpString(self):
- return self.tr("Example algorithm short description")
- def initAlgorithm(self, config=None):
- pass
- def processAlgorithm(self, parameters, context, feedback):
- c_insee = '57533'
- n_couche = 'test_cadastre'
- EPSG_code = '2154'
- urlWithParams = "url=http://inspire.cadastre.gouv.fr/scpc/"+c_insee+".wms?contextualWMSLegend=0&crs=EPSG:"+EPSG_code+"&dpiMode=7&featureCount=10&format=image/png&layers=AMORCES_CAD&layers=LIEUDIT&layers=CP.CadastralParcel&layers=SUBFISCAL&layers=CLOTURE&layers=DETAIL_TOPO&layers=HYDRO&layers=VOIE_COMMUNICATION&layers=BU.Building&layers=BORNE_REPERE&styles=&styles=&styles=&styles=&styles=&styles=&styles=&styles=&styles=&styles=&maxHeight=1024&maxWidth=1280"
- rlayer = QgsRasterLayer(urlWithParams, 'Cadastre_'+n_couche+'_'+c_insee, 'wms')
- context.temporaryLayerStore().addMapLayer(rlayer)
- context.addLayerToLoadOnCompletion(rlayer.id(), context.LayerDetails('cadastre', context.project(), 'xxx', QgsProcessingUtils.Raster))
- return {self.OUTPUT: ''}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement