Skip to content

Conversation

@BryonLewis
Copy link
Collaborator

@BryonLewis BryonLewis commented Jan 17, 2026

  • enables the rotate handle with a 'grab' icon for hovering style for rectangles
  • adds function for calculating the rotation between rotated bounding boxes
  • Stores the rotation value as a detection attribute called 'rotation'
  • Added logic for reserved fields for detection and track attributes
  • All bboxes should be stored as an axis-aligned bbox with a rotation in radians CCW about the center in radians
  • If the rotation isn't default, a small arrow is drawn on the 'right' side of the bbox
  • On modification I need to check the difference between rotating and resizing, there are helper functions to do that.

@BryonLewis BryonLewis changed the title initial attempt at adding object oriented bounding boxes Object Oriented Bounding Boxes Jan 25, 2026
@BryonLewis BryonLewis marked this pull request as ready for review February 1, 2026 19:25
@BryonLewis BryonLewis requested a review from naglepuff February 1, 2026 23:25
Comment on lines 70 to 72
const reservedList = data.belongs === 'detection'
? ['rotation', 'userModified']
: ['userCreated'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we had an object, then we could just do reservedList = RESERVED_ATTRIBUTES[data.belongs];. If you don't like the object idea, then I think it would still be better to import the lists here instead of hard-coding them again.

Comment on lines 615 to 641
if (this.arrowFeatureLayer) {
if (this.type === 'rectangle') {
const ann = this.featureLayer.annotations()[0];
if (ann) {
const g = ann.geojson();
if (g && g.geometry && g.geometry.type === 'Polygon') {
const coords = (g.geometry as GeoJSON.Polygon).coordinates[0];
const rotation = getRotationFromAttributes(g.properties as Record<string, unknown>);
const unrotated = rotateGeoJSONCoordinates(coords, 0 - (rotation ?? 0));
// create RectBounds from unrotated coordinates
const bounds: RectBounds = [Math.min(unrotated[0][0], unrotated[2][0]), Math.min(unrotated[0][1], unrotated[2][1]), Math.max(unrotated[0][0], unrotated[2][0]), Math.max(unrotated[0][1], unrotated[2][1])];
const arrow = getRotationArrowLine(bounds, rotation ?? 0);
if (arrow) {
this.arrowFeatureLayer.data([{ c: arrow.coordinates }]).line((d: { c: GeoJSON.Position[] }) => d.c).draw();
} else {
this.arrowFeatureLayer.data([]).draw();
}
} else {
this.arrowFeatureLayer.data([]).draw();
}
} else {
this.arrowFeatureLayer.data([]).draw();
}
} else {
this.arrowFeatureLayer.data([]).draw();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be rewritten to be less nested? I see a lot of failure cases that are doing the same thing (clearing the arrow feature)

@BryonLewis BryonLewis requested a review from naglepuff February 3, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants