Skip to content

Commit

Permalink
Merge pull request #1743 from girder/harden-geojson-parsing
Browse files Browse the repository at this point in the history
Harden the geojson annotation parser
  • Loading branch information
manthey authored Dec 13, 2024
2 parents a5b46d1 + 7d373b8 commit 23c0a55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 1.30.6

### Improvements

- Harden the geojson annotation parser ([#1743](../../pull/1743))

## 1.30.5

### Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def __init__(self, geojson):
self._annotation = {'elements': self._elements}
self._parseFeature(geojson)

def _parseFeature(self, geoelem):
def _parseFeature(self, geoelem): # noqa
if isinstance(geoelem, (list, tuple)):
for entry in geoelem:
self._parseFeature(entry)
Expand All @@ -268,8 +268,11 @@ def _parseFeature(self, geoelem):
if not isinstance(element['label'], dict):
element['label'] = {'value': element['label']}
element['label']['value'] = str(element['label']['value'])
if 'annotation' in geoelem.get('properties', {}):
self._annotation.update(geoelem['properties']['annotation'])
if geoelem.get('properties', {}).get('annotation'):
try:
self._annotation.update(geoelem['properties']['annotation'])
except Exception:
pass
self._annotation['elements'] = self._elements
elemtype = geoelem.get('properties', {}).get('type', '') or geoelem['geometry']['type']
func = getattr(self, elemtype.lower() + 'Type', None)
Expand Down

0 comments on commit 23c0a55

Please sign in to comment.