Skip to content

Commit d6d256a

Browse files
committed
Merge branch 'feat-reload-official' of https://github.com/federal-geospatial-platform/pygeoapi into feat-reload-official
2 parents 3ee5907 + 7f090af commit d6d256a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+817
-1649
lines changed

.github/workflows/containers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
contents: read
2626
steps:
2727
- name: Check out the repo
28-
uses: actions/checkout@v3
28+
uses: actions/checkout@master
2929

3030
- name: Set up QEMU
3131
uses: docker/[email protected]

.github/workflows/docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
include:
2424
- python-version: '3.10'
2525
steps:
26-
- uses: actions/checkout@v2
27-
- uses: actions/setup-python@v2
26+
- uses: actions/checkout@master
27+
- uses: actions/setup-python@v5
2828
name: Setup Python ${{ matrix.python-version }}
2929
with:
3030
python-version: ${{ matrix.python-version }}

.github/workflows/flake8.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jobs:
77
flake8_py3:
88
runs-on: ubuntu-22.04
99
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-python@v3
10+
- uses: actions/checkout@master
11+
- uses: actions/setup-python@v5
1212
name: setup Python
1313
with:
1414
python-version: '3.10'

.github/workflows/main.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jobs:
3737
- name: Chown user
3838
run: |
3939
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
40-
- uses: actions/checkout@v2
41-
- uses: actions/setup-python@v2
40+
- uses: actions/checkout@master
41+
- uses: actions/setup-python@v5
4242
name: Setup Python ${{ matrix.python-version }}
4343
with:
4444
python-version: ${{ matrix.python-version }}
@@ -56,7 +56,7 @@ jobs:
5656
- name: Install and run Elasticsearch 📦
5757
uses: getong/[email protected]
5858
with:
59-
elasticsearch version: '8.3.1'
59+
elasticsearch version: '8.17.0'
6060
host port: 9200
6161
container port: 9200
6262
host node port: 9300
@@ -65,25 +65,25 @@ jobs:
6565
- name: Install and run OpenSearch 📦
6666
uses: esmarkowski/[email protected]
6767
with:
68-
version: 2.12.0
68+
version: 2.18.0
6969
security-disabled: true
7070
port: 9209
7171
- name: Install and run MongoDB
72-
uses: supercharge/mongodb-github-action@1.5.0
72+
uses: supercharge/mongodb-github-action@1.12.0
7373
with:
74-
mongodb-version: 4.4
74+
mongodb-version: '8.0.4'
7575
- name: Install and run SensorThingsAPI
7676
uses: cgs-earth/[email protected]
7777
- name: Install sqlite and gpkg dependencies
78-
uses: awalsh128/cache-apt-pkgs-action@latest
78+
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
7979
with:
8080
packages: libsqlite3-mod-spatialite
8181
version: 4.3.0a-6build1
8282
- name: Use ubuntuGIS unstable ppa
8383
run: sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt update
8484
shell: bash
8585
- name: Install GDAL with Python bindings
86-
uses: awalsh128/cache-apt-pkgs-action@latest
86+
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
8787
with:
8888
packages: gdal-bin libgdal-dev
8989
version: 3.8.4

docker/default.config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ server:
4646
cors: true
4747
pretty_print: true
4848
admin: ${PYGEOAPI_SERVER_ADMIN:-false}
49-
limit: 10
49+
limits:
50+
default_items: 10
51+
max_items: 50
5052
# templates: /path/to/templates
5153
map:
5254
url: https://tile.openstreetmap.org/{z}/{x}/{y}.png

docs/source/configuration.rst

