Skip to content

Commit 14ca916

Browse files
authored
feat: add WMS GetFeatureInfo identify support (#97)
* feat: add WMS GetFeatureInfo identify support Enable the identify tool for WMS layers by issuing GetFeatureInfo requests and rendering the response in the identify popup. JSON, HTML, and plain-text info formats are supported, with a dev-server proxy to avoid cross-origin issues. * Address review feedback - Compute WMS GetFeatureInfo X/Y from a small query box centered on the click lng/lat so identify works in rotated/pitched views - Remove the unreachable {bbox-epsg-3857} bypass in WMS query encoding - Limit isWmsLayer to layer.type === "wms" to match LayerPanel's canIdentify - Read layer.source.version and switch SRS/CRS for WMS 1.1.1 vs 1.3.0 - Set FEATURE_COUNT=1 since only the first feature is displayed - Honor a configured layer.source.infoFormat to avoid extra round-trips - Require a URL/sourcePath before enabling identify for WMS layers - Treat DOMException AbortError as an abort in isAbortError - Document the dev-only WMS proxy / production CORS limitation * Address Claude review feedback - Guard the WMS identify .catch() with abortController.signal.aborted so a superseded request can no longer null the active controller or overwrite the current popup - Treat an empty GeoJSON features array as a successful "no hit" instead of a parse failure, avoiding extra format-probe requests - Bail out of WMS response parsing when the signal aborts after the body read - Parse the WMS endpoint via URL so control params override pre-existing duplicates and land before any fragment - Mirror stringSource trimming in LayerPanel canIdentify so blank WMS URLs no longer enable identify * Address Claude review feedback - Require a non-blank source.layers (not just a URL) before enabling WMS identify, so a layer missing LAYERS no longer shows an enabled button - Sniff bare JSON arrays in addition to objects when content-type is missing - Keep probing remaining info formats when a body arrives in an unexpected format instead of returning the mismatched text early - Make WMS FEATURE_COUNT configurable via source.featureCount (default 1)
1 parent 7a408be commit 14ca916

2 files changed

Lines changed: 350 additions & 18 deletions

File tree

apps/geolibre-desktop/src/components/panels/LayerPanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ export function LayerPanel({
221221
{visibleLayers.map((layer, displayIndex) => {
222222
const canIdentify =
223223
layer.type === "geojson" ||
224+
(layer.type === "wms" &&
225+
typeof layer.source.layers === "string" &&
226+
Boolean(layer.source.layers.trim()) &&
227+
Boolean(
228+
(typeof layer.source.url === "string" &&
229+
layer.source.url.trim()) ||
230+
layer.sourcePath,
231+
)) ||
224232
layer.type === "vector-tiles" ||
225233
(layer.type === "mbtiles" &&
226234
layer.metadata.tileType === "vector") ||
@@ -363,14 +371,14 @@ export function LayerPanel({
363371
? identifyActive
364372
? "Deactivate identify"
365373
: "Identify features"
366-
: "Identify is only available for vector layers"
374+
: "Identify is only available for vector and WMS layers"
367375
}
368376
aria-label={
369377
canIdentify
370378
? identifyActive
371379
? "Deactivate identify"
372380
: "Identify features"
373-
: "Identify is only available for vector layers"
381+
: "Identify is only available for vector and WMS layers"
374382
}
375383
disabled={!canIdentify}
376384
onClick={(e) => {

0 commit comments

Comments
 (0)