當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。