diff --git a/modelbaker/generator/generator.py b/modelbaker/generator/generator.py index 64dd60a..c4d47f6 100644 --- a/modelbaker/generator/generator.py +++ b/modelbaker/generator/generator.py @@ -233,7 +233,10 @@ def layers(self, filter_layer_list=[]): elif "ili_name" in record and record["ili_name"]: meta_attrs = self.get_meta_attrs(record["ili_name"]) for attr_record in meta_attrs: - if attr_record["attr_name"] == "dispExpression": + if attr_record["attr_name"] in [ + "dispExpression", + "qgis.modelbaker.dispExpression", + ]: display_expression = attr_record["attr_value"] coord_decimals = ( diff --git a/modelbaker/utils/qgis_utils.py b/modelbaker/utils/qgis_utils.py index 6a60990..9e473a3 100644 --- a/modelbaker/utils/qgis_utils.py +++ b/modelbaker/utils/qgis_utils.py @@ -159,6 +159,8 @@ def get_oid_settings(self): tree_layers = root.findLayers() for tree_layer in tree_layers: # get t_ili_tid field OID field + if tree_layer.layer().type() != QgsMapLayer.VectorLayer: + continue fields = tree_layer.layer().fields() field_idx = fields.lookupField("t_ili_tid") if field_idx < 0: diff --git a/tests/test_projectgen.py b/tests/test_projectgen.py index 30b1f7b..961fb87 100644 --- a/tests/test_projectgen.py +++ b/tests/test_projectgen.py @@ -1437,7 +1437,7 @@ def test_meta_attr_postgis(self): importer = iliimporter.Importer() importer.tool = DbIliMode.ili2pg importer.configuration = iliimporter_config(importer.tool, "ilimodels") - importer.configuration.ilimodels = "ExceptionalLoadsRoute_LV95_V1" + importer.configuration.ilimodels = "ExceptionalLoadsRoute_LV03_V1" importer.configuration.dbschema = "ciaf_ladm_{:%Y%m%d%H%M%S%f}".format( datetime.datetime.now() ) @@ -1482,7 +1482,7 @@ def test_meta_attr_geopackage(self): importer = iliimporter.Importer() importer.tool = DbIliMode.ili2gpkg importer.configuration = iliimporter_config(importer.tool, "ilimodels") - importer.configuration.ilimodels = "ExceptionalLoadsRoute_LV95_V1" + importer.configuration.ilimodels = "ExceptionalLoadsRoute_LV03_V1" importer.configuration.dbfile = os.path.join( self.basetestpath, @@ -1531,7 +1531,7 @@ def test_meta_attr_mssql(self): importer = iliimporter.Importer() importer.tool = DbIliMode.ili2mssql importer.configuration = iliimporter_config(importer.tool, "ilimodels") - importer.configuration.ilimodels = "ExceptionalLoadsRoute_LV95_V1" + importer.configuration.ilimodels = "ExceptionalLoadsRoute_LV03_V1" importer.configuration.dbschema = "ciaf_ladm_{:%Y%m%d%H%M%S%f}".format( datetime.datetime.now() ) @@ -1620,9 +1620,7 @@ def test_meta_attr_toml_postgis(self): assert layer.layer.displayExpression() == "type" if layer.name == "route": count += 1 - assert layer.layer.displayExpression() == ( - '"t_ili_tid"' if Qgis.QGIS_VERSION_INT >= 31800 else '"t_id"' - ) + assert layer.layer.displayExpression() == "type" if layer.name == "obstacle": count += 1 assert layer.layer.displayExpression() == "type" @@ -1676,9 +1674,7 @@ def test_meta_attr_toml_mssql(self): assert layer.layer.displayExpression() == "type" if layer.name == "route": count += 1 - assert layer.layer.displayExpression() == ( - '"T_Ili_Tid"' if Qgis.QGIS_VERSION_INT >= 31800 else '"T_Id"' - ) + assert layer.layer.displayExpression() == "type" if layer.name == "obstacle": count += 1 assert layer.layer.displayExpression() == "type" @@ -1834,9 +1830,7 @@ def test_meta_attr_toml_geopackage(self): assert layer.layer.displayExpression() == "type" if layer.name == "route": count += 1 - assert layer.layer.displayExpression() == ( - '"T_Ili_Tid"' if Qgis.QGIS_VERSION_INT >= 31800 else '"T_Id"' - ) + assert layer.layer.displayExpression() == "type" if layer.name == "obstacle": count += 1 assert layer.layer.displayExpression() == "type" diff --git a/tests/testdata/ilimodels/ExceptionalLoadsRoute_V1.ili b/tests/testdata/ilimodels/ExceptionalLoadsRoute_V1.ili index 1087f25..a98289a 100644 --- a/tests/testdata/ilimodels/ExceptionalLoadsRoute_V1.ili +++ b/tests/testdata/ilimodels/ExceptionalLoadsRoute_V1.ili @@ -87,6 +87,7 @@ VERSION "2017-02-08" = RestrictAxisLoad : 0 .. 1000 [Units.t]; END Obstacle; + !!@ qgis.modelbaker.dispExpression="type" CLASS Route = Identifier : MANDATORY TEXT*50; Canton : MANDATORY CHAdminCodes_V1.CHCantonCode;