1.0.5 • Published 2 years ago
rasterized-interpolation v1.0.5
rasterized-interpolation
generate route paths using WGS84 grid data and the xy velocity components of points.
Usage
:earth_asia: data
GridData
param | type | describe |
---|---|---|
header | JSON | grid data format description |
xu | Array | the velocity component in the x-direction |
yv | Array | the velocity component in the y-direction |
header
param | type | describe |
---|---|---|
west | number | westernmost |
east | number | easternmost |
south | number | southernmost |
north | number | northernmost |
dx | number | grid x direction accuracy |
dy | number | grid y direction accuracy |
nx | number | number of grids in the x direction |
ny | number | number of grids in the y direction |
example
const gridData = {
header: {
// scope
east: 110,
west: 120,
south: 70,
north: 80,
// direction accuracy
dx: 1,
dy: 1,
// number of grids
nx: 10,
ny: 10
},
// sort from east to west and from north to south
xu: [-0.24, -0.25, -0.26, -0.24, -0.24, -0.25, -0.26, -0.24, -0.24, -0.25],
yu: [-0.24, -0.25, -0.26, -0.24, -0.24, -0.25, -0.26, -0.24, -0.24, -0.25]
}
Synchronous
synchronous interpolation prediction data. It is recommended to use asynchronous data loading if your data volume is too large.
example
import { InterpolationRandom, InterpolationAll } from './worker/rasterized-interpolation.js';
const data: GardData = {...};
// generate random paths
InterpolationRandom({ data, randomTotal: 10000 });
// generate all paths
InterpolationAll({ data })
Asynchronous
if you need to use a worker to process a large amount of data.
worker configuration
you need to configure the project worker to load the script. If you don't want to configure it, you can use synchronous loading method.
copyPlugins({
from: path.join('node_modules/rasterized-interpolation/core/', 'rasterized-interpolation-worker.js'),
to: 'rootPath'
})
example
import { createWorker } from 'rasterized-interpolation';
const myWorker = createWorker();
const data: GardData = {...};
myWorker.send(data)
// Get your interpolation prediction data
myWorker.onmessage = function(e) {
...
}