docs(docs): V1-2.6 U2 boards 02-06, 13, 31-33, review and arbitrations
This commit is contained in:
1 parent
c42c65509b
commit
bc19481b93
18 files changed
+1335
No files matched your search
@@ -0,0 +1,45 @@
|
||||
// node gen-data.cjs: writes data.js (window.DOC) from the equine draft document, so every annotation, name,
|
||||
// category, laterality, findings zone, vertebral region, review status and coordinate of the U2 boards comes from
|
||||
// document.json and none is typed by hand. The point sizes of each view (the slider's snap marks) are counted
|
||||
// from the same data.
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const SRC = path.join(__dirname, '../../../supabase/seed/anatomical-sheets/equine/draft/document.json')
|
||||
const doc = JSON.parse(fs.readFileSync(SRC, 'utf8'))
|
||||
|
||||
const zoneName = Object.fromEntries(doc.finding_zones.map((z) => [z.id, z.name.fr]))
|
||||
const regions = doc.vertebral_config.regions.map((r) => ({ code: r.code, fr: r.name.fr, en: r.name.en, count: r.count }))
|
||||
const sizes = {}
|
||||
for (const a of doc.annotations) {
|
||||
if (a.geometry.type !== 'circle') continue
|
||||
sizes[a.view_id] = sizes[a.view_id] || {}
|
||||
sizes[a.view_id][a.geometry.r] = (sizes[a.view_id][a.geometry.r] || 0) + 1
|
||||
}
|
||||
const out = {
|
||||
name: doc.name,
|
||||
views: doc.views.map((v) => ({ id: v.id, fr: v.name.fr, en: v.name.en, parent: v.parent_view_id || null, box: v.view_box || null })),
|
||||
categories: doc.categories.map((c) => ({ id: c.id, fr: c.name.fr, en: c.name.en, color: c.color })),
|
||||
regions,
|
||||
annotations: doc.annotations.map((a) => ({
|
||||
id: a.id,
|
||||
view: a.view_id,
|
||||
kind: a.kind,
|
||||
cat: a.category_id,
|
||||
lat: a.laterality,
|
||||
fr: a.name ? a.name.fr : null,
|
||||
en: a.name ? a.name.en : null,
|
||||
zone: a.finding_zone_id || null,
|
||||
zoneFr: a.finding_zone_id ? zoneName[a.finding_zone_id] : null,
|
||||
region: a.vertebral_region_code || null,
|
||||
status: a.review_status || 'inherited',
|
||||
g: a.geometry.type === 'circle'
|
||||
? ['c', a.geometry.cx, a.geometry.cy, a.geometry.r]
|
||||
: ['p', a.geometry.points],
|
||||
})),
|
||||
zones: doc.finding_zones.map((z) => ({ id: z.id, fr: z.name.fr })),
|
||||
sizes,
|
||||
}
|
||||
const body = 'window.DOC = ' + JSON.stringify(out) + '\n'
|
||||
fs.writeFileSync(path.join(__dirname, 'data.js'), '// generated by gen-data.cjs from document.json\n' + body)
|
||||
console.log('annotations', out.annotations.length, 'zones', out.zones.length, 'regions', regions.length,
|
||||
'sizes', JSON.stringify(sizes), 'bytes', body.length)
|
||||
Reference in new issue
Block a user