Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/division importer handle divisions with geometry in multiple featuremembers #370

Merged
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
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
Loading