Skip to content

Commit

Permalink
Merge pull request #108 from QGEP/2023-03_interlis_additional_models_new
Browse files Browse the repository at this point in the history
2023 03 interlis additional models new
  • Loading branch information
ponceta committed Dec 21, 2023
2 parents 8c51066 + 110c8ef commit 3b53854
Show file tree
Hide file tree
Showing 67 changed files with 18,243 additions and 171 deletions.
135 changes: 124 additions & 11 deletions qgepqwat2ili/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

from . import config, utils
from .qgep.export import qgep_export
# 4.4.2023
from .qgepsia405.export import qgep_export as qgepsia405_export
from .qgepdss.export import qgep_export as qgepdss_export
from .qgep.import_ import qgep_import
# 5.4.2023
from .qgepsia405.import_ import qgep_import as qgepsia405_import
from .qgepdss.import_ import qgep_import as qgepdss_import

from .qgep.mapping import get_qgep_mapping
from .qgep.model_abwasser import Base as BaseAbwasser
from .qgep.model_qgep import Base as BaseQgep
Expand Down Expand Up @@ -37,11 +44,27 @@ def main(args):
"--selection",
help="if provided, limits the export to networkelements that are provided in the selection (comma separated list of ids)",
)

# TODO: this only makes sense for export
parser_qgep.add_argument(
"--labels_file",
help="if provided, includes the label positions in the export (the file should be the results of the provided `qgep:extractlabels_interlis` QGIS algorithm as geojson)",
)

#4.4.2023 / 5.4.2023 replaced with choices
#parser_qgep.add_argument(
# "--labels_orientation",
# help="parameter to adjust orientation of label text to fit other default values for north direction. If provided, turns the orientation by the given value [90, -90, 0] degree)",
#)
#parser_tpl.add_argument("model", choices=["qgep", "qwat"])
# back to argument to make it optional
#parser_qgep.add_argument("labels_orientation", choices=["90.0", "0.0","-90.0"])
parser_qgep.add_argument(
"--labels_orientation",
#choices=["90.0", "0.0","-90.0"],
#help="parameter to adjust orientation of label text to fit other default values for north direction. If provided, turns the orientation by the given value [90, -90, 0] degree)",
)

parser_qgep.add_argument(
"--recreate_schema", action="store_true", help="drops schema and reruns ili2pg importschema"
)
Expand All @@ -66,6 +89,12 @@ def main(args):
action="store_true",
help="export the model SIA405_ABWASSER_2015_LV95 (instead of default VSA_KEK_2019_LV95)",
)
# 24.3.2023
parser_qgep.add_argument(
"--export_dss",
action="store_true",
help="export the model DSS_2015_LV95 (instead of default VSA_KEK_2019_LV95)",
)

