adminexpress
Retrieve administrative units for any location in France using longitude and latitude coordinates. Access commune, canton, department, region, and other administrative boundaries from Géoplateforme data.
Instructions
Renvoie les unités administratives (commune, canton, collectivite_territoriale, epci, departement, region, arrondissement) pour une position donnée par sa longitude et sa latitude (source : Géoplateforme (WFS, ADMINEXPRESS-COG.LATEST)).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lon | Yes | La longitude du point | |
| lat | Yes | La latitude du point |
Implementation Reference
- src/tools/AdminexpressTool.ts:25-28 (handler)The main handler function that executes the tool logic by calling the getAdminUnits helper with the provided longitude and latitude.async execute(input: AdminexpressInput) { logger.info(`adminexpress(${input.lon},${input.lat})...`); return getAdminUnits(input.lon, input.lat); }
- src/tools/AdminexpressTool.ts:14-23 (schema)Input schema definition using Zod validators for longitude (lon) and latitude (lat) parameters.schema = { lon: { type: z.number(), description: "La longitude du point", }, lat: { type: z.number(), description: "La latitude du point", }, };
- src/gpf/adminexpress.js:29-55 (helper)Helper function that performs the WFS query to retrieve administrative units intersecting the given coordinates from the ADMINEXPRESS-COG service.export async function getAdminUnits(lon, lat) { logger.info(`[adminexpress] getAdminUnits(${lon},${lat})...`); // note that EPSG:4326 means lat,lon order for GeoServer -> flipped coordinates... const cql_filter = `INTERSECTS(geometrie,Point(${lat} ${lon}))`; // TODO : avoid useless geometry retrieval at WFS level const url = 'https://data.geopf.fr/wfs?' + new URLSearchParams({ service: 'WFS', request: 'GetFeature', typeName: ADMINEXPRESS_TYPES.map((type) => { return `ADMINEXPRESS-COG.LATEST:${type}` }).join(','), outputFormat: 'application/json', cql_filter: cql_filter }).toString(); const featureCollection = await fetchJSON(url); return featureCollection.features.map((feature) => { // parse type from id (ex: "commune.3837") const type = feature.id.split('.')[0]; // ignore geometry and extend properties return Object.assign({ type: type, id: feature.id, bbox: feature.bbox }, feature.properties); }); }