Skip to content

Commit

Permalink
Fix cloud native not being rendered (#390)
Browse files Browse the repository at this point in the history
* Fix cloud native not being rendered

* Fix COG to render correct order
  • Loading branch information
meomancer authored Jan 30, 2025
1 parent e698a08 commit 2478a7a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ function ContextLayers() {
* @param {function} handleChange Function when the accordion show.
*/
export default function ContextLayersAccordion({ expanded }) {
const dispatch = useDispatch();
const { contextLayersShow } = useSelector(state => state.map);

/** Render group and layers
* @param {str} groupName Name of group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
* __copyright__ = ('Copyright 2024, Unicef')
*/

import {
addPopup,
getBeforeLayerId,
getLayerIdOfReferenceLayer,
hasSource
} from "../utils";
import { addPopup, getBeforeLayerId, hasSource } from "../utils";
import { GET_RESOURCE } from "../../../../utils/ResourceRequests";


Expand All @@ -39,7 +34,7 @@ export default function cloudNativeGISLayer(map, id, data, contextLayerData, pop
const url = info.tile_url

// We find the before layers
let before = getLayerIdOfReferenceLayer(map)
let before = null
if (contextLayerOrder) {
const beforeOrder = getBeforeLayerId(map, id, contextLayerOrder)
if (beforeOrder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
addClickEvent,
addStandalonePopup,
getBeforeLayerId,
getLayerIdOfReferenceLayer,
hexToRgba,
removeLayer,
removeSource
Expand All @@ -29,6 +28,7 @@ import { sleep } from "../../../../utils/main";
import { getCogFeatureByPoint } from "../../../../utils/COGLayer";
import { setColorFunction } from '@geomatico/maplibre-cog-protocol';
import { DjangoRequests } from "../../../../Requests";
import { Session } from "../../../../utils/Sessions";


/***
Expand Down Expand Up @@ -64,6 +64,10 @@ export default function rasterCogLayer(map, id, data, setData, contextLayerData,
}

let classifications = [];
const session = new Session(id, 1000)
if (!session.isValid) {
return
}

await DjangoRequests.post(
`/api/raster/classification`,
Expand All @@ -82,6 +86,10 @@ export default function rasterCogLayer(map, id, data, setData, contextLayerData,
throw Error(error.toString())
})

if (!session.isValid) {
return
}

// TODO: Handle styling when multiple, identical COG URLs are used
const url = `cog://${data.url}#` + contextLayerData.id;

Expand Down Expand Up @@ -132,7 +140,7 @@ export default function rasterCogLayer(map, id, data, setData, contextLayerData,
map.addSource(id, sourceParams);

// We find the before layers
let before = getLayerIdOfReferenceLayer(map)
let before = null;
if (contextLayerOrder) {
const beforeOrder = getBeforeLayerId(map, id, contextLayerOrder)
if (beforeOrder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
* __copyright__ = ('Copyright 2023, Unicef')
*/

import {
addPopup,
getBeforeLayerId,
getLayerIdOfReferenceLayer,
hasSource
} from "../utils";
import { addPopup, getBeforeLayerId, hasSource } from "../utils";


/***
Expand All @@ -31,7 +26,7 @@ export default function vectorTileLayer(map, id, data, contextLayerData, popupFe
}

// We find the before layers
let before = getLayerIdOfReferenceLayer(map)
let before = null;
if (contextLayerOrder) {
const beforeOrder = getBeforeLayerId(map, id, contextLayerOrder)
if (beforeOrder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ export function ReferenceLayer(

// Fill layer
const contextLayerIds = map.getStyle().layers.filter(
layer => layer.type !== 'raster'
).filter(
layer => layer.id.includes(CONTEXT_LAYER_ID) || layer.id.includes('gl-draw-') || [INDICATOR_LABEL_ID, LAYER_HIGHLIGHT_ID].includes(layer.id)
)
let before = contextLayerIds[0]?.id
Expand Down
5 changes: 4 additions & 1 deletion django_project/geosight/data/api/v1/context_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class ContextLayerViewSet(
extra_exclude_fields = [
'url', 'permission', 'styles', 'label_styles', 'configuration',
'parameters', 'original_styles', 'original_configuration',
'data_fields'
'data_fields',
'password', 'username',
'cloud_native_gis_layer_id', 'arcgis_config',
'related_table', 'token', 'url_legend', 'group'
]

@swagger_auto_schema(
Expand Down
6 changes: 1 addition & 5 deletions django_project/geosight/data/serializer/context_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ def get_original_configuration(self, obj: ContextLayer):

class Meta: # noqa: D106
model = ContextLayer
exclude = (
'password', 'username',
'cloud_native_gis_layer_id', 'arcgis_config',
'related_table', 'token', 'url_legend', 'group'
)
fields = '__all__'


class ContextLayerFieldSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit 2478a7a

Please sign in to comment.