+85-48
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ For more information related to API design rules (the ``api_rules`` property in
4949
gzip: false # default server config to gzip/compress responses to requests with gzip in the Accept-Encoding header
5050
cors: true # boolean on whether server should support CORS
5151
pretty_print: true # whether JSON responses should be pretty-printed
52-
limit: 10 # server limit on number of items to return
52+
53+
limits: # server limits on number of items to return. This property can also be defined at the resource level to override global server settings
54+
default_items: 50
55+
max_items: 1000
56+
max_distance_x: 25
57+
max_distance_y: 25
58+
max_distance_units: m
59+
on_exceed: throttle # throttle or error (default=throttle)
60+
5361
admin: false # whether to enable the Admin API
5462
5563
# optional configuration to specify a different set of templates for HTML pages. Recommend using absolute paths. Omit this to use the default provided templates
@@ -254,6 +262,41 @@ default.
254262
.. seealso::
255263
:ref:`plugins` for more information on plugins
256264

265+
Using environment variables
266+
---------------------------
267+
268+
pygeoapi configuration supports using system environment variables, which can be helpful
269+
for deploying into `12 factor <https://12factor.net/>`_ environments for example.
270+
271+
Below is an example of how to integrate system environment variables in pygeoapi.
272+
273+
.. code-block:: yaml
274+
275+
server:
276+
bind:
277+
host: ${MY_HOST}
278+
port: ${MY_PORT}
279+
280+
Multiple environment variables are supported as follows:
281+
282+
.. code-block:: yaml
283+
284+
data: ${MY_HOST}:${MY_PORT}
285+
286+
It is also possible to define a default value for a variable in case it does not exist in
287+
the environment using a syntax like: ``value: ${ENV_VAR:-the default}``
288+
289+
.. code-block:: yaml
290+
291+
server:
292+
bind:
293+
host: ${MY_HOST:-localhost}
294+
port: ${MY_PORT:-5000}
295+
metadata:
296+
identification:
297+
title:
298+
en: This is pygeoapi host ${MY_HOST} and port ${MY_PORT:-5000}, nice to meet you!
299+
257300
Adding links to collections
258301
---------------------------
259302

@@ -389,53 +432,6 @@ If omitted, no header will be added. Common names for this header are ``API-Vers
389432
Note that pygeoapi already adds a ``X-Powered-By`` header by default that includes the software version number.
390433

391434

392-
Validating the configuration
393-
----------------------------
394-
395-
To ensure your configuration is valid, pygeoapi provides a validation
396-
utility that can be run as follows:
397-
398-
.. code-block:: bash
399-
400-
pygeoapi config validate -c /path/to/my-pygeoapi-config.yml
401-
402-
403-
Using environment variables
404-
---------------------------
405-
406-
pygeoapi configuration supports using system environment variables, which can be helpful
407-
for deploying into `12 factor <https://12factor.net/>`_ environments for example.
408-
409-
Below is an example of how to integrate system environment variables in pygeoapi.
410-
411-
.. code-block:: yaml
412-
413-
server:
414-
bind:
415-
host: ${MY_HOST}
416-
port: ${MY_PORT}
417-
418-
Multiple environment variables are supported as follows:
419-
420-
.. code-block:: yaml
421-
422-
data: ${MY_HOST}:${MY_PORT}
423-
424-
It is also possible to define a default value for a variable in case it does not exist in
425-
the environment using a syntax like: ``value: ${ENV_VAR:-the default}``
426-
427-
.. code-block:: yaml
428-
429-
server:
430-
bind:
431-
host: ${MY_HOST:-localhost}
432-
port: ${MY_PORT:-5000}
433-
metadata:
434-
identification:
435-
title:
436-
en: This is pygeoapi host ${MY_HOST} and port ${MY_PORT:-5000}, nice to meet you!
437-
438-
439435
Hierarchical collections
440436
------------------------
441437

@@ -507,6 +503,36 @@ Examples:
507503
curl https://example.org/collections/lakes/items # only the name attribute is returned in properties
508504
curl https://example.org/collections/lakes/items/{item_id} # only the name attribute is returned in properties
509505
506+
Limiting data responses
507+
-----------------------
508+
509+
pygeoapi defines a ``limits`` configuration parameter that will allow a user to define default and maximum limits for multiple data types. This parameter is defined at the server level (``server.limits``) with the ability to override at resource level (``resources[*].limits``). An example of this setting is shown below:
510+
511+
.. code-block:: yaml
512+
513+
limits:
514+
default_items: 10 # applies to vector data
515+
max_items: 500 # applies to vector data
516+
max_distance_x: 123 # applies to all datasets
517+
max_distance_y: 456 # applies to all datasets
518+
max_distance_units: m # as per UCUM https://ucum.org/ucum#section-Tables-of-Terminal-Symbols
519+
on_exceed: error # one of error, throttle
520+
521+
The ``limits`` setting is applied as follows:
522+
523+
- can be defined at both the server and resources levels, with resource limits overriding server wide limits settings
524+
- ``on_exceed`` can be set to ``error`` or ``throttle`` (default). If a client specified limit exceeds those set by the server:
525+
- when set to ``error``, an exception is returned
526+
- when set to ``throttle`` the maximum data allowed by the collection/server/provider is returned
527+
528+
Vector data (features, records)
529+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
530+
- when a limit not specified by the client, ``limits.default_items`` can be used to set the result set size
531+
- when a limit is specified by the client, the minimum of the ``limit`` parameter and ``limits.max_items`` is calculated to set the result set size
532+
533+
Raster data (coverages, environmental data retrieval)
534+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
535+
- when a bbox or spatial subset is specified by the client, ``limits.max_distance_x``, ``limits.max_distance_y`` and ``limits.max_distance_units`` are used to determine whether a request has asked for more data than the collection is configured to provide and respond accordingly (via ``on_exceed``)
510536

511537
Linked Data
512538
-----------
@@ -638,6 +664,17 @@ deployment flexibility, the path can be specified with string interpolation of e
638664
The template ``tests/data/base.jsonld`` renders the unmodified JSON-LD. For more information on the capacities
639665
of Jinja2 templates, see :ref:`html-templating`.
640666

667+
Validating the configuration
668+
----------------------------
669+
670+
To ensure your configuration is valid, pygeoapi provides a validation
671+
utility that can be run as follows:
672+
673+
.. code-block:: bash
674+
675+
pygeoapi config validate -c /path/to/my-pygeoapi-config.yml
676+
677+
641678
Summary
642679
-------
643680

docs/source/cql.rst

+29-23
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
CQL support
44
===========
55

6+
OGC Common Query Language (`CQL2`_) is a generic language designed to provide enhanced query and subset/filtering to (primarily) feature and record data.
7+
68
Providers
79
---------
810

9-
As of now the available providers supported for CQL filtering are limited to :ref:`Elasticsearch <Elasticsearch>` and :ref:`PostgreSQL <PostgreSQL>`.
10-
11+
CQL2 support is implemented in various pygeoapi feature and record providers. See the :ref:`feature <ogcapi-features>` and :ref:`metadata <ogcapi-records>` provider sections
12+
for current provider support.
13+
1114
Limitations
1215
-----------
1316

14-
Support of CQL is limited to `Simple CQL filter <https://portal.ogc.org/files/96288#cql-core>`_ and thus it allows to query with the
17+
Support of CQL is limited to `Basic CQL2 <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-core>`_ and thus it allows to query with the
1518
following predicates:
1619

1720
* comparison predicates
@@ -21,20 +24,20 @@ following predicates:
2124
Formats
2225
-------
2326

24-
At the moment Elasticsearch supports only the CQL dialect with the JSON encoding `CQL-JSON <https://portal.ogc.org/files/96288#simple-cql-JSON>`_.
27+
Supported providers leverage the CQL2 dialect with the JSON encoding `CQL-JSON <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-json>`_.
2528

26-
PostgreSQL supports both CQL-JSON and CQL-text dialects, `CQL-JSON <https://portal.ogc.org/files/96288#simple-cql-JSON>`_ and `CQL-TEXT <https://portal.ogc.org/files/96288#simple-cql-text>`_
29+
PostgreSQL supports both `CQL2 JSON <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-json>`_ and `CQL text <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-text>`_ dialects.
2730

2831
Queries
2932
^^^^^^^
3033

3134
The PostgreSQL provider uses `pygeofilter <https://github.com/geopython/pygeofilter>`_ allowing a range of filter expressions, see examples for:
3235

33-
* `Comparison predicates <https://portal.ogc.org/files/96288#simple-cql_comparison-predicates>`_
34-
* `Spatial predicates <https://portal.ogc.org/files/96288#enhanced-spatial-operators>`_
35-
* `Temporal predicates <https://portal.ogc.org/files/96288#simple-cql_temporal>`_
36+
* `Comparison predicates (`Advanced <https://docs.ogc.org/is/21-065r2/21-065r2.html#advanced-comparison-operators>`_, `Case-insensitive <https://docs.ogc.org/is/21-065r2/21-065r2.html#case-insensitive-comparison>`_)
37+
* `Spatial predicates <https://docs.ogc.org/is/21-065r2/21-065r2.html#spatial-functions>`_
38+
* `Temporal predicates <https://docs.ogc.org/is/21-065r2/21-065r2.html#temporal-functions>`_
3639

37-
Using Elasticsearch the following type of queries are supported right now:
40+
Using Elasticsearch the following type of queries are supported currently:
3841

3942
* ``between`` predicate query
4043
* Logical ``and`` query with ``between`` and ``eq`` expression
@@ -59,11 +62,11 @@ A ``BETWEEN`` example for a specific property through an HTTP POST request:
5962
curl --location --request POST 'http://localhost:5000/collections/nhsl_hazard_threat_all_indicators_s_bc/items?f=json&limit=50&filter-lang=cql-json' \
6063
--header 'Content-Type: application/query-cql-json' \
6164
--data-raw '{
62-
"between": {
63-
"value": { "property": "properties.MHn_Intensity" },
64-
"lower": 0.59,
65-
"upper": 0.60
66-
}
65+
"op": "between",
66+
"args": [
67+
{"property": "properties.MHn_Intensity"},
68+
[0.59, 0.60]
69+
]
6770
}'
6871
6972
Or
@@ -73,11 +76,11 @@ Or
7376
curl --location --request POST 'http://localhost:5000/collections/recentearthquakes/items?f=json&limit=10&filter-lang=cql-json'
7477
--header 'Content-Type: application/query-cql-json'
7578
--data-raw '{
76-
"between":{
77-
"value":{"property": "ml"},
78-
"lower":4,
79-
"upper":4.5
80-
}
79+
"op": "between",
80+
"args": [
81+
{"property": "ml"},
82+
[4, 4.5]
83+
]
8184
}'
8285
8386
The same ``BETWEEN`` query using HTTP GET request formatted as CQL text and URL encoded as below:
@@ -93,7 +96,11 @@ An ``EQUALS`` example for a specific property:
9396
curl --location --request POST 'http://localhost:5000/collections/recentearthquakes/items?f=json&limit=10&filter-lang=cql-json'
9497
--header 'Content-Type: application/query-cql-json'
9598
--data-raw '{
96-
"eq":[{"property": "user_entered"},"APBE"]
99+
"op": "=",
100+
"args": [
101+
{"property": "user_entered"},
102+
"APBE"
103+
]
97104
}'
98105
99106
A ``CROSSES`` example via an HTTP GET request. The CQL text is passed via the ``filter`` parameter.
@@ -115,7 +122,6 @@ The same example, but this time providing a geometry in EWKT format:
115122
116123
curl "http://localhost:5000/collections/beni/items?filter=DWITHIN(geometry,SRID=3857;POINT(1392921%205145517),100,meters)"
117124
118-
119-
120-
121125
Note that the CQL text has been URL encoded. This is required in curl commands but when entering in a browser, plain text can be used e.g. ``CROSSES(foo_geom, LINESTRING(28 -2, 30 -4))``.
126+
127+
.. _`CQL2`: https://docs.ogc.org/is/21-065r2/21-065r2.html

docs/source/data-publishing/ogcapi-features.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ parameters.
3131
`Parquet`_,✅/✅,results/hits,✅,✅,❌,✅,❌,❌,✅
3232
`PostgreSQL`_,✅/✅,results/hits,✅,✅,✅,✅,✅,✅,✅
3333
`SQLiteGPKG`_,✅/❌,results/hits,✅,❌,❌,✅,❌,❌,✅
34-
`SensorThings API`_,✅/✅,results/hits,✅,✅,✅,✅,❌,,✅
34+
`SensorThings API`_,✅/✅,results/hits,✅,✅,✅,✅,❌,,✅
3535
`Socrata`_,✅/✅,results/hits,✅,✅,✅,✅,❌,❌,✅
3636
`TinyDB`_,✅/✅,results/hits,✅,✅,✅,✅,❌,✅,✅
3737

0 commit comments

Comments
 (0)