Skip to content

Commit f98d5f9

Browse files
authored
Merge pull request geopython#2209 from geopython/tinydb-query-nogeom
TinyDB: fix spatial queries against null geometries
2 parents 0a7bb16 + 402a792 commit f98d5f9

File tree

5 files changed

+414
-5
lines changed

5 files changed

+414
-5
lines changed

pygeoapi/provider/tinydb_.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Authors: Tom Kralidis <tomkralidis@gmail.com>
44
#
5-
# Copyright (c) 2025 Tom Kralidis
5+
# Copyright (c) 2026 Tom Kralidis
66
#
77
# Permission is hereby granted, free of charge, to any person
88
# obtaining a copy of this software and associated documentation
@@ -448,7 +448,7 @@ def __repr__(self):
448448
return f'<TinyDBCatalogueProvider> {self.data}'
449449

450450

451-
def bbox_intersects(record_geometry, input_bbox):
451+
def bbox_intersects(record_geometry, input_bbox) -> bool:
452452
"""
453453
Manual bbox intersection calculation
454454
@@ -458,7 +458,15 @@ def bbox_intersects(record_geometry, input_bbox):
458458
:returns: `bool` of whether the record_bbox intersects input_bbox
459459
"""
460460

461-
bbox1 = list(shape(record_geometry).bounds)
461+
if record_geometry is None:
462+
LOGGER.debug('Record geometry is none; skipping')
463+
return False
464+
465+
try:
466+
bbox1 = list(shape(record_geometry).bounds)
467+
except Exception as err:
468+
LOGGER.debug(f'Invalid geometry: {err}')
469+
return False
462470

463471
bbox2 = [float(c) for c in input_bbox.split(',')]
464472

tests/data/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ This directory provides test data to demonstrate functionality.
106106
- source: [Canadian National Water Data Archive](https://www.canada.ca/en/environment-climate-change/services/water-overview/quantity/monitoring/survey/data-products-services/national-archive-hydat.html) as extracted from the [MSC GeoMet OGC API](https://eccc-msc.github.io/open-data/msc-geomet/web-services_en/#ogc-api-features) service
107107
- URL: https://www.canada.ca/en/environment-climate-change/services/water-overview/quantity/monitoring/survey/data-products-services/national-archive-hydat.html
108108
- License: https://eccc-msc.github.io/open-data/licence/readme_en
109+
110+
### `dutch-nationaalgeoregister/sample-records.tinydb`
111+
- source: Dutch National Georegister
112+
- URL: https://nationaalgeoregister.nl
113+
- License: CC0: https://creativecommons.org/share-your-work/public-domain/cc0

0 commit comments

Comments
 (0)