mt-polygon-simplification/benchmarking/src/simplifyMapper.js

17 lines
580 B
JavaScript
Raw Normal View History

2019-08-04 22:45:39 +02:00
import { memoize } from 'lodash'
import { simplifyWasm } from '../../lib/simplify-wasm/index.js'
import { dataSelector } from './data/index.js'
async function numberOfNodes(dataset, tol, highQual) {
2019-08-06 17:23:40 +02:00
let data = await dataSelector(dataset)
2019-08-04 22:45:39 +02:00
return await simplifyWasm(data, tol, highQual).then(arr => arr.length)
}
const memNumberOfNodes = memoize(numberOfNodes, (...args) => args.join('|'))
export async function simplifyMapper({ dataset, tolRange, highQual }) {
let items = tolRange.map(tol => memNumberOfNodes(dataset, tol, highQual))
return await Promise.all(items)
}