パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.1.1

rbush

RBush — ポイントと長方形用の高性能なRツリーに基づく2次元空間インデックス。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
18.5万
いいね数
11
Pub ポイント
140

パッケージをインストール

flutter pub add rbush

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

RBush は、ポイントと長方形の効率的な 2D 幾何演算を実行するための高性能な R 木ベースの空間インデックスです。空間データを扱うアプリケーションにおいて、高速な範囲検索、近隣探索、衝突検出を可能にします。Dart 向けに開発されており、すべての主要プラットフォームで Flutter プロジェクトにスムーズに統合できます。ゲーム、マッピングシステム、および迅速な空間照会が必要なあらゆるアプリケーションに最適です。その実装は速度とメモリ効率に最適化されており、リアルタイムまたは大規模な空間処理に適しています。

用途

  • 地理空間データのインデックス化
  • ゲームオブジェクトの衝突検出
  • 地図ベースのアプリケーション
  • リアルタイムの近接クエリ
  • 空間検索の最適化

主な機能

  • 高パフォーマンスな R 木インデックス
  • ポイントと長方形をサポートしています
  • 2D空間クエリに最適化されています
  • クロスプラットフォーム互換性
  • 低いメモリオーバーヘッド

適している対象

  • インタラクティブマップを開発する開発者
  • 空間衝突チェックが必要なゲーム開発者
  • 頻繁な空間クエリを持つアプリケーション
  • パフォーマンスが重要な地理空間ツール
  • 高速な2D幾何演算を必要とするFlutterアプリ

注意事項

  • 2Dデータ専用に最適
  • 頻繁な挿入/削除を行う動的データセットには適していない
  • 座標系の取り扱いに注意が必要です
  • ポイントおよび長方形のジオメトリに限定
  • 複雑な形状や多角形の組み込みサポートなし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

RBush

RBush is a high-performance Dart library for 2D spatial indexing of points and rectangles. It's based on an optimized R-tree data structure with bulk insertion support.

Spatial index is a special data structure for points and rectangles that allows you to perform queries like "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). It's most commonly used in maps and data visualizations.

Usage

// Create a tree with up to 16 elements in a leaf.
final tree = RBush(16);

// Bulk load elements (empty in this case, so here it's a no-op).
tree.load(<RBushElement>[]);

// Insert a single element.
tree.insert(RBushElement(
  minX: 10, minY: 10,
  maxX: 20, maxY: 30,
  data: 'sample data'
));

// Find the element we've inserted.
final List<RBushElement> found = tree.search(
    RBushBox(minX: 5, minY: 5, maxX: 25, maxY: 25));

// Remove all elements from the tree.
tree.clear();

An optional argument to RBush defines the maximum number of entries in a tree node. 9 (used by default) is a reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.

To store items of a different type, extend from (or instantiate) RBushBase<T>. For example:

class MyItem {
  final String id;
  final LatLng location;
  
  const MyItem(this.id, this.location);
}

final tree = RBushBase<MyItem>(
  maxEntries: 4,
  toBBox: (item) => RBushBox(
    minX: item.location.longitude,
    maxX: item.location.longitude,
    minY: item.location.latitude,
    maxY: item.location.latitude,
  ),
  getMinX: (item) => item.location.longitude,
  getMinY: (item) => item.location.latitude,
);
K Nearest Neighbours

The RBushBase class also includes a knn() method for the nearest neighbours search. This is especially useful when using the r-tree to store point features, like in the example above.

Note that for larger geographical areas the distance would be wrong, since the class uses pythagorean distances (dx² + dy²), not Haversine or great circle.

Tiny Queue and Quick Select

This package also includes ported fast versions of a priority queue and a selection algorithm. These are used internally by the r-tree, but might be useful for you as well.

Upstream

This library is a straight-up port of several JavaScript libraries written by Vladimir Agafonkin:

All of these are published under MIT or ISC licenses.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト