Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pygeoapi/provider/csv_.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# =================================================================
#
# Authors: Tom Kralidis <tomkralidis@gmail.com>
# Francesco Bartoli <xbartolone@gmail.com>
#
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2025 Francesco Bartoli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -138,6 +140,9 @@ def _load(self, offset=0, limit=10, resulttype='results',

if bbox:
LOGGER.debug('processing bbox parameter')
if len(bbox) > 4:
LOGGER.debug("bbox reduced to 4 elements")
bbox = bbox[:4]
data_ = filter(
lambda f: all(
[self._intersects(f, bbox)]), data_)
Expand Down
3 changes: 3 additions & 0 deletions pygeoapi/provider/geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _load(self, bbox=[], skip_geometry=None, properties=[],
# filter by bbox if set
if bbox:
LOGGER.debug('processing bbox parameter')
if len(bbox) > 4:
LOGGER.debug("bbox reduced to 4 elements")
bbox = bbox[:4]
data['features'] = [f for f in data['features'] if \
self._intersects(f['geometry'], bbox)] # noqa

Expand Down
3 changes: 3 additions & 0 deletions tests/provider/test_csv__provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def test_query(config):
results = p.query(bbox=[-75, 45, -64, 55])
assert len(results['features'][0]['properties']) == 2

results = p.query(bbox=[-75, 45, -64, 55, 0, 0])
assert len(results['features'][0]['properties']) == 2


def test_get_invalid_property(config):
"""Testing query for an invalid property name"""
Expand Down
5 changes: 5 additions & 0 deletions tests/provider/test_csw_provider.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# =================================================================
#
# Authors: Tom Kralidis <tomkralidis@gmail.com>
# Francesco Bartoli <xbartolone@gmail.com>
#
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2025 Francesco Bartoli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -109,6 +111,9 @@ def test_query(config):
results = p.query(bbox=[-10, 40, 0, 60])
assert len(results['features']) == 2

results = p.query(bbox=[-10, 40, 0, 60, 0, 0])
assert len(results['features']) == 2

results = p.query(properties=[('title', 'Maecenas enim')])
assert len(results['features']) == 1

Expand Down
5 changes: 5 additions & 0 deletions tests/provider/test_geojson_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def test_query(fixture, config):
assert results['numberMatched'] == 1
assert results['numberReturned'] == 1

results = p.query(bbox=[120, 10, 126, 11, 0, 0])
assert len(results['features']) == 1
assert results['numberMatched'] == 1
assert results['numberReturned'] == 1


def test_get(fixture, config):
p = GeoJSONProvider(config)
Expand Down
Loading