Skip to content

Commit

Permalink
Merge pull request #100 from OpenGeoscience/map-layer-fixes
Browse files Browse the repository at this point in the history
Fix edge cases with create_{vector,raster}_map_layer
  • Loading branch information
floryst authored Feb 10, 2025
2 parents 32750c0 + ac3f1f7 commit 45b4a90
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions uvdat/core/tasks/map_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def create_raster_map_layer(file_item, style_options):
import large_image
import large_image_converter

style_options = style_options or {}

# create new raster map layer object
new_map_layer = RasterMapLayer.objects.create(
dataset=file_item.dataset,
Expand Down Expand Up @@ -171,6 +173,8 @@ def create_raster_map_layer(file_item, style_options):

def create_vector_map_layer(file_item, style_options):
"""Save a VectorMapLayer from a FileItem's contents."""
style_options = style_options or {}

new_map_layer = VectorMapLayer.objects.create(
dataset=file_item.dataset,
metadata={},
Expand All @@ -188,6 +192,8 @@ def create_vector_map_layer(file_item, style_options):
if source_projection:
geojson_data = geojson_data.set_crs(source_projection)
geojson_data = geojson_data.to_crs(4326)
else:
raise ValueError(f'Cannot handle file type "{file_item.file_type}"')

geojson_data = add_styling(geojson_data, style_options)
new_map_layer.write_geojson_data(geojson_data.to_json())
Expand Down

0 comments on commit 45b4a90

Please sign in to comment.