annotorious / annotorious-openseadragon

An OpenSeadragon plugin for annotating high-res zoomable images
https://annotorious.github.io
BSD 3-Clause "New" or "Revised" License
121 stars 42 forks source link

Retrieve annotations which intersect with their bounding box #134

Closed hsellik closed 2 years ago

hsellik commented 2 years ago

Since you keep the spatial index for bounding boxes, would it be possible to expose a method to return other annotations whose bounding boxes are intersecting with the annotation specified?

.getAnnotationsIntersecting

getAnnotationsIntersecting(arg);

Returns the annotations whose bounding boxes intersect with the bounding box of the specified annotation.

Argmument arg is of type String or Object with the value of the annotation or the annotation ID respectively.

It's not a perfect intersection match for the annotations, but at least the bounding boxes match and it's close enough for me.

It's not working for sure, but I was thinking roughly something like this: https://github.com/recogito/annotorious-openseadragon/compare/main...hsellik:annotorious-openseadragon:bounding-box

What do you think?

rsimon commented 2 years ago

Hi,

I like the idea - could be a really useful feature! As you say a fully complete implementation would have to check intersections between actual shapes (I guess by providing separate tests box/box, box/poly, poly/poly, and for point and line shapes). But this might be a nice first step. Would you mind sending a PR? I think I might tweak the plumbing a bit, but otherwise I'm happy to include this.

Two caveats:

hsellik commented 2 years ago

Hi!

Made the pull request https://github.com/recogito/annotorious-openseadragon/pull/139.

Tried to make it work locally first, but couldn't. So as you said, it needs some tweaks, still.

rsimon commented 2 years ago

Got it - many thanks! There were only two small issues:

I made a handful of small tweaks to fix this. The feature should be good to go now. Thanks again - a nice addition!