-
Notifications
You must be signed in to change notification settings - Fork 23
Object Oriented Bounding Boxes #1572
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
base: main
Are you sure you want to change the base?
Conversation
…reserved attributes
client/src/use/useAttributes.ts
Outdated
| const reservedList = data.belongs === 'detection' | ||
| ? ['rotation', 'userModified'] | ||
| : ['userCreated']; |
There was a problem hiding this comment.
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.
| 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(); | ||
| } | ||
| } |
There was a problem hiding this comment.
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)
Co-authored-by: Michael Nagler <mike.nagler@kitware.com>
Uh oh!
There was an error while loading. Please reload this page.