From d8eb84de2a9143be080d901d221202050eaebd38 Mon Sep 17 00:00:00 2001 From: Forrest Date: Mon, 10 Feb 2025 12:15:37 -0500 Subject: [PATCH 1/2] Handle None style_options Fix create_raster_map_layer calling .get() on NoneType. --- uvdat/core/tasks/map_layers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uvdat/core/tasks/map_layers.py b/uvdat/core/tasks/map_layers.py index 00d2d7ab..8bef68ba 100644 --- a/uvdat/core/tasks/map_layers.py +++ b/uvdat/core/tasks/map_layers.py @@ -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, @@ -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={}, From ac3f1f7f0c7b3ed2daacd4a4d55e36ee961fd13a Mon Sep 17 00:00:00 2001 From: Forrest Date: Mon, 10 Feb 2025 12:17:06 -0500 Subject: [PATCH 2/2] Handle case where input file type is not supported --- uvdat/core/tasks/map_layers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uvdat/core/tasks/map_layers.py b/uvdat/core/tasks/map_layers.py index 8bef68ba..12a8c2eb 100644 --- a/uvdat/core/tasks/map_layers.py +++ b/uvdat/core/tasks/map_layers.py @@ -192,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())