패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.1.1

rbush

RBush — 점과 사각형에 대한 고성능 R-트리 기반 2차원 공간 인덱스입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
17.5만
좋아요
11
Pub 점수
140

패키지 설치

flutter pub add rbush

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

RBush는 점과 사각형에 대한 효율적인 2차원 기하 연산을 위한 고성능 R-트리 기반 공간 인덱스입니다. 공간 데이터를 포함하는 애플리케이션에서 빠른 범위 쿼리, 가장 가까운 이웃 검색 및 충돌 감지가 가능합니다. Dart용으로 개발되어 모든 주요 플랫폼의 Flutter 프로젝트와 원활하게 통합됩니다. 게임, 지도 시스템 및 빠른 공간 검색이 필요한 모든 애플리케이션에 적합합니다. 속도와 메모리 효율성을 최적화한 구현으로 실시간 또는 대규모 공간 처리에 적합합니다.

사용 사례

  • 지리공간 데이터 인덱싱
  • 게임 객체 충돌 감지
  • 지도 기반 애플리케이션
  • 실시간 근접 쿼리
  • 공간 검색 최적화

주요 기능

  • 고성능 R-트리 인덱싱
  • 점과 사각형을 지원합니다
  • 2D 공간 쿼리에 최적화됨
  • 크로스 플랫폼 호환성
  • 낮은 메모리 오버헤드

적합한 대상

  • 인터랙티브 지도를 구축하는 개발자
  • 공간 충돌 검사를 필요로 하는 게임 개발자
  • 자주 공간 쿼리를 수행하는 애플리케이션
  • 성능 중심의 지리공간 도구
  • 빠른 2차원 기하 연산이 필요한 플러터 앱

고려 사항

  • 2차원 데이터에만 적합
  • 자주 삽입/삭제가 이루어지는 동적 데이터 세트에는 적합하지 않음
  • 좌표계를 신중하게 다뤄야 합니다
  • 점 및 사각형 기하학적 형상에 한정
  • 복잡한 모양이나 다각형에 대한 내장 지원 없음

원본 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.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트