Skip to content

Commit

Permalink
Migrate from OpenLayers to MapLibre GL (#63)
Browse files Browse the repository at this point in the history
* Partially working maplibre-gl implementation

* Rename server map layers to dataset layers

* Fix basic rendering issues

* Fix active layer ordering

* Fix opacity rendering

* Remove use of DatasetLayer.openlayer

* Fix updateBaseLayer and clearMapLayers

* Place toggled layer on top if not created

* Improve types

* Correctly display vector layer points

* Display region datasets correctly

* Clean up unnecessary code and fix type issues

* Simplify layer creation

* Fix map click handler

* Fix zoom to region button

* Remove region grouping functionality in map tooltip

* Apply style changes to all dataset layers by default

* Fix circle layer opacity issue

* Improve line and circle rendering

* Fix raster and tooltip display

* Consolidate tooltip manipulation code

* Clean up raster colormap code

* Fix layout of zoom to region button

* Enable network and GCC features

* Remove references to openlayers

* Use OSM instead of map tiler

* Fix linting errors

* Ensure map layers are fetched in sorted order

* Fix bug in raster tile request param construction

* Remove unused and commented out code

* Ignore and add TODO to non-null assertion

* Remove nested array in network endpoint

* Add comment to explain unavoidable error

* Fix bug with reset network button

* Show raster and flood map layers in simulations panel

* Add ts-ignore statements

* Remove TODOs
  • Loading branch information
jjnesbitt authored Sep 25, 2024
1 parent 6c51ec8 commit ad426e9
Show file tree
Hide file tree
Showing 23 changed files with 12,786 additions and 12,174 deletions.
1 change: 1 addition & 0 deletions uvdat/core/models/map_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Meta:

class RasterMapLayer(AbstractMapLayer):
cloud_optimized_geotiff = S3FileField()
# TODO: Store data x/y min/max bounds on model

def get_image_data(self, resolution: float = 1.0):
with tempfile.TemporaryDirectory() as tmp:
Expand Down
22 changes: 10 additions & 12 deletions uvdat/core/rest/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ def network(self, request, **kwargs):
networks = []
for network in dataset.networks.all():
networks.append(
[
{
'nodes': [
uvdat_serializers.NetworkNodeSerializer(n).data
for n in NetworkNode.objects.filter(network=network)
],
'edges': [
uvdat_serializers.NetworkEdgeSerializer(e).data
for e in NetworkEdge.objects.filter(network=network)
],
}
]
{
'nodes': [
uvdat_serializers.NetworkNodeSerializer(n).data
for n in NetworkNode.objects.filter(network=network)
],
'edges': [
uvdat_serializers.NetworkEdgeSerializer(e).data
for e in NetworkEdge.objects.filter(network=network)
],
}
)
return HttpResponse(json.dumps(networks), status=200)

Expand Down
4 changes: 0 additions & 4 deletions uvdat/core/rest/map_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
ST_Transform(t.geometry, %(srid)s),
ST_Transform(bounds.geom, %(srid)s)
)
AND (
ST_GeometryType(ST_AsText(t.geometry)) != 'ST_Point'
OR %(z)s >= 16
)
)
SELECT ST_AsMVT(mvtgeom.*) FROM mvtgeom
;
Expand Down
10 changes: 9 additions & 1 deletion uvdat/core/rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,20 @@ class Meta:


class VectorMapLayerSerializer(serializers.ModelSerializer, AbstractMapLayerSerializer):
dataset_category = serializers.SerializerMethodField()

def get_dataset_category(self, obj: VectorMapLayer):
if obj.dataset is None:
raise Exception('map layer with null dataset!')

return obj.dataset.category

class Meta:
model = VectorMapLayer
exclude = ['geojson_file']


class VectorMapLayerDetailSerializer(serializers.ModelSerializer, AbstractMapLayerSerializer):
class VectorMapLayerDetailSerializer(VectorMapLayerSerializer):
derived_region_id = serializers.SerializerMethodField('get_derived_region_id')

def get_derived_region_id(self, obj):
Expand Down
3 changes: 3 additions & 0 deletions web/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VUE_APP_OAUTH_CLIENT_ID=cBmD6D6F2YAmMWHNQZFPUr4OpaXVpW5w4Thod6Kj
VUE_APP_API_ROOT=http://localhost:8000/api/v1
VUE_APP_OAUTH_API_ROOT=http://localhost:8000/oauth/
1 change: 1 addition & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
# local env files
.env.local
.env.*.local
.env

# Log files
npm-debug.log*
Expand Down
Loading

0 comments on commit ad426e9

Please sign in to comment.