Skip to content

[Feature]: Feature services: ask for the map's area, not the whole layer (WFS, OGC API Features, ArcGIS) #819

Closed

Description

@elpidioassinaturas

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 no BBOX.
  • That answer is 467 MB and took 75 s here, so service.add stops 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.
  • bbox is in service.add's parameters, but only WCS coverages use it (coverage_area in crates/engine/src/cmd/service.rs). For features, the address built from the capabilities (wfs() in crates/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 with layer.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.add already reads bbox with 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:CRS84 when the type offers CRS84, the coordinate system already chosen for SRSNAME. 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 bare EPSG:4326 is 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.

    • OGC API Features: bbox=w,s,e,n, longitude first by the standard. The server's next links keep it.

    • ArcGIS: geometry=w,s,e,n&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects.

  • In one helper in rustgis_data::ogc that adds the box to an Offer::Features address, used by service.add and 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.add zooms 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.search does.
  • 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, ArcGIS where). 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.add with bbox for 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

  1. deniial00 commented on Oct 24, 2026

    @deniial00
    Member

    I am unsure if this should be the default. Can you check how other programs handle WFS?

  2. elpidioassinaturas commented on Oct 24, 2026

    @elpidioassinaturas
    ContributorAuthor

    Good point. I checked, and none of the three makes the view the default:

    • QGIS: a WFS layer is downloaded whole by default, in the background, with paging, an on-disk cache and progressive drawing. Only request features overlapping the view extent is an option of the add dialog, and the connection's Max. number of features is unlimited by default (manual).
    • ArcGIS Pro: Use Spatial Extent is off by default ("Do not spatially limit the features added to the map. This is the default."). It can borrow the current visible extent or a layer's. The whole request is capped at 3,000 features by default "to avoid performance issues" (use, add).
    • GDAL/OGR: the driver reads the whole layer, page by page in WFS 2.0. A spatial filter set on the layer is sent to the server as 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:

    • The whole layer stays the default, in the dialog and in service.add. Nothing changes for anyone who doesn't ask for an area.
    • An area when asked for:
      • service.add sends the bbox it's given (a box or "view"). Today it accepts one and ignores it for features.
      • The dialog gets Only the map's area, off by default, as QGIS and ArcGIS Pro have it.
      • The requests, the antimeridian and the limits are as described above.
    • A whole layer too slow for a script says what to do: when service.add runs 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.

  3. deniial00 commented on Oct 25, 2026

    @deniial00
    Member

    Sounds good to me!

  4. added
    enhancement
    on Oct 25, 2026
  5. added a commit that references this issue on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions