SpectralProfile fields information is getting lost when vector layer is passed to a processing algorithm
Hi @Benjamin Jakimow ,
the current test that decides if a field is an actual SpectralProfile field, checks against the EditorWidgetSetup-Type:
This information seams to be missing, after the spectral library layer is passed to a processing algorithm.
Have you any idea, how to circumvent this?
Of course, the user could manually select all SpectralProfile fields as an input parameter to the algorithm, but that would be very inconvinient.
Comments (13)
-
reporter -
Please provide a code example / unit thes that reproduces this behavior. Which processing algorithm do you mean?
The editor widget type is a property of the QgsField and available at QgsFeature level as well.
-
By the way, there is nothing else we could check against if a QgsField is used for SpectraProfiles or not.
-
reporter Please provide a code example / unit thes that reproduces this behavior. Which processing algorithm do you mean?
It’s the SaveLibraryAsGeoJsonAlgorithm. I now implemented a check inside the algortithm, so you can use it to reproduce and debug:
Traceback (most recent call last): File "D:\source\QGISPlugIns\enmap-box\site-packages\typeguard\__init__.py", line 903, in wrapper retval = func(*args, **kwargs) File "D:\source\QGISPlugIns\enmap-box\enmapboxprocessing\algorithm\savelibraryasgeojsonalgorithm.py", line 66, in processAlgorithm raise Exception('DEBUG Issue #1092: profile_field_list(library) returns empty list.') Exception: DEBUG Issue #1092: profile_field_list(library) returns empty list.
-
reporter
-
reporter To be clear, this issue is not about the SaveLibraryAsGeoJsonAlgorithm as such. Every processing algorithm that want’s to process a library layer is affected.
-
The EnMAPProcessingAlgorithm fails to keep the enditor widget setup information
class TestIssue1089(EnMAPBoxTestCase): def test_memoryConversion(self): slib = TestObjects.createSpectralLibrary() QgsProject.instance().addMapLayer(slib) context = QgsProcessingContext() context.setProject(QgsProject.instance()) feedback = QgsProcessingFeedback() context.setFeedback(feedback) alg = EnMAPProcessingAlgorithm() alg.addParameterVectorLayer('memory', '') params = {'memory': slib} slib2 = alg.parameterAsVectorLayer(params, 'memory', context) for field in slib.fields(): field2 = slib2.fields().field(field.name()) self.assertEqual(field.type(), field2.type()) self.assertEqual(field.editorWidgetSetup().type(), field2.editorWidgetSetup().type())
Furthermore I don’t know if this one saves the qml as well.
# save as GeoJSON alg = 'native:savefeatures' parameters = {'INPUT': library, 'OUTPUT': filename} self.runAlg(alg, parameters, None, feedback2, context, True)
-
-
assigned issue to
-
assigned issue to
-
reporter Oh no, you are right. Our fancy handling of QGIS memory layers, to make them OGR compatible, is biting us back
-
reporter Hmm, I think it is best to not convert to OGR by default. I’ll add a “convertToOgr=False” option to the
parameterAsVectorLayer
method. -
I can fix this if you like
-
reporter No thanks, I’m already at it.
-
- changed status to resolved
resolves
#1092→ <<cset d4c88ad5c98a>>
- Log in to comment
@Benjamin Jakimow , what I also don’t like about the current solution: the EditorWidgetSetup-Type is a property of the layer. It would make mutch more sense, if it would be specified inside the vector source.