Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zones FAO] Affichage des zones avec Geoserver #2923

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions frontend/src/domain/types/layer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import TileLayer from 'ol/layer/Tile'
import { TileWMS } from 'ol/source'

import type { RegulatoryZone } from '../../features/Regulation/types'
import type { Point } from 'ol/geom'
import type VectorLayer from 'ol/layer/Vector'
Expand Down Expand Up @@ -30,6 +33,10 @@ export type VectorLayerWithName = VectorLayer<VectorSource> & {
name?: string
}

export type TileLayerWithName = TileLayer<TileWMS> & {
name?: string
}

export type WebGLPointsLayerWithName = WebGLPointsLayer<VectorSource<Point>> & {
name?: string
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FAO_LAYER } from '@features/AdministrativeZone/layers/constants'
import { useMainAppSelector } from '@hooks/useMainAppSelector'
import React, { useEffect } from 'react'

import {
Expand All @@ -7,7 +9,7 @@ import {
layersNotInCurrentOLMap,
layersNotInShowedLayers
} from '../../../domain/entities/layers'
import { useMainAppSelector } from '../../../hooks/useMainAppSelector'
import { LayerProperties } from '../../../domain/entities/layers/constants'
import { monitorfishMap } from '../../map/monitorfishMap'
import { getVectorOLLayer } from '../useCases/showAdministrativeZone'

Expand All @@ -30,6 +32,13 @@ function UnmemoizedAdministrativeLayers() {
if (!layerToInsert) {
return
}

if (layerToInsert.type === LayerProperties.FAO.code && FAO_LAYER) {
olLayers.push(FAO_LAYER)

return
}

const VectorLayer = getVectorOLLayer(layerToInsert.type, layerToInsert.zone, isBackoffice)
olLayers.push(VectorLayer)
})
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/features/AdministrativeZone/layers/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getLayerNameFromTypeAndZone } from '@features/AdministrativeZone/useCases/utils'
import TileLayer from 'ol/layer/Tile'
import { TileWMS } from 'ol/source'
import { createXYZ } from 'ol/tilegrid'

import { LayerProperties } from '../../../domain/entities/layers/constants'

import type { TileLayerWithName } from '../../../domain/types/layer'

export const FAO_LAYER = new TileLayer({
source: new TileWMS({
params: { FORMAT: 'image/png', LAYERS: 'monitorfish:fao_areas', STYLES: 'monitorfish:FAO style', TILED: true },
serverType: 'geoserver',
tileGrid: createXYZ({ tileSize: 512 }),
// Countries have transparency, so do not fade tiles:
transition: 0,
url: `${import.meta.env.FRONTEND_GEOSERVER_REMOTE_URL}/geoserver/monitorfish/wms`
})
}) as TileLayerWithName

FAO_LAYER.name = getLayerNameFromTypeAndZone(LayerProperties.FAO.code, undefined)
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,6 @@ export function getAdministrativeLayerStyle(type: string) {
}`
})
})
case LayerProperties.FAO.code:
return (feature: Feature | undefined) =>
new Style({
stroke: new Stroke({
color: '#767AB2',
width: 1
}),
text: new Text({
fill: new Fill({ color: THEME.color.gunMetal }),
font: '12px Marianne',
overflow: true,
stroke: new Stroke({ color: 'rgba(255,255,255,0.4)', width: 2 }),
text: `${
(LayerProperties.FAO.zoneNamePropertyKey && feature?.get(LayerProperties.FAO.zoneNamePropertyKey)) || ''
}`
})
})
case LayerProperties.AEM.code:
return (feature: Feature | undefined) =>
new Style({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Geoserver FAO style

The `fao_areas` layer is served as a Geoserver `wms` layer.

For `geowebcache` to be running under `/wms` routes, the `WMS` caching direct integration must be setup:
https://docs.geoserver.org/stable/en/user/geowebcache/webadmin/defaults.html#enable-direct-integration-with-geoserver-wms

The style (named `FAO style`) is defined as the following SLD:
```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<Name>FAO areas layer</Name>
<UserStyle>
<Name>FAO areas</Name>
<Title>FAO Areas</Title>
<FeatureTypeStyle>
<Rule>
<Name>Line</Name>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#767ab2</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
<Rule>
<Name>Text</Name>
<TextSymbolizer>
<Label>
<ogc:PropertyName>f_code</ogc:PropertyName>
</Label>
<Font>
<CssParameter name="font-size">12</CssParameter>
</Font>
<Halo>
<Fill>
<CssParameter name="fill">#ffffff</CssParameter>
</Fill>
</Halo>
<Fill>
<CssParameter name="fill">#282F3E</CssParameter>
<CssParameter name="fill-opacity">1</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
```
Loading