Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix for Model Baker Extra Metaattributes #78

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading