MCPcopy Create free account
hub / github.com/microsoft/SandDance / parseGridData

Function parseGridData

docs/tests/v2/es6/js/sanddance.js:61849–61935  ·  view source on GitHub ↗
(data, getPosition)

Source from the content-addressed store, hash-verified

61847
61848
61849function parseGridData(data, getPosition) {
61850 var getWeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
61851 var pointCount = (0, _count.count)(data);
61852 var positions = new Float32Array(pointCount * 2);
61853 var positions64xyLow = new Float32Array(pointCount * 2);
61854 var weightValues = new Float32Array(pointCount * 3);
61855 var yMin = Infinity;
61856 var yMax = -Infinity;
61857 var xMin = Infinity;
61858 var xMax = -Infinity;
61859 var y;
61860 var x;
61861
61862 var _createIterable = (0, _iterableUtils.createIterable)(data),
61863 iterable = _createIterable.iterable,
61864 objectInfo = _createIterable.objectInfo;
61865
61866 var _iteratorNormalCompletion = true;
61867 var _didIteratorError = false;
61868 var _iteratorError = undefined;
61869
61870 try {
61871 for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
61872 var object = _step.value;
61873 objectInfo.index++;
61874 var position = getPosition(object, objectInfo);
61875 var index = objectInfo.index;
61876 x = position[0];
61877 y = position[1];
61878 positions[index * 2] = x;
61879 positions[index * 2 + 1] = y;
61880 positions64xyLow[index * 2] = fp64LowPart(x);
61881 positions64xyLow[index * 2 + 1] = fp64LowPart(y);
61882 var weight = getWeight ? getWeight(object, objectInfo) : DEFAULT_WEIGHT; // Aggregator expects each weight is an array of size 3
61883
61884 if (Array.isArray(weight)) {
61885 weightValues[index * 3] = weight[0];
61886 weightValues[index * 3 + 1] = weight[1];
61887 weightValues[index * 3 + 2] = weight[2];
61888 } else {
61889 // backward compitability
61890 weightValues[index * 3] = weight;
61891 }
61892
61893 if (Number.isFinite(y) && Number.isFinite(x)) {
61894 yMin = y < yMin ? y : yMin;
61895 yMax = y > yMax ? y : yMax;
61896 xMin = x < xMin ? x : xMin;
61897 xMax = x > xMax ? x : xMax;
61898 }
61899 }
61900 } catch (err) {
61901 _didIteratorError = true;
61902 _iteratorError = err;
61903 } finally {
61904 try {
61905 if (!_iteratorNormalCompletion && _iterator.return != null) {
61906 _iterator.return();

Callers 1

pointToDensityGridDataFunction · 0.85

Calls 2

getPositionFunction · 0.70
fp64LowPartFunction · 0.70

Tested by

no test coverage detected