UNPKG

@realsee/dnalogel

Version:
105 lines (104 loc) 2.6 kB
var c = (o, e, r) => new Promise((l, n) => { var i = (t) => { try { s(r.next(t)); } catch (p) { n(p); } }, m = (t) => { try { s(r.throw(t)); } catch (p) { n(p); } }, s = (t) => t.done ? l(t.value) : Promise.resolve(t.value).then(i, m); s((r = r.apply(o, e)).next()); }); import { FLOORPLAN_EXTRA_OBJECT_IMAGE as f } from "../Assets/floorplanExtraObject.js"; import { getFloorIndexFromModelPosition as a, modelPosition2FloorplanPosition as u, floorplanPosition2ImagePosition as _ } from "./formatPosition.js"; function I(o) { return c(this, null, function* () { const e = new Headers({ "Content-Type": "text/plain" }), r = function(n) { return c(this, null, function* () { const i = { index: n.index, url: n.url, svgUrl: n.svg_url }; if (n.svg_url) { const m = yield fetch(n.svg_url, { headers: e }).then((s) => s.text()); i.svgContent = m; } return i; }); }; return yield Promise.all(o.map(r)); }); } function g(o) { return { id: o.id, size: o.size, name: o.name, path: o.path, roomType: o.room_type, floorType: o.floor_type, roomLabel: { position: o.room_label.position, positionInImage: o.room_label.position_in_image }, observerIndexs: o.observer_indexs }; } function x(o) { return { floorName: o.floor_name, floorIndex: o.floor_index, rooms: o.rooms.map(g), rules: o.rules }; } function d(o) { return { index: o.index, floorIndex: o.floor_index, position: o.position, positionInImage: o.position_in_image }; } function v(o) { return { rad: o.rad, position: o.position, positionInImage: o.position_in_image, northRad: o.north_rad, roomId: o.room_id, floorIndex: o.floor_index }; } function P(o) { return c(this, null, function* () { const e = yield I(o.outlines), r = o.computed_data.bounding, l = o.computed_data.floor_datas.map(x), n = o.computed_data.entrance ? v(o.computed_data.entrance) : null; return { outlines: e, entrance: n, bounding: r, floorDatas: l, observers: o.computed_data.observers.map(d) }; }); } function y(o, e, r) { return o.map((n) => { const i = n.position, m = n.icon ? n.icon : { url: f, width: 45, height: 48 }, s = a(i, e), t = u(i, r), p = _(t, r); return { floorIndex: s, icon: m, id: n.id, position: t, positionInImage: p }; }); } export { P as formatData, y as formatExtraObjects };