Skip to content

Commit

Permalink
Merge pull request #78 from opengisch/metaattrprefix
Browse files Browse the repository at this point in the history
Prefix for Model Baker Extra Metaattributes
  • Loading branch information
signedav authored Nov 29, 2023
2 parents 634ebce + ae3a878 commit 60f260f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
5 changes: 4 additions & 1 deletion modelbaker/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
2 changes: 2 additions & 0 deletions modelbaker/utils/qgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 6 additions & 12 deletions tests/test_projectgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/ilimodels/ExceptionalLoadsRoute_V1.ili
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 60f260f

Please sign in to comment.