Hi Valérian, It was an issue in processing code, that Nyall finally itdentified and fixed here: https://github.com/qgis/QGIS/pull/9640
Cheers, Denis On Wed, 27 Mar 2019, 10:51 Valérian Lebert, <vleb...@tactis.fr> wrote: > Nous avons complètement migré sur 3.4. > > A terme le script doit permettre à l'utilisateur de sélectionner > > - la couche des communes > - le field des noms de commune > - le field des "codes INSEE" de communes > > Par habitude, je souhaitais donc utiliser l'API processing pour packager > cela dans une interface utilisateur simple (voir PJ) pour le choix des > différentes inputs. > > Nous avons développés plusieurs outils ainsi, mais pour la première fois > nous devons charger un layer dans le processing et ce n'est pas aussi > simple que je le pensais. > > Est-ce clair? > > Valérian > > Le mer. 27 mars 2019 à 16:44, Denis Rouzaud <denis.rouz...@gmail.com> a > écrit : > >> Bonjour, >> >> Mais du coup, quel est intérêt de faire ce script sous 3.x? >> >> >> >> >> Le mer. 27 mars 2019 à 10:20, Valérian Lebert <vleb...@tactis.fr> a >> écrit : >> >>> Voici ci-joint. >>> C'est juste un script de test, mon but derrière cela étant de mettre à >>> jour un script QGIS 2.18 qui permet de charger un fond de plan cadastral à >>> partir d'une table de communes. >>> >>> Les lignes du script "cadastre_temp" entrées directement dans la console >>> QGIS donnent un résultat valide >>> >>> Merci >>> Valérian >>> >>> Le mer. 27 mars 2019 à 16:14, Denis Rouzaud <denis.rouz...@gmail.com> a >>> écrit : >>> >>>> Bonjour Valérian, >>>> >>>> Est-ce que vous pouvez me transmettre le script complet pour que je >>>> puisse regarger? >>>> (je travaille chez OpenGIS). >>>> >>>> Merci, >>>> Denis >>>> >>>> Le mer. 27 mars 2019 à 09:27, Valérian Lebert <vleb...@tactis.fr> a >>>> écrit : >>>> >>>>> Thanks Denis for your answer. >>>>> >>>>> It helps but I still have some issues with rasterLayers : >>>>> >>>>> ------ >>>>> vlayer2 = >>>>> QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', >>>>> 'vlayer2', "memory") >>>>> >>>>> 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(vlayer2) >>>>> context.temporaryLayerStore().addMapLayer(rlayer) >>>>> >>>>> context.addLayerToLoadOnCompletion(vlayer2.id(),context.LayerDetails('test2', >>>>> context.project(), 'test2')) >>>>> context.addLayerToLoadOnCompletion(rlayer.id(),context.LayerDetails('cadastre', >>>>> context.project(), 'cadastre')) >>>>> ------ >>>>> >>>>> vlayer2 is properly added to the project but i still get an error for >>>>> rlayer >>>>> >>>>> >>>>> Chargement des couches de résultat >>>>> >>>>> Les couches suivantes n'ont pas été générées >>>>> correctement.<ul><li>Cadastre_test_cadastre_57533_249deb86_fd00_4df3_af9a_8d084388ca91</li></ul>Vous >>>>> pouvez vérifier le Panel de messages du journal dans la fenêtre principale >>>>> de QGIS pour trouver plus d'informations à propos de l'exécution de >>>>> l'algorithme. >>>>> >>>>> Any idea? >>>>> >>>>> Le mer. 27 mars 2019 à 14:40, Denis Rouzaud <denis.rouz...@gmail.com> >>>>> a écrit : >>>>> >>>>>> Hi Valérian, >>>>>> >>>>>> Not 100% sure, but I think you miss >>>>>> context.temporaryLayerStore().addMapLayer(vlayer1) and up to vlayer4 >>>>>> before actually adding them to the context. >>>>>> >>>>>> Let me know if it works, >>>>>> >>>>>> Denis >>>>>> >>>>>> Le mer. 27 mars 2019 à 04:32, Valérian Lebert <vleb...@tactis.fr> a >>>>>> écrit : >>>>>> >>>>>>> Hello, >>>>>>> >>>>>>> I am trying to add a layer to project in a QgsProcessingAlgorithm. >>>>>>> >>>>>>> I run the folowing test code, just to find a way to add a layer to >>>>>>> the project. I don't want to use featureSink because at the end the >>>>>>> layer I >>>>>>> want to add is a raster layer : >>>>>>> >>>>>>> def processAlgorithm(self, parameters, context, feedback): >>>>>>> """ >>>>>>> Here is where the processing itself takes place. >>>>>>> """ >>>>>>> >>>>>>> vlayer1 = >>>>>>> QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', >>>>>>> 'vlayer1', "memory") >>>>>>> vlayer2 = >>>>>>> QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', >>>>>>> 'vlayer2', "memory") >>>>>>> vlayer3 = >>>>>>> QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', >>>>>>> 'vlayer3', "memory") >>>>>>> vlayer4 = >>>>>>> QgsVectorLayer('Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes', >>>>>>> 'vlayer4', "memory") >>>>>>> >>>>>>> >>>>>>> context.addLayerToLoadOnCompletion(vlayer1.id(),context.LayerDetails('toto', >>>>>>> QgsProject.instance(), 'test1')) >>>>>>> >>>>>>> context.addLayerToLoadOnCompletion(vlayer2.id(),context.LayerDetails('toto', >>>>>>> context.project(), 'test2')) >>>>>>> QgsProject.instance().addMapLayer(vlayer3, True) >>>>>>> context.project().addMapLayer(vlayer4, True) >>>>>>> >>>>>>> >>>>>>> return {self.OUTPUT: 'toto'} >>>>>>> >>>>>>> I read that adding a layer directly from instance() should not be >>>>>>> used in a processing algorithm. >>>>>>> However, none of the created vectorLayer is added to the legend. >>>>>>> >>>>>>> I get a warning on processing feedback with no details in message >>>>>>> log : >>>>>>> Chargement des couches de résultat >>>>>>> Les couches suivantes n'ont pas été générées >>>>>>> correctement.<ul><li>vlayer1_98306459_f1bc_4285_b8dc_660502e5cb47</li><li>vlayer2_040a7ea0_7a5f_4e02_bfd1_4ce311c60219</li></ul>Vous >>>>>>> pouvez vérifier le Panel de messages du journal dans la fenêtre >>>>>>> principale >>>>>>> de QGIS pour trouver plus d'informations à propos de l'exécution de >>>>>>> l'algorithme. >>>>>>> >>>>>>> Am i doing wrong or is there something broken in procesing API? >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> Valérian >>>>>>> _______________________________________________ >>>>>>> QGIS-Developer mailing list >>>>>>> QGIS-Developer@lists.osgeo.org >>>>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >>>>>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Denis Rouzaud >>>>>> de...@opengis.ch <de...@opengis.ch> >>>>>> +41 76 370 21 22 <+41763702122> >>>>>> [image: OPENGIS.ch Logo] <https://www.opengis.ch> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Valérian Lebert >>>>> >>>>> Directeur de projet >>>>> M : +33.7.75.10.77.51 <+33%207%2075%2010%2077%2051> >>>>> >>>>> P : +33.1.49.57.05.05 <+33%201%2049%2057%2005%2005> >>>>> E : vleb...@tactis.fr >>>>> >>>> -- >>>> >>>> Denis Rouzaud >>>> de...@opengis.ch <de...@opengis.ch> >>>> +41 76 370 21 22 >>>> >>>> >>>> >>> >>> -- >>> Valérian Lebert >>> >>> Directeur de projet >>> M : +33.7.75.10.77.51 >>> >>> P : +33.1.49.57.05.05 >>> E : vleb...@tactis.fr >>> >> >> >> -- >> Denis Rouzaud >> de...@opengis.ch <de...@opengis.ch> >> +41 76 370 21 22 <+41763702122> >> [image: OPENGIS.ch Logo] <https://www.opengis.ch> >> > > > -- > Valérian Lebert > > Directeur de projet > M : +33.7.75.10.77.51 > > P : +33.1.49.57.05.05 > E : vleb...@tactis.fr >
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer