本文整理汇总了TypeScript中kdbush类的典型用法代码示例。如果您正苦于以下问题:TypeScript kdbush类的具体用法?TypeScript kdbush怎么用?TypeScript kdbush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了kdbush类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: kdbush
import * as kdbush from 'kdbush';
import { KDBush } from 'kdbush';
// API
const points = [[110, 60], [130, 40]];
const index = kdbush(points);
// properties
index.nodeSize;
index.points;
index.ids;
index.coords;
// range
index.range(10, 10, 20, 20);
index.range(10, 10, 20, 20).map(id => points[id]);
// within
index.within(10, 10, 5);
index.within(10, 10, 5).map(id => points[id]);
// custom points (object)
const xy = [{x: 110, y: 60}, {x: 130, y: 40}];
const index2: KDBush<{x: number, y: number}> = kdbush(xy, p => p.x, p => p.y);
index2.points[0].x;
index2.points[0].y;
index2.points.map(p => [p.x, p.y]);
// custom points (latlng)
const latlng = [[60, 110], [40, 130]];
kdbush(latlng, p => p[1], p => p[0]);
示例2: kdbush
import * as kdbush from "kdbush";
import { KDBush } from "kdbush";
// API
const points = [[110, 60], [130, 40]];
const index = kdbush(points);
// Specify array constructor
const pick = (index: number) => (point: number[]) => point[index];
kdbush(points, pick(0), pick(1), 64, Int8Array);
kdbush(points, pick(0), pick(1), 64, Int16Array);
kdbush(points, pick(0), pick(1), 64, Int32Array);
kdbush(points, pick(0), pick(1), 64, Float32Array);
kdbush(points, pick(0), pick(1), 64, Float64Array);
kdbush(points, pick(0), pick(1), 64, Array);
// properties
index.nodeSize;
index.points;
index.ids;
index.coords;
// range
index.range(10, 10, 20, 20);
index.range(10, 10, 20, 20).map(id => points[id]);
// within
index.within(10, 10, 5);
index.within(10, 10, 5).map(id => points[id]);
// custom points (object)
示例3: kdbush
import * as kdbush from 'kdbush';
import * as geokdbush from 'geokdbush';
const points = [
{lon: 0, lat: 0},
{lon: 20, lat: 10},
{lon: -10, lat: 30},
];
const index = kdbush(points, p => p.lon, p => p.lat);
const nearest = geokdbush.around(index, -119.7051, 34.4363, 1000);
示例4: kdbush
import * as kdbush from 'kdbush';
// API
const points = [[110, 60], [130, 40]];
const index = kdbush(points);
// properties
index.nodeSize;
index.points;
index.ids;
index.coords;
// range
index.range(10, 10, 20, 20);
index.range(10, 10, 20, 20).map(id => points[id]);
// within
index.within(10, 10, 5);
index.within(10, 10, 5).map(id => points[id]);
// custom points (object)
const xy = [{x: 110, y: 60}, {x: 130, y: 40}];
const index2 = kdbush(xy, p => p.x, p => p.y);
index2.points[0].x;
index2.points[0].y;
index2.points.map(p => [p.x, p.y]);
// custom points (latlng)
const latlng = [[60, 110], [40, 130]];
kdbush(latlng, p => p[1], p => p[0]);
kdbush(latlng, p => p[1], p => p[0], 64, Int32Array);