Repository navigation
Description
The need
Adding a layer from a WFS downloads the whole layer, wherever the map is. National mapping agencies publish their boundaries this way, and a whole layer can be far larger than the area wanted.
Brazil's IBGE is an example. Its GeoServer (https://geoservicos.ibge.gov.br/geoserver/wfs) publishes the municipalities as CGMAT:qg_2024_030_munic, one layer for each year from 2018 to 2025. To map one state, Piauí, with the map zoomed to it:
rustgis-cli run --cmd 'service.add={"url":"https://geoservicos.ibge.gov.br/geoserver/wfs","type":"wfs","layer":"CGMAT:qg_2024_030_munic","bbox":[-45.99,-10.93,-40.37,-2.74]}'- RustGIS asks for all 5,570 municipalities of Brazil:
GetFeature&TYPENAMES=CGMAT:qg_2024_030_munic&…&COUNT=50000, with noBBOX. - That answer is 467 MB and took 75 s here, so
service.addstops at the 60 s limit (BLOCKING_TIMEOUT) and nothing is added. This was run from the MCP server; the CLI, scripts and the AI Assistant go through the same command. - The same request with the box (
&BBOX=-45.99,-10.93,-40.37,-2.74,urn:ogc:def:crs:OGC:1.3:CRS84) is 21 MB and took 5 s: Piauí's 224 municipalities and their neighbours, 472 in all. bboxis inservice.add's parameters, but only WCS coverages use it (coverage_areaincrates/engine/src/cmd/service.rs). For features, the address built from the capabilities (wfs()incrates/data/src/ogc.rs) is fetched as it is.- Today the way around it is to write the GetFeature address by hand with a server-specific filter (
&CQL_FILTER=sigla_uf='PI') and add it withlayer.addUrl. Few users will know to do that.
OGC API Features collections (…/items?limit=10000&f=json) and ArcGIS feature layers (…/query?where=1%3D1&…) are fetched whole in the same way.
Proposal
Feature layers are asked for over an area, as WCS coverages already are: the map's view by default, a bbox given, or "full" for the whole layer as today.
rustgis-cli run --cmd 'map.zoomToExtent={"extent":[-45.99,-10.93,-40.37,-2.74]}' --cmd 'service.add={"url":"https://geoservicos.ibge.gov.br/geoserver/wfs","layer":"CGMAT:qg_2024_030_munic"}'Choices in this proposal
- The view by default, as for WCS.
service.addalready readsbboxwith the same meaning for coverages (catalogs::area:[west, south, east, north]or"view", the default). Features follow it, and"full"keeps today's behaviour. On a world view the box is the world, so a small layer comes whole as before. - The box goes into the request, in each service's own terms:
-
WFS:
BBOX=w,s,e,n,urn:ogc:def:crs:OGC:1.3:CRS84when the type offers CRS84, the coordinate system already chosen forSRSNAME. Otherwise:- WFS 1.1 and 2.0:
BBOX=s,w,n,e,urn:ogc:def:crs:EPSG::4326, latitude first. The URN fixes the axis order, where a bareEPSG:4326is read either way by different servers. - WFS 1.0:
BBOX=w,s,e,n.
IBGE's GeoServer answered both forms with the same 472 features.
- WFS 1.1 and 2.0:
-
OGC API Features:
bbox=w,s,e,n, longitude first by the standard. The server'snextlinks keep it. -
ArcGIS:
geometry=w,s,e,n&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects.
-
- In one helper in
rustgis_data::ogcthat adds the box to anOffer::Featuresaddress, used byservice.addand by the desktop dialog. The dialog (serviceui::add_layer_from) downloads the offer's address in the background as From URL… does, and passes the view, as it already does for coverages. - Features that cross the box come whole, as the services return them. The layer holds every feature that touches the area, not a clipped copy.
- The layer says it is partial. The result notes "features in the map's area; bbox "full" for the whole layer". The view isn't changed after adding: today
service.addzooms to the whole layer's bounds, which would show the user an empty country. - Across the antimeridian, the whole layer is asked for, as
catalog.searchdoes. - The limits stay as they are: 50,000 features for WFS (
FEATURE_LIMIT), 100,000 or a minute for OGC API pages, 512 MB a download (MAX_DOWNLOAD). With the box they are reached far less often.
Out of scope
- Attribute filters (CQL, OGC API
filter, ArcGISwhere). They differ from server to server; the box is in every standard. - Feature layers from the Web Data catalogs (
webdataui), which list their own datasets. - A "Refresh for the current view" for a layer already added.
Plan
One PR:
- the helper and its unit tests: each service, both axis orders, the antimeridian;
service.addwithbboxfor features;- the dialog;
- the docs (
data-formats.md, the WFS and OGC API rows;data.md).
I can open it if this is welcome.
Activity
deniial00 commentedon Oct 24, 2026
I am unsure if this should be the default. Can you check how other programs handle WFS?
elpidioassinaturas commentedon Oct 24, 2026
Good point. I checked, and none of the three makes the view the default:
BBOX(driver).So they read the whole layer by default and offer the area as an option. They bound the cost in other ways: QGIS reads in the background, and ArcGIS Pro caps the count.
I'll change the proposal to match:
service.add. Nothing changes for anyone who doesn't ask for an area.service.addsends thebboxit's given (a box or"view"). Today it accepts one and ignores it for features.service.addruns past its 60 s, the error suggests"bbox"rather than only Add Data › From URL. That is the IBGE case: 467 MB for all of Brazil, 21 MB for one state's box.If that suits you, I'll open it as one PR.
deniial00 commentedon Oct 25, 2026
Sounds good to me!
Services: an OGC API address with bbox-crs is left as it is (opengeos…
Services: the dialog asks for the view's area for a feature layer only (
Services: ask a WFS, OGC API or ArcGIS feature layer for an area only (…
Services: tests for /items in any case and for the timeout hint (open…
Services: follow-ups to #924 (a plainer note, /items in any case, the…