Advertisement
3nids

Untitled

Mar 27th, 2019
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. """
  4. ***************************************************************************
  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 2 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. ***************************************************************************
  12. """
  13.  
  14. from PyQt5.QtCore import QCoreApplication
  15. from qgis.core import (QgsProcessing,
  16. QgsFeatureSink,
  17. QgsProcessingException,
  18. QgsProcessingAlgorithm,
  19. QgsProcessingParameterFeatureSource,
  20. QgsVectorLayer,
  21. QgsRasterLayer,
  22. QgsProject,
  23. QgsProcessingUtils)
  24. import processing
  25.  
  26. class ExampleProcessingAlgorithm(QgsProcessingAlgorithm):
  27.  
  28. INPUT = 'INPUT'
  29. OUTPUT = 'OUTPUT'
  30.  
  31. def tr(self, string):
  32. """
  33. Returns a translatable string with the self.tr() function.
  34. """
  35. return QCoreApplication.translate('Processing', string)
  36.  
  37. def createInstance(self):
  38. return ExampleProcessingAlgorithm()
  39.  
  40. def name(self):
  41. return 'myscript'
  42.  
  43. def displayName(self):
  44. return self.tr('My Script')
  45.  
  46. def group(self):
  47. return self.tr('Example scripts')
  48.  
  49. def groupId(self):
  50. return 'examplescripts'
  51.  
  52. def shortHelpString(self):
  53. return self.tr("Example algorithm short description")
  54.  
  55. def initAlgorithm(self, config=None):
  56. pass
  57.  
  58. def processAlgorithm(self, parameters, context, feedback):
  59. c_insee = '57533'
  60. n_couche = 'test_cadastre'
  61. EPSG_code = '2154'
  62. 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"
  63. rlayer = QgsRasterLayer(urlWithParams, 'Cadastre_'+n_couche+'_'+c_insee, 'wms')
  64. context.temporaryLayerStore().addMapLayer(rlayer)
  65. context.addLayerToLoadOnCompletion(rlayer.id(), context.LayerDetails('cadastre', context.project(), 'xxx', QgsProcessingUtils.Raster))
  66.  
  67. return {self.OUTPUT: ''}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement