r_tree 패키지는 Dart에서 2차원 공간 데이터를 효율적으로 인덱싱하고 쿼리하기 위한 R-트리 구현을 제공합니다. 빠른 범위 쿼리와 가장 가까운 이웃 검색을 가능하게 하여 지리적 좌표, 충돌 감지 또는 레이아웃 관리와 같은 애플리케이션에 적합합니다. 성능과 다양한 플랫폼 간 호환성을 고려해 개발되었으며, Android, iOS, Web, macOS, Windows, Linux를 지원합니다. 패키지는 Workiva에서 유지보수되며 pub를 통해 Flutter 프로젝트와 원활하게 통합됩니다.
사용 사례
공간 데이터 인덱싱
게임에서의 충돌 감지
지리적 좌표 쿼리
UI 요소 히트 테스트
거리 기반 검색
지도 기반 애플리케이션 기능
주요 기능
효율적인 2차원 범위 쿼리
가장 가까운 이웃 검색 지원
크로스 플랫폼 호환성
고성능 공간 인덱싱
삽입 및 쿼리용 간단한 API
스레드 안전 연산
적합한 대상
게임 개발
GIS 애플리케이션
공간 논리를 갖춘 인터랙티브 UI
데이터 시각화 도구
위치 인식 앱
성능 중심의 공간 연산
고려 사항
2차원 데이터에만 적합
분할 없이 매우 큰 데이터 세트에 최적화되지 않음
좌표 정밀도를 신중하게 다뤄야 합니다
일부 사용 사례에서는 정적 또는 배치 업데이트된 데이터에 국한됨
내장된 지속성 지원 없음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
RTree
A recursive RTree library written in Dart. This R-tree implementation is used to index and query two-dimensional data. Items are inserted and balanced via the RTree class and can then be queried by Rectangle. The balancing can be tweaked by modifying the branch factor of the RTree.
"R-trees are tree data structures used for spatial access methods, i.e., for indexing multi-dimensional information such as geographical coordinates, rectangles or polygons." - http://en.wikipedia.org/wiki/R-tree
Example
Run the example app for a visual demonstration of the RTree
webdev serve example:8080
Navigate to http://localhost:8080. A canvas is drawn, click & drag on the canvas to add rectangles of various colors to your RTree, then click the search button and click & drag over an area of the canvas to search it for rectangles.
Benchmarks
Run the benchmarks in the command line (Dart VM) using:
dart benchmark/benchmarks.dart
You can also run them in a browser using dart2js. This takes an extra step since webdev will only build the web directory as of this writing. You'll also need some binary for serving a directory on a web server, the example below uses serve.
cp -R benchmark/ web
webdev build
serve build
Click the run button and observe the output in the browser console.