From 06cc16721f5cfe0a4c20e210a8bb90be943869fe Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Fri, 1 Aug 2025 17:15:27 +0200 Subject: [PATCH] Remove SequenceDataLayer --- .../src/lib/deck.gl/SequenceDataLayer.js | 219 ------------------ .../client/source/src/lib/deck.gl/index.js | 2 - 2 files changed, 221 deletions(-) delete mode 100644 lib/www/client/source/src/lib/deck.gl/SequenceDataLayer.js diff --git a/lib/www/client/source/src/lib/deck.gl/SequenceDataLayer.js b/lib/www/client/source/src/lib/deck.gl/SequenceDataLayer.js deleted file mode 100644 index c44522f..0000000 --- a/lib/www/client/source/src/lib/deck.gl/SequenceDataLayer.js +++ /dev/null @@ -1,219 +0,0 @@ -import { CompositeLayer } from '@deck.gl/core'; -import { GeoJsonLayer, ScatterplotLayer } from '@deck.gl/layers'; -import { unpack, MSGTYPE } from '@/lib/binary'; - -class SequenceDataLayer extends CompositeLayer { - - #getDataArrayBuffer (buffer, id=0) { - const segments = unpack(buffer); -// console.log("segments", segments); - return segments.map( (segment, index) => { - const props = { - id: `s-${id}-c-${index}`, - data: { - length: segment.count, - attributes: { - getPosition: {value: segment.positions, size: 2} - }, - type: segment.type, - seq: segment.seq, - sp0: segment.sp0, - Δsp: segment.Δsp - }, - dataComparator: (newVal, oldVal) => true - }; - - if (segment.ts0) { - props.data.ts0 = segment.ts0; - } - - if (segment.Δij) { - props.data.Δij = segment.Δij; - } - - if (segment.Δts) { - props.data.Δts = segment.Δts; - } - - if (segment.radii) { - props.data.attributes.getRadius = {value: segment.radii, size: 1}; - } - - return props; - }); - } - - #getDataSequence ({id, data}) { - return this.#getDataArrayBuffer(data, id); - } - - #getData (data) { -// console.log("getData", data); - if (typeof data === "string") { - // Fetch URL - } else if (data instanceof ArrayBuffer) { -// console.log("is ArrayBuffer"); - return this.#getDataArrayBuffer(data); - } else if (typeof data === "object" && data.hasOwnProperty("id")) { -// console.log("is id object"); - return this.#getDataSequence(data); - } else if (Array.isArray(data)) { -// console.log("is Array"); - return data.map(i => this.#getData(i)).flat(); - } else { -// console.log("is something else"); - return data; - } - } - - renderLayers () { - const data = this.props.data; - const defs = this.#getData(data.sequences); - return defs.map( def => { - let aesthetics = {}; - if (def.data.type == MSGTYPE.PREPLOT_RAWERROR_OPT) { - aesthetics = { - stroked: false, - filled: true, - getFillColor: [160, 160, 180, 200], - radiusUnits: "meters", - radiusScale: 1, - radiusMinPixels: 2, - getLineWidth: 2, - lineWidthScale: 20, - lineWidthMinPixels: 2 - }; - } else if (def.data.type == MSGTYPE.RAW_OPT) { - aesthetics = { - stroked: false, - filled: true, - getFillColor: [255, 0, 127, 100], - getRadius: 0.5, - radiusUnits: "meters", - radiusScale: 1, - radiusMinPixels: 3, - getLineWidth: 2, - lineWidthScale: 20, - lineWidthMinPixels: 2 - }; - } else if (def.data.type == MSGTYPE.FINAL_OPT) { - aesthetics = { - stroked: false, - filled: true, - getFillColor: [127, 0, 255, 100], - getRadius: 0.5, - radiusUnits: "meters", - radiusScale: 1, - radiusMinPixels: 3, - getLineWidth: 2, - lineWidthScale: 20, - lineWidthMinPixels: 2 - }; - } - - const props = this.getSubLayerProps({ - ...aesthetics, - ...def, - pickable: this.props.pickable - }); -// console.log(props); - - return new ScatterplotLayer(props); - }); - } -}; -SequenceDataLayer.layerName = "SequenceDataLayer"; -SequenceDataLayer.tooltip = ({index, sourceLayer}) => { - try { - if (index >= 0) { - const p = sourceLayer?.props?.data; - if (index >= p.length) { - console.log("Index out of bounds"); - } - // console.log("P", p); - if (p.type == MSGTYPE.PREPLOT_RAWERROR_OPT) { - - const seq = p.seq.toString().padStart(3, "0"); - const pnt = p.sp0 + p.Δsp * index; - return `S${seq} ${pnt}`; - - } else if (p.type == MSGTYPE.RAW_OPT || p.type == MSGTYPE.FINAL_OPT) { - - const seq = p.seq.toString().padStart(3, "0"); - const pnt = p.sp0 + p.Δsp * index; - const kind = p.type == MSGTYPE.RAW_OPT ? "Raw" : "Final"; - const Δi = p.Δij[index*2]; - const Δj = p.Δij[index*2+1]; - const tstamp = new Date(Number(p.ts0) + p.Δts[index]); - - const html = `S${seq} ${pnt} (${kind})
\n` + - `${tstamp.toISOString()}
\n` + - `Δi: ${Δi.toFixed(2)}
\n` + - `Δj: ${Δj.toFixed(2)}
`; - return {html}; - } - } - } catch (err) { - console.error(err.message); - console.log(index, sourceLayer); - } -}; - - - - ///* -// new GeoJsonLayer(this.getSubLayerProps({ -// id: 'ijerr', -// data: this.props.data, -// pickable: this.props.pickable, -// stroked: this.props.stroked, -// filled: this.props.filled, -// extruded: this.props.extruded, -// lineWidthScale: this.props.lineWidthScale, -// lineWidthMinPixels: this.props.lineWidthMinPixels, -// getFillColor: this.props.getFillColor, -// //getLineColor: this.props.getLineColor, -// pointRadiusMinPixels: this.props.pointRadiusMinPixels, -// getRadius: this.props.getRadius, -// getLineWidth: this.props.getLineWidth, -// getElevation: this.props.getElevation, -// updateTriggers: { -// getPosition: this.props.updateTriggers.getPosition, -// getRadius: this.props.updateTriggers.getRadius, -// getFillColor: this.props.updateTriggers.getFillColor, -// getLineWidth: this.props.updateTriggers.getLineWidth, -// getElevation: this.props.updateTriggers.getElevation -// } -// })), -// //*/ -// new ScatterplotLayer(this.getSubLayerProps({ -// id: 'pos', -// data: this.props.data.features, -// pickable: this.props.pickable, -// stroked: this.props.stroked, -// filled: this.props.filled, -// extruded: this.props.extruded, -// lineWidthScale: this.props.lineWidthScale, -// lineWidthMinPixels: this.props.lineWidthMinPixels, -// getFillColor: [255, 170, 0, 200], -// //getPosition: f => f?.geometry?.coordinates, -// getPosition: f => f?.properties?.geometryfinal?.coordinates || f?.properties?.geometryraw?.coordinates, -// //getLineColor: this.props.getLineColor, -// radiusMinPixels: this.props.pointRadiusMinPixels, -// getRadius: 1, -// getLineWidth: this.props.getLineWidth, -// getElevation: this.props.getElevation, -// updateTriggers: { -// getPosition: this.props.updateTriggers.getPosition, -// //getRadius: this.props.updateTriggers.getRadius, -// //getFillColor: this.props.updateTriggers.getFillColor, -// getLineWidth: this.props.updateTriggers.getLineWidth, -// getElevation: this.props.updateTriggers.getElevation -// } -// })) -// ]; -// } -// } -// SequenceDataLayer.layerName = "SequenceDataLayer"; - -export default SequenceDataLayer; diff --git a/lib/www/client/source/src/lib/deck.gl/index.js b/lib/www/client/source/src/lib/deck.gl/index.js index 2827283..9e70327 100644 --- a/lib/www/client/source/src/lib/deck.gl/index.js +++ b/lib/www/client/source/src/lib/deck.gl/index.js @@ -1,6 +1,4 @@ -import SequenceDataLayer from './SequenceDataLayer'; export { - SequenceDataLayer };