Skip to content

Commit

Permalink
Merge pull request #370 from City-of-Turku/feature/division-importer-…
Browse files Browse the repository at this point in the history
…handle-divisions-with-geometry-in-multiple-featuremembers

Feature/division importer handle divisions with geometry in multiple featuremembers
  • Loading branch information
juuso-j authored Aug 26, 2024
2 parents e69f4a0 + f0e4b26 commit b618f46
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions smbackend_turku/importers/divisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, logger=None, importer=None):
self.logger = logger
self.importer = importer
self.muni_data_path = "data"
self.imported_geometries = {}

def _import_division(self, muni, div, type_obj, syncher, parent_dict, feat):
check_turku_boundary = div.get("check_turku_boundary", True)
Expand Down Expand Up @@ -240,10 +241,16 @@ def _import_division(self, muni, div, type_obj, syncher, parent_dict, feat):
except AdministrativeDivisionGeometry.DoesNotExist:
geom_obj = AdministrativeDivisionGeometry(division=obj)

# If the geometry is in multiple featureMembers, combine the geometries
if full_id in self.imported_geometries.keys():
geom = geom.union(self.imported_geometries[full_id].boundary)
geom_obj.boundary = geom
geom_obj.save()
self.imported_geometries[full_id] = geom_obj

def _import_one_division_type(self, muni, div):
self.imported_geometries = {}

def make_div_id(obj):
if "parent" in div:
return "%s-%s" % (obj.parent.origin_id, obj.origin_id)
Expand Down

0 comments on commit b618f46

Please sign in to comment.