Skip to content
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
2 changes: 1 addition & 1 deletion .env.dev.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ GEOSERVER_HOST=localhost
################################################################################
# PostgreSQL

DB_VERSION=pg17-postgis3.6.1-timescale2.24.0
DB_VERSION=pg17-postgis3.6.1-timescale2.24.0-contrib
DB_DATA_VOLUME_NAME=db-data-17
POSTGRES_PORT=5432
POSTGRES_USER=postgres
Expand Down
2 changes: 1 addition & 1 deletion .env.test.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ MONITORENV_JVM_OPTIONS=
################################################################################
# PostgreSQL

DB_VERSION=pg17-postgis3.6.1-timescale2.24.0
DB_VERSION=pg17-postgis3.6.1-timescale2.24.0-contrib
DB_DATA_VOLUME_NAME=db-data-17
POSTGRES_PORT=5432
POSTGRES_USER=postgres
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE EXTENSION IF NOT EXISTS unaccent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE MATERIALIZED VIEW search_beaches AS
SELECT id,
official_name,
name,
geom,
postcode,
unaccent(name) as unaccent_name,
unaccent(official_name) as unaccent_official_name
from beaches;
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ INSERT INTO public.beaches
VALUES (2009, '0104000020E610000001000000010100000079AA9E70989C4B40B89C97A0AE0D35C0', 'Plage Des Roches Noires',
'Saint-Paul', '97460', '97415');


REFRESH MATERIALIZED VIEW search_beaches;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class AbstractDBTests {
@JvmStatic
val container: GenericContainer<Nothing> =
GenericContainer<Nothing>(
"ghcr.io/mtes-mct/monitorenv/monitorenv-database:pg17-postgis3.6.1-timescale2.24.0",
"ghcr.io/mtes-mct/monitorenv/monitorenv-database:pg17-postgis3.6.1-timescale2.24.0-contrib",
).apply {
withExposedPorts(5432)
withEnv("POSTGRES_DB", "testdb")
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/mappings/geoserver/beaches-search.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"equalTo": "GetFeature"
},
"typename": {
"equalTo": "monitorenv:beaches"
"equalTo": "monitorenv:search_beaches"
},
"outputFormat": {
"equalTo": "application/json"
Expand All @@ -33,6 +33,6 @@
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "*"
},
"body": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"id\":\"beaches.789\",\"geometry\":{\"type\":\"MultiPoint\",\"coordinates\":[[-3.2027,47.6536]]},\"geometry_name\":\"geom\",\"properties\":{\"id\":789,\"name\":\"Plan D'eau\",\"official_name\":\"Étel\",\"postcode\":\"56410\",\"insee\":\"56055\"},\"bbox\":[-3.2027,47.6536,-3.2027,47.6536]}],\"totalFeatures\":1,\"numberMatched\":1,\"numberReturned\":1,\"timeStamp\":\"2025-08-26T07:12:52.375Z\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"urn:ogc:def:crs:EPSG::4326\"}},\"bbox\":[-3.2027,47.6536,-3.2027,47.6536]}"
"body": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"id\":\"search_beaches.789\",\"geometry\":{\"type\":\"MultiPoint\",\"coordinates\":[[-3.2027,47.6536]]},\"geometry_name\":\"geom\",\"properties\":{\"id\":789,\"name\":\"Plan D'eau\",\"official_name\":\"Étel\",\"postcode\":\"56410\",\"insee\":\"56055\"},\"bbox\":[-3.2027,47.6536,-3.2027,47.6536]}],\"totalFeatures\":1,\"numberMatched\":1,\"numberReturned\":1,\"timeStamp\":\"2025-08-26T07:12:52.375Z\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"urn:ogc:def:crs:EPSG::4326\"}},\"bbox\":[-3.2027,47.6536,-3.2027,47.6536]}"
}
}
6 changes: 4 additions & 2 deletions frontend/src/api/beachesAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ export const getBeachesFromAPI = async (query: string | undefined) => {
const conditions = searchQueries.map(searchQuery => {
const sanitizedQuery = sanitizeQuery(searchQuery)

return `(name ILIKE '%${sanitizedQuery}%' OR official_name ILIKE '%${sanitizedQuery}%' OR postcode ILIKE '%${sanitizedQuery}%')`
return `(unaccent_name ILIKE '%${sanitizedQuery}%' OR unaccent_official_name ILIKE '%${sanitizedQuery}%' OR postcode ILIKE '%${sanitizedQuery}%')`
})
const cqlFilter = conditions.join(' AND ')

return fetch(
`${geoserverURL}/geoserver/wfs?service=WFS&` +
`version=1.1.0&request=GetFeature&typename=${
import.meta.env.FRONTEND_GEOSERVER_NAMESPACE
}:beaches&outputFormat=application/json&srsname=${WSG84_PROJECTION}&CQL_FILTER=${encodeURIComponent(cqlFilter)}`
}:search_beaches&outputFormat=application/json&srsname=${WSG84_PROJECTION}&CQL_FILTER=${encodeURIComponent(
cqlFilter
)}`
)
.then(response => {
if (response.status === OK) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/LocateOnMap/SearchLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function SearchLocation() {
}
let extent: Extent | undefined

if (location.id.startsWith('beaches')) {
if (location.id.startsWith('search_beaches')) {
const selectedBeach = beaches.find(beach => beach.id === location.id)
if (selectedBeach) {
extent = transformExtent(selectedBeach.bbox, WSG84_PROJECTION, OPENLAYERS_PROJECTION)
Expand Down
6 changes: 3 additions & 3 deletions infra/init/geoserver_init_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ EOF
curl -v -u ${GEOSERVER_ADMIN_USER}:${GEOSERVER_ADMIN_PASSWORD} -X POST http://${GEOSERVER_HOST}:${GEOSERVER_PORT}/geoserver/rest/workspaces/monitorenv/datastores/monitorenv_postgis/featuretypes -H "accept: text/html" -H "content-type: application/json" -d @- << EOF
{
"featureType": {
"name": "beaches",
"nativeName": "beaches",
"title": "beaches",
"name": "search_beaches",
"nativeName": "search_beaches",
"title": "search_beaches",
"nativeCRS": "EPSG:4326",
"srs": "EPSG:4326",
"enabled": true,
Expand Down
Loading