when setting speclib binary field to SpectralProfile, changes are not persistent after restart

Issue #726 on hold
Andreas Janz created an issue

Benjamin, the animated gif is to big for uploading it here. Use this link here:
https://drive.google.com/file/d/1sERRWZn3C_sVmv0FJv448IunY133fT0P/view?usp=sharing

Comments (17)

  1. Andreas Janz reporter

    even better provide some code

    Not sure if this bug is related to your API. I would guess it is rather a GUI issue.

  2. Benjamin Jakimow

    Sorry, but your issue description misses basic details to get reproduced.
    From its title only it does not become clear in which context which speclib is opened and which field is set to “SpectralProfile” and so on.

    Good and detailed issue description allow others (users, developers, search engines) to find issue based on keyword and to compare it to their own use-case. This way the issue tracker becomes a library of cases, solutions and discussions and helps to improve software like the EnMAP-Box. Just putting everything into a “video” even too large to be uploaded here contradicts this idea.

  3. Andreas Janz reporter

    it does not become clear in which context which speclib is opened 

    You are right, from the video alone, it is not clear, which file I used. It’s from the repo: enmap-box/tests/testdata/library.gpkg

    ‌

    Good and detailed issue description allow others (users, developers, search engines) to find issue based on keyword and to compare it to their own use-case. This way the issue tracker becomes a library of cases, solutions and discussions and helps to improve software like the EnMAP-Box. Just putting everything into a “video” even too large to be uploaded here contradicts this idea.

    I found it hard to put the several steps shown in the video into self-explaining words. Now that the filename of the library is clear, everything else should be perfectly clear viewing the video. But anyway, here are the instructions in written word:

    • drag&drop the library onto the gray view area
    • set AutoForm of “profiles” field to SpectralProfile
    • save current style as default style
    • close the box
    • start the box again
    • drag&drop the library onto the gray view area
    • look at the AutoForm of the “profiles“ field → not showing SpectralProfile (that is the issue)

    Hope that helps.

  4. Benjamin Jakimow

    I don’t know why the style is not loaded initially, but you can use “Restore Default” to get it.

  5. Andreas Janz reporter

    The thing is, when saving the style via QGIS, the EnMAP-Box is showing it correctly right away. E.g. for enmapbox/exampledata/library_berlin.gpkg

    1. Could it be, that the EnMAP-Box saves the default style slightly different compared to QGIS?
    2. Possible workaround: when adding a new vector layer from a given filename (layer = QgsVectorLayer(filename)), you could call layer.loadDefaultStyle() afterwards

    ‌

  6. Benjamin Jakimow

    loadDefaultStyle should be already called when creating a QgsVectorLayer with default layer options,
    same with QgsVectorLayer.saveDefaultStyle(), and the QML looks correct.

    Really strange….

  7. Benjamin Jakimow

    QGIS seems to be affected by the same behaviour and also for standard widget types, like the range widget:
    Standard loading gives me:

    I have to call Style → Restore Default to get the right range properties (and the Spectral Profile widget for field “profiles”)

    ‌

  8. Andreas Janz reporter

    loadDefaultStyle should be already called when creating a QgsVectorLayer with default layer options,

    Have you tried to call layer.loadDefasultStyle explicitely?

  9. Andreas Janz reporter

    QGIS seems to be affected by the same behaviour and also for standard widget types, like the range widget:

    Ah ok, so maybe more a QGIS Bug.

  10. Benjamin Jakimow

    It definitely is. QgsVectorLayer.saveAsDefaultStyle() writen an QML that described the edit widget type, e.g. for range as:

        <field configurationFlags="None" name="number">
          <editWidget type="range">
            <config>
              <Option type="Map">
                <Option value="false" name="AllowNull" type="bool"/>
                <Option value="256" name="Max" type="int"/>
                <Option value="1" name="Min" type="int"/>
                <Option value="4" name="Precision" type="int"/>
                <Option value="1" name="Step" type="int"/>
                <Option value="SpinBox" name="Style" type="QString"/>
              </Option>
            </config>
          </editWidget>
        </field>
    

    Otherwise the layer properties dialog generates something like:

    <field configurationFlags="None" name="number">
          <editWidget type="Range">
            <config>
              <Option type="Map">
                <Option value="false" name="AllowNull" type="bool"/>
                <Option value="256" name="Max" type="int"/>
                <Option value="1" name="Min" type="int"/>
                <Option value="4" name="Precision" type="int"/>
                <Option value="1" name="Step" type="int"/>
                <Option value="SpinBox" name="Style" type="QString"/>
              </Option>
            </config>
          </editWidget>
        </field>
    

    Note the difference: “Range” - this should be the display name only and “range”, the identifier for the widget. Somewhere the display name is taken instead of the widget id.

  11. Log in to comment