当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript kdbush类代码示例

本文整理汇总了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]);
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:kdbush-tests.ts

示例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)
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:kdbush-tests.ts

示例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);
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:10,代码来源:geokdbush-tests.ts

示例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);
开发者ID:DanCorder,项目名称:DefinitelyTyped,代码行数:31,代码来源:kdbush-tests.ts


注:本文中的kdbush类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。