Coder Social home page Coder Social logo

Comments (7)

jorgejesus avatar jorgejesus commented on July 18, 2024

Use WFS2.0 as data source for pygeoapi

from pygeoapi.

tomkralidis avatar tomkralidis commented on July 18, 2024

+1 great feature! Considerations:

  • we can use OWSLib’s WFS functionality to interact with WFS 1 or 2 sources
  • we can also use OWSLib’s Filter XML functionality to convert WFS 3 property filters into WFS 1/2 Filter XML. This may get tricky depending on the underlying WFS 1/2 implementation
  • the devil will be in the WFS 1/2 GetFeature responses. OWSLib simply returns string/XML object representations which would need to be converted into GeoJSON. Suggest we start with common WFS 1/2 implementations (MapServer, GeoServer, others?)

from pygeoapi.

jorgejesus avatar jorgejesus commented on July 18, 2024

from pygeoapi.

justb4 avatar justb4 commented on July 18, 2024

Think this can be solved in a compact way with a single OGRProvider: a PyGeoAPI Provider that uses the GDAL/OGR Python bindings. Did some tests with both GeoServer and MapServer WFS v2 backends like from PDOK (Dutch National SDI). Many of the WFS-FES capabilities can be supported directly (if backend supports WFS v2):

  • result type hits: feature count
  • paging: translates to WFS paging with configurable pagesize
  • spatial filtering: e.g. bounding box or any other
  • attribute filtering, including get-feature-by-id: e.g. get feature by (gml) id

Advantages are:

  • no need for GML request construction (like Filters) and response parsing and GML-GeoJSON mapping
  • support not just WFS v2 but (m)any OGR source-types like GPKG, Shapefile, FGDB etc
  • Proxy support for URL-based backends
  • multiple auth methods support for URL-based backends

Things to consider:

  • OGR WFS Driver may issue WFS GetCapabilities request on each Open() call (need investigation)
  • the regular WFS v1, v2 performance considerations like complex filters bringing a WFS down

Software Design consideration:

  • Develop a single OGRProvider as a one-in-all Provider, or as an ABC with specialized OGRProvider-derived classes like OGRWFSProvider, OGRShapefileProvider etc.

I would aim first for OGRProvider with specialized Driver/OGRSource-type-specific helper-classes.
We do something very similar within a Stetl OGRInput ETL class. Main difference (per Source-type) is really on per-OGR-Driver-specific Source options (next to standard GDAL/OGR options). We can catch this within the PGA config YAML like:

                        .
                        .
    provider:
        name: OGR
        data:
            source_type: WFS
            source: WFS:http://geodata.nationaalgeoregister.nl/rdinfo/wfs?
            source_options:
                VERSION: 2.0.0
                OGR_WFS_PAGING_ALLOWED: YES
                OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO
             gdal_ogr_options:
                GDAL_CACHEMAX: 64
                GDAL_HTTP_PROXY: (optional proxy)
                GDAL_PROXY_AUTH: (optional auth for remote WFS)
                CPL_DEBUG: NO
        id_field: gml_id
        layer: rdinfo:stations
                        .
                        .

    provider:
        name: OGR
        data:
            source_type: ESRI Shapefile
            source: tests/data/rdinfo.shp
            source_options:
                        .
            gdal_ogr_options:
                GDAL_CACHEMAX: 64
        id_field: fid
        layer: stations

I can take stab at this, would be nice to have something running to e.g. wrap all PDOK WFS-es.

refs:

from pygeoapi.

tomkralidis avatar tomkralidis commented on July 18, 2024

Thanks @justb4. This approach works. I'm glad the plugin framework is flexible enough to encompass an OGR driver. In one way, OGR can replace every other provider that implements the same thing. It will be good to have them all, and let them mature/evolve over time.

from pygeoapi.

justb4 avatar justb4 commented on July 18, 2024

update: OGR Provider can even do (paged) fetch from ESRI FeatureServers!

from pygeoapi.

justb4 avatar justb4 commented on July 18, 2024

Think we're done with OGRProvider for WFS2 backends. Tested with GeoServer, MapServer and deegree WFSs (see tests), including bbox queries. Other OGR backends (Drivers) work as well like GPKG, ESRI Shapefile, ESRI FeatureServer, except for paging (will need to use OGR SQL for most). Will open separate issue(s) for those.

So closing here, re-open if still issues with WFS2 OGR backends.

from pygeoapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.