From 42a419299b714be66f2f862f87a7503efe24d235 Mon Sep 17 00:00:00 2001 From: Denis Rykov Date: Tue, 6 Sep 2022 13:12:20 +0200 Subject: [PATCH] PR #975 - OGR Stop using GetFID - fix for #974 --- pygeoapi/provider/ogr.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pygeoapi/provider/ogr.py b/pygeoapi/provider/ogr.py index 30431ae..47ee52a 100644 --- a/pygeoapi/provider/ogr.py +++ b/pygeoapi/provider/ogr.py @@ -472,10 +472,15 @@ class OGRProvider(BaseProvider): if skip_geometry: json_feature['geometry'] = None try: - json_feature['id'] = json_feature['properties'].pop(self.id_field) - except Exception as err: - LOGGER.error(err) - json_feature['id'] = ogr_feature.GetFID() + json_feature['id'] = json_feature['properties'].pop( + self.id_field, json_feature['id'] + ) + except KeyError as err: + LOGGER.error( + "Cannot use configured id_field nor fid as id, err={}".format( + err + ) + ) return json_feature