Skip to content

Commit

Permalink
Merge pull request #687 from girder/default-props-centroids
Browse files Browse the repository at this point in the history
Have appropriate default properties when emitting centroids.
  • Loading branch information
manthey authored Nov 19, 2021
2 parents 47d5166 + b3b7504 commit 1450c08
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- On Girder with read-only assetstores, return results even if caching fails ([#684](../../pull/684))
- Handle geospatial files with no explicit projection ([#686](../../pull/686))

### Bug Fixes
- Fix default properties on annotations when emitted as centroids ([#687](../../pull/687))

## Version 1.8.6

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def _similarElementStructure(self, a, b, parentKey=None): # noqa
return False
elif isinstance(a, list):
if len(a) != len(b):
if parentKey not in {'points', 'values'} or len(a) < 3 or len(b) < 3:
if parentKey not in {'points', 'values'} or len(a) < 2 or len(b) < 2:
return False
# If this is an array of points, let it pass
for idx in range(len(b)):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ def yieldElements(self, annotation, region=None, info=None): # noqa
'bbox': True}
proplist = []
propskeys = ['type', 'fillColor', 'lineColor', 'lineWidth', 'closed']
# This should match the javascript
defaultProps = {
'fillColor': 'rgba(0,0,0,0)',
'lineColor': 'rgb(0,0,0)',
'lineWidth': 2,
}
for key in propskeys:
fields['element.%s' % key] = True
props = {}
Expand Down Expand Up @@ -249,7 +255,9 @@ def yieldElements(self, annotation, region=None, info=None): # noqa
bbox = entry.get('bbox')
if not bbox or 'lowx' not in bbox or 'size' not in bbox:
continue
prop = tuple(element.get(key) for key in propskeys)
prop = tuple(
element.get(key, defaultProps.get(key)) for key in propskeys
if element.get(key, defaultProps.get(key)) is not None)
if prop not in props:
props[prop] = len(props)
proplist.append(list(prop))
Expand Down

0 comments on commit 1450c08

Please sign in to comment.