Skip to content

Commit

Permalink
fix: allow reference other sources, depth=1 must be specified
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Dec 19, 2023
1 parent 1c0a7dc commit 64fb981
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions metadata_catalogue/maps/libs/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def map_from_maplibre_style_spec(map_name: str, style: dict):
else:
entities[key] = Source.objects.create(**source_attrs)

group = LayerGroup.objects.create(name="Layers", order=0, map=map, download_url=None)
group = LayerGroup.objects.create(name="Layers", order=0, map=map, download_url=None, depth=1)

for i, layer in enumerate(style.get("layers")):
layer_attrs = {
Expand All @@ -71,7 +71,11 @@ def map_from_maplibre_style_spec(map_name: str, style: dict):
layer_attrs["style"]["layout"] = layer["layout"]

if "source" in layer:
layer_attrs["source"] = entities[layer["source"]]
if layer["source"] in entities:
source = entities[layer["source"]]
else:
source = Source.objects.filter(slug=slugify(layer["source"])).first()
layer_attrs["source"] = source
layer_attrs["group"] = group
layer_attrs["group_order"] = i

Expand Down

0 comments on commit 64fb981

Please sign in to comment.