WFS module for farmOS.
- Only supports WFS 1.1.0 / GML 3.1.1 currently
- Only supports features with single geometries of the types; point, polygon, or line string
- Only supports querying/updating/deleting by simple filters on BBOX or feature id - more complex OGC Filter operations may be supported in the future
- Only supports the EPSG:4326 spatial reference system (SRS) which farmOS uses - QGIS and similar software generally supports reprojection of data sources into other SRS'
- Only supports PHP >= 7.4 - earlier versions will not work
- Only tested against the farmOS 2.x branch - for farmOS 1.x see farmOS_wfs-7.x-1.x
- Only tested with QGIS 3.16 - earlier versions may work, but no promises
Use Composer and Drush to install farmOS_wfs in farmOS 2.x;
composer require drupal/farmos_wfs drush en farmos_wfs
Available released versions can be viewed at https://www.drupal.org/project/farmos_wfs/releases
farmOS0-oauth2-resource-owner(Name as desired)
- Grant Flow: Resource Owner
- Token URL:
- Client ID:
FarmOS0(Name as desired)
- Authentication Config: Choose the OAuth2 configuration created above
- Click 'Connect' and add the desired layers to your map!
The farmOS_wfs module allows bidirectional integration between farmOS and GIS with farmOS as the "source of truth" for asset data. This means complex mapping/geospatial tasks can be accomplished using QGIS and always up-to-date data directly from farmOS. Without farmOS_wfs, doing something similar would involve importing/exporting data between farmOS/GIS formats which would make it hard to maintain a single authoritative data model.
farmOS allows any asset to have arbitrary geometry or even collections of geometries, however QGIS - and I believe most GIS tools - expect the geometry of features in a feature type to be homogeneous. The WFS specification does allow for features with geometry types like GeometryCollection or MultiGeometry, but then these wouldn't be easily viewable or editable. farmOS_wfs therefore makes the pragmatic choice of serving different geometry types as separate layers.
These are fields which farmOS/Drupal reports as read-only. Attempts to set values for such fields is not permitted through farmOS_wfs and will produce an error. Generally these fields are also populated automatically which means they may change as a result of committing changes via farmOS_wfs, but the new value will not appear until the feature is next fetched from farmOS.
farmOS maintains the validity of asset references. Certain assets - especially non-fixed ones - will have movement/location logs referencing them. Those logs would need to be deleted before the asset could be deleted.
- Surface the
locationfield - this needs more thought since the asset reference wouldn't be easily editable and a read-only name would be of limited utility
- Use database transactions for committing changes to assets
- Support more complex OGC Filter queries
- Support additional WFS versions - most importantly WFS 2.0.0 to get full-featured pagination
- Detect when PostGIS spatial indices exist on the Geofield columns and switch to using PostGIS
ST_queries - relevant https://www.drupal.org/project/geofield/issues/2969564 & https://www.drupal.org/project/geofield_postgis
- Consider adding support for MultiPoint, MultiLineString, and MultiPolygon feature layers
- Consider adding geometry agnostic feature layers only parameterized by the asset type
- Add tests for OpenLayers as a client
docker/ directory of this repository run;
cp docker-compose.pgsql.yml docker-compose.yml docker-compose up -d
Once the command completes, farmOS should be running at http://localhost:80 with the farmOS_wfs module installed. The test site's username and password are 'root' and 'test' respectively.
docker/ directory with the above development environment started;
docker build -t qgis_test_harness qgis_test_harness docker run --rm -it --name qgis --network=docker_default -v $(pwd)'/qgis_tests:/tests_directory' qgis_test_harness:latest ./run_tests.sh
Running a single test:
docker run --rm -it --name qgis --network=docker_default -v $(pwd)'/qgis_tests:/tests_directory' qgis_test_harness:latest ./run_tests.sh test_suite/test_cases/qgis_basic_crud_test.py::QgisBasicCrudTest::test_qgis_create_line_string_water_asset
Running all 'non-point' qgis tests:
docker run --rm -i --name qgis --network=docker_default -v $(pwd)'/qgis_tests:/tests_directory' qgis_test_harness:latest ./run_tests.sh -k 'qgis and not point'
Arguments are passed as-is to pytest. See https://docs.pytest.org/en/stable/usage.html#specifying-tests-selecting-tests for more information.
autopep8 --in-place --recursive docker/qgis_tests/