ili2ogc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ili2ogc-0.1.0/.gitignore +9 -0
- ili2ogc-0.1.0/LICENSE +21 -0
- ili2ogc-0.1.0/PKG-INFO +131 -0
- ili2ogc-0.1.0/README.md +73 -0
- ili2ogc-0.1.0/mappings/ilismeta16-associations.yml +919 -0
- ili2ogc-0.1.0/mappings/ilismeta16-classes.yml +2670 -0
- ili2ogc-0.1.0/mappings/ilismeta16-datatypes.yml +644 -0
- ili2ogc-0.1.0/mappings/ilismeta16-enumerations.yml +7 -0
- ili2ogc-0.1.0/mappings/ilismeta16-extensions.yml +1 -0
- ili2ogc-0.1.0/mappings/ilismeta16-kind-values.yml +159 -0
- ili2ogc-0.1.0/pyproject.toml +167 -0
- ili2ogc-0.1.0/spec/grammar/mapping/01_root.yml +18 -0
- ili2ogc-0.1.0/spec/grammar/mapping/02_packages.yml +419 -0
- ili2ogc-0.1.0/spec/grammar/mapping/03_classes_and_structures.yml +199 -0
- ili2ogc-0.1.0/spec/grammar/mapping/04_attributes.yml +357 -0
- ili2ogc-0.1.0/spec/grammar/mapping/05_associations.yml +146 -0
- ili2ogc-0.1.0/spec/grammar/mapping/06_types.yml +1264 -0
- ili2ogc-0.1.0/spec/grammar/mapping/07_constraints.yml +934 -0
- ili2ogc-0.1.0/spec/grammar/mapping/08_functions_units.yml +256 -0
- ili2ogc-0.1.0/spec/grammar/mapping/09_views_graphics.yml +660 -0
- ili2ogc-0.1.0/src/interlis/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisLexer.interp +623 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisLexer.py +1026 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisLexer.tokens +390 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisParser.interp +536 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisParser.py +14831 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisParser.tokens +390 -0
- ili2ogc-0.1.0/src/interlis/antlr/InterlisParserVisitor.py +618 -0
- ili2ogc-0.1.0/src/interlis/builder/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/builder/_builder_protocol.py +39 -0
- ili2ogc-0.1.0/src/interlis/builder/attach.py +215 -0
- ili2ogc-0.1.0/src/interlis/builder/context_access.py +104 -0
- ili2ogc-0.1.0/src/interlis/builder/context_mixin.py +95 -0
- ili2ogc-0.1.0/src/interlis/builder/errors.py +48 -0
- ili2ogc-0.1.0/src/interlis/builder/forward_refs.py +371 -0
- ili2ogc-0.1.0/src/interlis/builder/model_builder.py +2196 -0
- ili2ogc-0.1.0/src/interlis/builder/oid_mixin.py +149 -0
- ili2ogc-0.1.0/src/interlis/builder/repository.py +323 -0
- ili2ogc-0.1.0/src/interlis/builder/source_resolver.py +437 -0
- ili2ogc-0.1.0/src/interlis/builder/translation_mixin.py +156 -0
- ili2ogc-0.1.0/src/interlis/builder/view_mixin.py +483 -0
- ili2ogc-0.1.0/src/interlis/cli.py +1417 -0
- ili2ogc-0.1.0/src/interlis/cli_style.py +71 -0
- ili2ogc-0.1.0/src/interlis/convert/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/convert/cartosym.py +1081 -0
- ili2ogc-0.1.0/src/interlis/convert/color.py +44 -0
- ili2ogc-0.1.0/src/interlis/convert/constraint_eval.py +262 -0
- ili2ogc-0.1.0/src/interlis/convert/cql2.py +215 -0
- ili2ogc-0.1.0/src/interlis/convert/jsonfg.py +2347 -0
- ili2ogc-0.1.0/src/interlis/convert/jsonschema.py +769 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/__init__.py +39 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/expressions.py +150 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/identifiers.py +64 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/model.py +103 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/render.py +180 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/tables.py +869 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/types.py +86 -0
- ili2ogc-0.1.0/src/interlis/convert/sql/views.py +1067 -0
- ili2ogc-0.1.0/src/interlis/convert/translation.py +166 -0
- ili2ogc-0.1.0/src/interlis/convert/xtf_writer.py +280 -0
- ili2ogc-0.1.0/src/interlis/diagnostic_ids.py +136 -0
- ili2ogc-0.1.0/src/interlis/diagnostics.py +235 -0
- ili2ogc-0.1.0/src/interlis/metamodel/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/metamodel/instance.py +50 -0
- ili2ogc-0.1.0/src/interlis/metamodel/registry.py +85 -0
- ili2ogc-0.1.0/src/interlis/metamodel/uml_schema.py +52 -0
- ili2ogc-0.1.0/src/interlis/runtime/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/runtime/parse.py +134 -0
- ili2ogc-0.1.0/src/interlis/spec/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/spec/models.py +53 -0
- ili2ogc-0.1.0/src/interlis/spec/spec_index.py +46 -0
- ili2ogc-0.1.0/src/interlis/spec/uml_index.py +101 -0
- ili2ogc-0.1.0/src/interlis/xtf/__init__.py +0 -0
- ili2ogc-0.1.0/src/interlis/xtf/model_resolution.py +81 -0
- ili2ogc-0.1.0/src/interlis/xtf/parse.py +264 -0
- ili2ogc-0.1.0/src/interlis/xtf/schema.py +553 -0
- ili2ogc-0.1.0/src/interlis/xtf/validate.py +1131 -0
ili2ogc-0.1.0/.gitignore
ADDED
ili2ogc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Federal Office of Topography swisstopo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ili2ogc-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ili2ogc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A pure-Python INTERLIS 2 toolkit: build a live metamodel from .ili, validate .xtf transfers, and convert to/from JSON Schema, OGC JSON-FG, PostgreSQL/GeoPackage SQL, and CQL2-JSON filters, with multi-language (TRANSLATION OF) output
|
|
5
|
+
Project-URL: Homepage, https://github.com/maxcollombin/ili2ogc
|
|
6
|
+
Project-URL: Repository, https://github.com/maxcollombin/ili2ogc.git
|
|
7
|
+
Project-URL: Issues, https://github.com/maxcollombin/ili2ogc/issues
|
|
8
|
+
Author-email: Maxime Collombin <maxime.collombin@netplus.ch>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Federal Office of Topography swisstopo
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: cql2,geodata,gis,interlis,json-fg,json-schema,ogc,sql,swisstopo
|
|
32
|
+
Classifier: Development Status :: 3 - Alpha
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Requires-Python: >=3.10
|
|
44
|
+
Requires-Dist: antlr4-python3-runtime==4.13.2
|
|
45
|
+
Requires-Dist: jsonschema>=4.23.0
|
|
46
|
+
Requires-Dist: pycartosym[sld]>=0.3.5
|
|
47
|
+
Requires-Dist: pydantic>=2.13.4
|
|
48
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: antlr4-tools>=0.2.2; extra == 'dev'
|
|
51
|
+
Requires-Dist: black>=24.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
53
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
55
|
+
Requires-Dist: ruamel-yaml>=0.19.1; extra == 'dev'
|
|
56
|
+
Requires-Dist: ruff>=0.16.2; extra == 'dev'
|
|
57
|
+
Description-Content-Type: text/markdown
|
|
58
|
+
|
|
59
|
+
# ili2ogc
|
|
60
|
+
|
|
61
|
+
A pure-Python INTERLIS 2 toolkit: parses `.ili` models into a graph of typed
|
|
62
|
+
Python objects (the IlisMeta16 metamodel), validates `.xtf` data transfers
|
|
63
|
+
against them, and converts both to JSON Schema, SQL DDL (PostgreSQL/
|
|
64
|
+
GeoPackage), OGC JSON-FG, CQL2-JSON filters, and back to `.xtf`. `TRANSLATION
|
|
65
|
+
OF` models are supported throughout via `--lang` (renames identifiers/keys
|
|
66
|
+
in the output, the transfer wire format itself is unaffected).
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
uv sync # or: pip install .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The generated ANTLR lexer/parser are committed under `src/interlis/antlr/`,
|
|
75
|
+
so no grammar build step is needed.
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
interlis build model.ili --repo models/ # parse + print the built model
|
|
81
|
+
interlis validate transfer.xtf --repo models/ # check .xtf against its .ili schema
|
|
82
|
+
interlis convert model.ili -o model.schema.json # .ili -> JSON Schema
|
|
83
|
+
interlis convert-sql model.ili --dialect postgresql -o model.sql # .ili -> SQL DDL
|
|
84
|
+
interlis convert-jsonfg transfer.xtf --repo models/ -o out.jsonfg.json # .xtf -> OGC JSON-FG
|
|
85
|
+
interlis convert-cql2 model.ili -o model.cql2.json # CONSTRAINT -> CQL2-JSON filters
|
|
86
|
+
interlis write-xtf view-model.ili source.xtf -o view.xtf # VIEW TOPIC data -> .xtf
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`--repo DIR` (repeatable) resolves `IMPORTS`/schema references against a
|
|
90
|
+
directory of `.ili` files. Run `interlis <command> --help` for every option.
|
|
91
|
+
|
|
92
|
+
## Python API
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from pathlib import Path
|
|
96
|
+
from interlis.runtime.parse import parse_file
|
|
97
|
+
from interlis.builder.model_builder import InterlisModelBuilder
|
|
98
|
+
from interlis.xtf.parse import parse_xtf
|
|
99
|
+
from interlis.xtf.validate import validate_transfer
|
|
100
|
+
|
|
101
|
+
tree, syntax_errors = parse_file(Path("model.ili"))
|
|
102
|
+
builder = InterlisModelBuilder(Path("mappings"), Path("spec/grammar/mapping"))
|
|
103
|
+
model = builder.build(tree) # graph of Pydantic objects, e.g. model.Element[0].Name
|
|
104
|
+
|
|
105
|
+
transfer = parse_xtf(Path("transfer.xtf"))
|
|
106
|
+
issues = validate_transfer(transfer, symbol_table=builder.symbol_table)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`interlis.convert.jsonschema`/`.sql`/`.jsonfg`/`.cql2`/`.xtf_writer` expose
|
|
110
|
+
the same conversions as the CLI's `convert`/`convert-sql`/`convert-jsonfg`/
|
|
111
|
+
`convert-cql2`/`write-xtf`. Pass a `ModelRepository`
|
|
112
|
+
(`interlis.builder.repository`) to the builder to resolve `IMPORTS` against
|
|
113
|
+
other local `.ili` models.
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
uv run pytest # test suite
|
|
119
|
+
uv run ruff check src/ tests/ # lint (also enforced in CI)
|
|
120
|
+
uv run black src/ tests/ # format
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
CI (`.github/workflows/ci.yml`) runs `ruff`, `black --check` and the test
|
|
124
|
+
suite on Python 3.10/3.12/3.14.
|
|
125
|
+
|
|
126
|
+
`spec/grammar/mapping/*.yml` and `mappings/ilismeta16-*.yml` (the
|
|
127
|
+
IlisMeta16 metamodel) are the executable source of truth: `InterlisModelBuilder`
|
|
128
|
+
is a generic engine driven by this data, not hand-written parsing code per
|
|
129
|
+
grammar rule. Regenerating the vendored grammar under
|
|
130
|
+
`vendor/interlis-antlr4` is a maintainer-only step, needed only when that
|
|
131
|
+
submodule changes.
|
ili2ogc-0.1.0/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ili2ogc
|
|
2
|
+
|
|
3
|
+
A pure-Python INTERLIS 2 toolkit: parses `.ili` models into a graph of typed
|
|
4
|
+
Python objects (the IlisMeta16 metamodel), validates `.xtf` data transfers
|
|
5
|
+
against them, and converts both to JSON Schema, SQL DDL (PostgreSQL/
|
|
6
|
+
GeoPackage), OGC JSON-FG, CQL2-JSON filters, and back to `.xtf`. `TRANSLATION
|
|
7
|
+
OF` models are supported throughout via `--lang` (renames identifiers/keys
|
|
8
|
+
in the output, the transfer wire format itself is unaffected).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
uv sync # or: pip install .
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The generated ANTLR lexer/parser are committed under `src/interlis/antlr/`,
|
|
17
|
+
so no grammar build step is needed.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
interlis build model.ili --repo models/ # parse + print the built model
|
|
23
|
+
interlis validate transfer.xtf --repo models/ # check .xtf against its .ili schema
|
|
24
|
+
interlis convert model.ili -o model.schema.json # .ili -> JSON Schema
|
|
25
|
+
interlis convert-sql model.ili --dialect postgresql -o model.sql # .ili -> SQL DDL
|
|
26
|
+
interlis convert-jsonfg transfer.xtf --repo models/ -o out.jsonfg.json # .xtf -> OGC JSON-FG
|
|
27
|
+
interlis convert-cql2 model.ili -o model.cql2.json # CONSTRAINT -> CQL2-JSON filters
|
|
28
|
+
interlis write-xtf view-model.ili source.xtf -o view.xtf # VIEW TOPIC data -> .xtf
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`--repo DIR` (repeatable) resolves `IMPORTS`/schema references against a
|
|
32
|
+
directory of `.ili` files. Run `interlis <command> --help` for every option.
|
|
33
|
+
|
|
34
|
+
## Python API
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
from interlis.runtime.parse import parse_file
|
|
39
|
+
from interlis.builder.model_builder import InterlisModelBuilder
|
|
40
|
+
from interlis.xtf.parse import parse_xtf
|
|
41
|
+
from interlis.xtf.validate import validate_transfer
|
|
42
|
+
|
|
43
|
+
tree, syntax_errors = parse_file(Path("model.ili"))
|
|
44
|
+
builder = InterlisModelBuilder(Path("mappings"), Path("spec/grammar/mapping"))
|
|
45
|
+
model = builder.build(tree) # graph of Pydantic objects, e.g. model.Element[0].Name
|
|
46
|
+
|
|
47
|
+
transfer = parse_xtf(Path("transfer.xtf"))
|
|
48
|
+
issues = validate_transfer(transfer, symbol_table=builder.symbol_table)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`interlis.convert.jsonschema`/`.sql`/`.jsonfg`/`.cql2`/`.xtf_writer` expose
|
|
52
|
+
the same conversions as the CLI's `convert`/`convert-sql`/`convert-jsonfg`/
|
|
53
|
+
`convert-cql2`/`write-xtf`. Pass a `ModelRepository`
|
|
54
|
+
(`interlis.builder.repository`) to the builder to resolve `IMPORTS` against
|
|
55
|
+
other local `.ili` models.
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
uv run pytest # test suite
|
|
61
|
+
uv run ruff check src/ tests/ # lint (also enforced in CI)
|
|
62
|
+
uv run black src/ tests/ # format
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
CI (`.github/workflows/ci.yml`) runs `ruff`, `black --check` and the test
|
|
66
|
+
suite on Python 3.10/3.12/3.14.
|
|
67
|
+
|
|
68
|
+
`spec/grammar/mapping/*.yml` and `mappings/ilismeta16-*.yml` (the
|
|
69
|
+
IlisMeta16 metamodel) are the executable source of truth: `InterlisModelBuilder`
|
|
70
|
+
is a generic engine driven by this data, not hand-written parsing code per
|
|
71
|
+
grammar rule. Regenerating the vendored grammar under
|
|
72
|
+
`vendor/interlis-antlr4` is a maintainer-only step, needed only when that
|
|
73
|
+
submodule changes.
|