mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:17:09 +00:00
Remove SequenceDataLayer
This commit is contained in:
@@ -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})<br/>\n` +
|
||||
`<small>${tstamp.toISOString()}</small><br/>\n` +
|
||||
`Δi: ${Δi.toFixed(2)}<br/>\n` +
|
||||
`Δj: ${Δj.toFixed(2)}</br/>`;
|
||||
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;
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
import SequenceDataLayer from './SequenceDataLayer';
|
||||
|
||||
export {
|
||||
SequenceDataLayer
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user