diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-02 17:29:34 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-07-21 15:10:29 +0200 |
commit | f713d1010527d171dff95c53f242c009e2b063f8 (patch) | |
tree | 70af36e9f832a5956528d8c25db7bdb9d799defa /ishtar_common/models_imports.py | |
parent | 562b9d55a71867b8b1543049ea3060de8386fb0c (diff) | |
download | Ishtar-f713d1010527d171dff95c53f242c009e2b063f8.tar.bz2 Ishtar-f713d1010527d171dff95c53f242c009e2b063f8.zip |
✨ GIS API: GIS import
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r-- | ishtar_common/models_imports.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 77b98fee1..b8626358c 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -154,6 +154,17 @@ IMPORT_TYPES = ( IMPORT_TYPES_DICT = dict(IMPORT_TYPES) +SPECIFIC_TYPES_COLUMNS = { + "point_2d": "Point2D", + "point_3d": "Point3D", + "multi_points": "MultiPoints", + "multi_line": "MultiLine", + "multi_polygon": "MultiPolygon", + "x": "X", + "y": "Y", + "z": "Z", +} + class ImporterType(models.Model): """ @@ -461,6 +472,30 @@ class ImporterType(models.Model): col_names.append(formater.label) return cols, col_names + def get_columns_types(self, importer_class=None): + """ + :param importer_class: importer class - if not provided get from self + :return: (list): return list of column types - each types is a string + """ + if not importer_class: + importer_class = self.get_importer_class() + types = [] + for formater in importer_class.LINE_EXPORT_FORMAT: + if not formater: + types.append("") + continue + + ctype = "" + field_name = formater.field_name[0] + for k in SPECIFIC_TYPES_COLUMNS: + if field_name == k or field_name.endswith(f"__{k}"): + ctype = SPECIFIC_TYPES_COLUMNS[k] + break + if not ctype: + ctype = str(formater.formater[0]) + types.append(ctype) + return types + def save(self, *args, **kwargs): if not self.slug: self.slug = create_slug(ImporterType, self.name) |