Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have appropriate default properties when emitting centroids. #687

Merged
merged 1 commit into from
Nov 19, 2021
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
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