opengisch / QgisModelBaker

Create QGIS projects from database schemas or Interlis models
https://opengisch.github.io/QgisModelBaker/
GNU Lesser General Public License v3.0
55 stars 17 forks source link

Order of ORDERED enums not considered in attribute forms #940

Open webrian opened 4 months ago

webrian commented 4 months ago

The order of an ORDERED enumeration is not considered by Model Baker.

A simple INTERLIS model with a ordered enumeration:

INTERLIS 2.3;

MODEL SimpleTable (de)
AT "mailto:agi@bd.so.ch"
VERSION "2024-05-02"  =

  DOMAIN

    LKoord = COORD 2460000.000 .. 2870000.000 [INTERLIS.M], 1045000.000 .. 1310000.000 [INTERLIS.M] ,ROTATION 2 -> 1;

    SimpleArt = (
      ErsteArt,
      ZweiteArt,
      DritteArt,
      VierteArt,
      FuenfteArt,
      SechsteArt
    ) ORDERED;

  TOPIC SimpleTopic =

    CLASS Table =
      Anzahl : 1 .. 1000;
      Bezeichnung : MTEXT*64;
      Geometrie : MANDATORY SimpleTable.LKoord;
      Art : SimpleTable.SimpleArt;
    END Table;

  END SimpleTopic;

END SimpleTable.

This model is implemented in the (PG) database as follows:

image

The column itfcode represents the order as defined in the data model.

Creating the QGIS project with Model Baker the enum values are ordered in an alphabetical way:

Bildschirmfoto vom 2024-06-25 15-23-30_dialog

I think from a user's point of view it would be preferable if the order of the values corresponded to the data model.

See also the discussion in the INTERLIS forum: https://interlis.discourse.group/t/ordered-enumerations/175

signedav commented 4 months ago

Shouldn't the seq giving the order?

Anyway, I think this would require a QGIS change. Maybe this is something to consider https://github.com/qgis/QGIS/issues/48191

Still Model Baker should then set the sorting to the seq (or itf_code)

webrian commented 4 months ago

Currently the seq column does not correspond to the itf_code. Not sure if this is on purpose or an issue with ili2db?

signedav commented 4 months ago

Yes you are right. I have to clarify that.

gacarrillor commented 1 month ago

Shouldn't the seq giving the order?

Anyway, I think this would require a QGIS change. Maybe this is something to consider qgis/QGIS#48191

Still Model Baker should then set the sorting to the seq (or itf_code)

See https://github.com/claeis/ili2db/issues/526#event-11155599672

gacarrillor commented 1 month ago

From the ili2db docs:

seq Definiert die Reihenfolge der Aufzählelemente.

signedav commented 1 month ago

Thanks for the clarification. I asked back if it's just not working or like that on purpose. Let's see. If https://github.com/qgis/QGIS/issues/48191 will be implemented with an order-expression, MB is flexible on that anyway.