parser_qwat = subparsers.add_parser(
"qwat",
Expand Down Expand Up @@ -129,24 +158,64 @@ def main(args):
file_handler.setLevel(INFO)
file_handler.setFormatter(Formatter("%(levelname)-8s %(message)s"))
utils.various.logger.addHandler(file_handler)


# to do maybe move orientation_list to CONFIG ?
orientation_list = [0.0, 90.0, -90.0]
#if args.labels_orientation is None:
# args.labels_orientation = "0.0"
# if args.labels_orientation in orientation_list or args.labels_orientation is None :
# check if args.selection exists, if not set to "0.0"
# if args.labels_orientation:
# print ("args.labels_orientation {args.labels_orientation}")
# else:
# #set args.selection to "0.0"
# args.labels_orientation = "0.0"

#if args.labels_orientation in orientation_list :
if args.parser == "qgep":
config.PGSERVICE = args.pgservice
SCHEMA = config.ABWASSER_SCHEMA
ILI_MODEL = config.ABWASSER_ILI_MODEL
#SCHEMA = config.ABWASSER_SCHEMA
#ILI_MODEL = config.ABWASSER_ILI_MODEL
if args.export_sia405:
SCHEMA = config.ABWASSER_SIA405_SCHEMA
ILI_MODEL = config.ABWASSER_SIA405_ILI_MODEL
ILI_MODEL_NAME = config.ABWASSER_ILI_MODEL_NAME_SIA405
ILI_EXPORT_MODEL_NAME = config.ABWASSER_ILI_MODEL_NAME_SIA405
#ABWASSER_SIA405_SCHEMA = config.ABWASSER_SIA405_SCHEMA
#ABWASSER_SIA405_ILI_MODEL = config.ABWASSER_SIA405_ILI_MODEL
# 24.3.2023 added dss export
elif args.export_dss:
SCHEMA = config.ABWASSER_DSS_SCHEMA
ILI_MODEL = config.ABWASSER_SIA405_ILI_MODEL
ILI_MODEL_NAME = config.ABWASSER_DSS_ILI_MODEL
ILI_EXPORT_MODEL_NAME = None
#ABWASSER_DSS_SCHEMA = config.ABWASSER_DSS_SCHEMA
#ABWASSER_DSS_ILI_MODEL = config.ABWASSER_DSS_ILI_MODEL
else:
SCHEMA = config.ABWASSER_SCHEMA
ILI_MODEL = config.ABWASSER_ILI_MODEL
ILI_MODEL_NAME = config.ABWASSER_ILI_MODEL_NAME
ILI_EXPORT_MODEL_NAME = None

if args.direction == "export":
utils.ili2db.create_ili_schema(
SCHEMA, ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema
)
qgep_export(selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file)

#add model dependency
if args.export_sia405:
# SIA405_ABWASSER_2015_LV95
qgepsia405_export(selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation)
elif args.export_dss:
# DSS_2015_LV95 expor5t
qgepdss_export(selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation)
else:
# VSA_KEK_2019_LV95 export

#qgep_export(selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file)
# 4.4.2023 with labels_orientation
#qgep_export(selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation if args.labels_orientation else 0)
qgep_export(selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation)

utils.ili2db.export_xtf_data(
SCHEMA, ILI_MODEL_NAME, ILI_EXPORT_MODEL_NAME, args.path, make_log_path(log_path, "iliexport")
)
Expand All @@ -162,17 +231,57 @@ def main(args):
if args.selection:
print("Selection is only supported on export")
exit(1)
if args.labels_orientation:
print("Labels_orientation is only supported on export")
exit(1)
if not args.skip_validation:
try:
utils.ili2db.validate_xtf_data(args.path, make_log_path(log_path, "ilivalidate"))
except utils.various.CmdException:
print("Ilivalidator doesn't recognize input as valid ! Run with --skip_validation to ignore")
exit(1)
utils.ili2db.create_ili_schema(
SCHEMA, ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema
)
utils.ili2db.import_xtf_data(SCHEMA, args.path, make_log_path(log_path, "iliimport"))
qgep_import()

#add model dependency, as in __init_.py
impmodel = "nothing"
#impmodel = utils.ili2db.get_xtf_model(args.path)
impmodel = utils.ili2db.get_xtf_model2(args.path)

if impmodel == "VSA_KEK_2019_LV95":
SCHEMA = config.ABWASSER_SCHEMA
ILI_MODEL = config.ABWASSER_ILI_MODEL
utils.ili2db.create_ili_schema(
SCHEMA, ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema
)
utils.ili2db.import_xtf_data(SCHEMA, args.path, make_log_path(log_path, "iliimport"))
print ("qgep_import: " + SCHEMA + "/" + ILI_MODEL)
qgep_import()
elif impmodel == "SIA405_ABWASSER_2015_LV95":
ABWASSER_SIA405_SCHEMA = config.ABWASSER_SIA405_SCHEMA
ABWASSER_SIA405_ILI_MODEL = config.ABWASSER_SIA405_ILI_MODEL
utils.ili2db.create_ili_schema(
ABWASSER_SIA405_SCHEMA, ABWASSER_SIA405_ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema
)
utils.ili2db.import_xtf_data(
ABWASSER_SIA405_SCHEMA, args.path, make_log_path(log_path, "iliimport")
)
print ("qgepsia405_import: " + ABWASSER_SIA405_SCHEMA + "/" + ABWASSER_SIA405_ILI_MODEL)
qgepsia405_import()

elif impmodel == "DSS_2015_LV95":
ABWASSER_DSS_SCHEMA = config.ABWASSER_DSS_SCHEMA
ABWASSER_DSS_ILI_MODEL = config.ABWASSER_DSS_ILI_MODEL
utils.ili2db.create_ili_schema(
ABWASSER_DSS_SCHEMA, ABWASSER_DSS_ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema
)
utils.ili2db.import_xtf_data(
ABWASSER_DSS_SCHEMA, args.path, make_log_path(log_path, "iliimport"))
print ("qgepdss_import: " + ABWASSER_DSS_SCHEMA + "/" + ABWASSER_DSS_ILI_MODEL)
qgepdss_import()

else:
print("MODEL " + impmodel + " schema creation failed: Not yet supported for INTERLIS import - no configuration available in config.py / _init_.py")



elif args.parser == "qwat":
config.PGSERVICE = args.pgservice
Expand Down Expand Up @@ -218,6 +327,7 @@ def main(args):
if args.model == "qgep":
if config.PGSERVICE is None:
config.PGSERVICE = config.QGEP_DEFAULT_PGSERVICE
#to do add model dependency
utils.ili2db.create_ili_schema(config.ABWASSER_SCHEMA, config.ABWASSER_ILI_MODEL, recreate_schema=True)
QGEPMAPPING = get_qgep_mapping()
utils.templates.generate_template("qgep", "abwasser", BaseQgep, BaseAbwasser, QGEPMAPPING)
Expand All @@ -239,5 +349,8 @@ def main(args):
else:
print("Unknown operation")
exit(1)

# else:
# # to do maybe read message from orientation_list
# print("No valid value for labels_orientation: [0.0, 90.0, -90.0]")
# exit(1)
print("Operation completed sucessfully !")
30 changes: 30 additions & 0 deletions qgepqwat2ili/bin/ili2pg-4.5.0-bindist/docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@ ideas/open issues/questions
LATEST
---------------------------

ili2db 4.6.1 (2021-11-10)
------------------------------
- Enum values are inserted twice when generating a script (#426)
- export only required MODELs in HEADERSECTION (#413)
- export by --topics with no baskets should create an empty transfer file (#432)
- --sqlColsAsText erzeugt leere Geometrien (#423)
- iox-ili-1.21.8

ili2db 4.6.0 (2021-09-10)
------------------------------
- replaced the legacy GUI with a message box
- fix "illegal value null for attrname" (#401)
- ili2fgdb: fix NullPointerException with --strokeArcs (#399)
- fix export of struct attr in VIEW (#397)
- added Iox2jsonUtility
- support --skipReferenceErrors on export
- fix missing model if --exportModels uses a translated model in another ili-file (#405)
- fix mapping of struct at model level if --exportModels used (#405)
- remove duplicate ReduceToBaseModel (duplicate in iox-ili) (#405)
- ili-cache: set ILI_CACHE_FILENAME=MD5 to use short filenames in $HOME/.ilicache (#420)
- new option --sqlExtRefCols to map EXTERNAL references as t_ili_tid FK (#283)
- new option --sqlColsAsText to map simple type attributes to text columns (#402)
- new option --exportBatchSize to set JDBC batchSize (#414)
- new option --importFetchSize to set JDBC fetchSize (#334)
- ili24: implement MULTICOORD (#408)
- support --option=booleanValue (#393)
- use metaattribute @ili2db.dispName with --createEnumTxtCol (#349)
- iox-ili-1.21.7
- ili2c-5.2.3

ili2db 4.5.0 (2021-03-12)
------------------------------
- ili2h2gis: add schema support (#383)
Expand Down
Loading

0 comments on commit 3b53854

Please sign in to comment.