Skip to content
Open
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
1 change: 1 addition & 0 deletions geospatial-utils/adjusters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import foca as foca
55 changes: 2 additions & 53 deletions geospatial-utils/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

from datetime import datetime

from implicitdict import ImplicitDict, StringBasedDateTime
from uas_standards.eurocae_ed318 import TextShortType


class ConverterConfiguration(ImplicitDict):
name: str
ed318_additions: ED318Additions
adjusters: list[str]


class ED318Additions(ImplicitDict):
Expand All @@ -19,54 +19,3 @@ class ED318Additions(ImplicitDict):
otherGeoid: str
feature_collection_bbox: list[float]
collection_name: str


FOCA = ED318Additions(
default_lang="en-GB",
provider=[
TextShortType(lang="de-CH", text="BAZL"),
TextShortType(lang="fr-CH", text="OFAC"),
TextShortType(lang="it-CH", text="UFAC"),
TextShortType(lang="en-GB", text="FOCA"),
],
description=[ # TODO: To validate
TextShortType(
lang="de-CH",
text="Schweizerische UAS Geozones, herausgegeben vom Bundesamt für Zivilluftfahrt (BAZL). Umwandlung aus dem Modell ED-269.",
),
TextShortType(
lang="fr-CH",
text="UAS Geozones suisses publiées par l'Office fédéral de l'aviation civile (OFAC). Conversion à partir du modèle ED-269",
),
TextShortType(
lang="it-CH",
text="Geozones UAS svizzere emesse dall'Ufficio federale dell'aviazione civile (UFAC). Conversione dal modello ED-269",
),
TextShortType(
lang="en-GB",
text="Swiss UAS Geozones issued by the Federal Office of Civil Aviation (FOCA). Conversion from the ED-269 model",
),
],
technicalLimitation=[ # TODO: To validate
TextShortType(
lang="de-CH",
text="Der Datensatz entsteht durch die Umwandlung der Originaldaten des ED-269-Modells ins neue ED-318. Für die Umwandlung sind einige Datenänderungen nötig. Diese Datei wurde in INTERLIS 2.4 erstellt.",
),
TextShortType(
lang="fr-CH",
text="Le fichier a été créé en convertissant les données originales du modèle ED-269 dans le nouveau ED-318. La conversion nécessite des modifications des données. Ce fichier a été créé en INTERLIS 2.4",
),
TextShortType(
lang="it-CH",
text="Il dataset è stato creato convertendo i dati originali del modello ED-269 nel nuovo ED-318. Per la conversione alcune modifiche dei dati sono necessarie. Questo file è stato creato in INTERLIS 2.4",
),
TextShortType(
lang="en-GB",
text="The dataset was created by converting the original data from the ED-269 model to the new ED-318. Some data modifications are necessary for conversion. This file was created in INTERLIS 2.4",
),
],
issued=StringBasedDateTime(datetime.now()),
otherGeoid="CHGeo2004",
collection_name="Swiss UAS Geozones according to ED-318 converted from the ED-269 data model",
feature_collection_bbox=[2485410.215, 1075268.136, 2833857.724, 1295933.698],
)
72 changes: 72 additions & 0 deletions geospatial-utils/configs/FOCA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "Swiss FOCA",
"adjusters": [
"foca"
],
"ed318_additions": {
"default_lang": "en-GB",
"provider": [
{
"lang": "de-CH",
"text": "BAZL"
},
{
"lang": "fr-CH",
"text": "OFAC"
},
{
"lang": "it-CH",
"text": "UFAC"
},
{
"lang": "en-GB",
"text": "FOCA"
}
],
"description": [
{
"lang": "de-CH",
"text": "Schweizerische UAS Geozones, herausgegeben vom Bundesamt f\u00fcr Zivilluftfahrt (BAZL). Umwandlung aus dem Modell ED-269."
},
{
"lang": "fr-CH",
"text": "UAS Geozones suisses publi\u00e9es par l'Office f\u00e9d\u00e9ral de l'aviation civile (OFAC). Conversion \u00e0 partir du mod\u00e8le ED-269"
},
{
"lang": "it-CH",
"text": "Geozones UAS svizzere emesse dall'Ufficio federale dell'aviazione civile (UFAC). Conversione dal modello ED-269"
},
{
"lang": "en-GB",
"text": "Swiss UAS Geozones issued by the Federal Office of Civil Aviation (FOCA). Conversion from the ED-269 model"
}
],
"technicalLimitation": [
{
"lang": "de-CH",
"text": "Der Datensatz entsteht durch die Umwandlung der Originaldaten des ED-269-Modells ins neue ED-318. F\u00fcr die Umwandlung sind einige Daten\u00e4nderungen n\u00f6tig. Diese Datei wurde in INTERLIS 2.4 erstellt."
},
{
"lang": "fr-CH",
"text": "Le fichier a \u00e9t\u00e9 cr\u00e9\u00e9 en convertissant les donn\u00e9es originales du mod\u00e8le ED-269 dans le nouveau ED-318. La conversion n\u00e9cessite des modifications des donn\u00e9es. Ce fichier a \u00e9t\u00e9 cr\u00e9\u00e9 en INTERLIS 2.4"
},
{
"lang": "it-CH",
"text": "Il dataset \u00e8 stato creato convertendo i dati originali del modello ED-269 nel nuovo ED-318. Per la conversione alcune modifiche dei dati sono necessarie. Questo file \u00e8 stato creato in INTERLIS 2.4"
},
{
"lang": "en-GB",
"text": "The dataset was created by converting the original data from the ED-269 model to the new ED-318. Some data modifications are necessary for conversion. This file was created in INTERLIS 2.4"
}
],
"issued": "2025-12-16T14:38:18.121239Z",
"otherGeoid": "CHGeo2004",
"collection_name": "Swiss UAS Geozones according to ED-318 converted from the ED-269 data model",
"feature_collection_bbox": [
2485410.215,
1075268.136,
2833857.724,
1295933.698
]
}
}
2 changes: 2 additions & 0 deletions geospatial-utils/configs/personal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
36 changes: 25 additions & 11 deletions geospatial-utils/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import pathlib
import sys

