Use object.selections polygon for chip highlight instead of bbox columns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -98,13 +98,15 @@ router.get('/', requireJwt, async (req, res, next) => {
|
||||
placeholderMap[w.id] = { de: w.de, en: w.en, sv: w.sv, type: 'word', bbox: null };
|
||||
});
|
||||
|
||||
// Object lookup → get first linked word as label
|
||||
// Object lookup → get first linked word as label + selections polygon
|
||||
const objUuids = uuidArr.filter(u => !placeholderMap[u]);
|
||||
if (objUuids.length) {
|
||||
const objRes = await query(
|
||||
`SELECT ow.object_id AS id, w.titel_de AS de, w.titel_en AS en, w.titel_sv AS sv
|
||||
`SELECT ow.object_id AS id, w.titel_de AS de, w.titel_en AS en, w.titel_sv AS sv,
|
||||
o.selections
|
||||
FROM object_words ow
|
||||
JOIN words w ON w.id = ow.word_id
|
||||
JOIN objects o ON o.id = ow.object_id
|
||||
WHERE ow.object_id = ANY($1)`,
|
||||
[objUuids]
|
||||
);
|
||||
@@ -112,7 +114,11 @@ router.get('/', requireJwt, async (req, res, next) => {
|
||||
const seen = new Set();
|
||||
objRes.rows.forEach(r => {
|
||||
if (!seen.has(r.id)) {
|
||||
placeholderMap[r.id] = { de: r.de, en: r.en, sv: r.sv, type: 'object', bbox: null };
|
||||
placeholderMap[r.id] = {
|
||||
de: r.de, en: r.en, sv: r.sv,
|
||||
type: 'object',
|
||||
selections: r.selections || [],
|
||||
};
|
||||
seen.add(r.id);
|
||||
}
|
||||
});
|
||||
@@ -162,8 +168,7 @@ router.get('/', requireJwt, async (req, res, next) => {
|
||||
if (resolvedObjectIds.size) {
|
||||
const picRes = await query(
|
||||
`SELECT DISTINCT ON (op.object_id)
|
||||
op.object_id, p.picture_link AS url, p.blurhash,
|
||||
op.bbox_x, op.bbox_y, op.bbox_w, op.bbox_h
|
||||
op.object_id, p.picture_link AS url, p.blurhash
|
||||
FROM object_pictures op
|
||||
JOIN pictures p ON p.id = op.picture_id
|
||||
WHERE op.object_id = ANY($1)
|
||||
@@ -172,12 +177,6 @@ router.get('/', requireJwt, async (req, res, next) => {
|
||||
);
|
||||
picRes.rows.forEach(r => {
|
||||
pictureMap[r.object_id] = { url: r.url, blurhash: r.blurhash };
|
||||
// Attach bbox to placeholder if all four values are present
|
||||
if (placeholderMap[r.object_id] && r.bbox_x != null) {
|
||||
placeholderMap[r.object_id].bbox = {
|
||||
x: r.bbox_x, y: r.bbox_y, w: r.bbox_w, h: r.bbox_h,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user