import adjusters.foca
import config
import adjusters
import convert
import fileutils
import validate
from config import ConverterConfiguration
from fileutils import ed269
from implicitdict import ImplicitDict
from loguru import logger

version = os.environ.get("GEOSPATIAL_UTILS_VERSION", "unknown")
Expand Down Expand Up @@ -37,6 +38,13 @@ def main():
default="0",
)

convert_cmd.add_argument(
"-c",
"--config",
help="Path to the configuration to use.",
default="configs/FOCA.json",
)

args = parser.parse_args()

if args.command == "convert":
Expand All @@ -46,19 +54,25 @@ def main():

# Load source
ed269_data = ed269.loads(source)
# TODO: Move hard-coded configuration to a json file.
logger.warning(
"Additional data not provided in ED269 is hard-coded with Swiss FOCA information. This will be moved to a configurable file in the near future."
)

# Load config
with open(args.config) as f:
data = json.load(f)
config = ImplicitDict.parse(data, ConverterConfiguration)
logger.info(f"Using configuration {config.name}")

# Conversion
ed318_data = convert.from_ed269_to_ed318(ed269_data, config=config.FOCA)
ed318_data = convert.from_ed269_to_ed318(
ed269_data, config=config.ed318_additions
)

# Adjustments
logger.warning(
"The output is adjusted with Swiss FOCA configuration. The output contains non-conform ConditionExpressionType values."
)
ed318_data = adjusters.foca.adjust(ed318_data)
for adjuster in config.adjusters:
if not hasattr(adjusters, adjuster):
logger.error(f"Unknown adjuster: {adjuster}")
sys.exit(1)

ed318_data = getattr(adjusters, adjuster).adjust(ed318_data)

# Save to file
output = pathlib.Path(args.output_file)
Expand Down