搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.14

turf

一個類似於 turf.js 的地理空間分析庫,用於處理 GeoJSON,完全以 Dart 編寫。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
17.6萬
喜歡數
51
Pub 分數
150

安裝套件

flutter pub add turf

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Turf 是一個用於 Dart 的地理空間分析程式庫,受到 turf.js 的啟發,專為處理 GeoJSON 數據而設計。它提供了一套工具,可用於執行距離計算、緩衝區、相交等空間運算,全部以純 Dart 實作。非常適合需要即時地理計算且不依賴原生平台程式碼的應用程式。該程式庫支援多種平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,使其在跨平台開發中極具彈性。其輕量級特性和與 Flutter 的相容性,使其適用於地圖和位置相關功能。

適用情境

  • 地理空間資料處理
  • 基於地圖的分析
  • 位置感知應用
  • 即時空間計算
  • GeoJSON 操作

主要特色

  • 純 Dart 實現
  • 支援 GeoJSON
  • 跨平台相容性
  • Turf.js 類 API
  • 廣泛的空間操作

適合對象

  • Flutter 開發者
  • GIS 應用
  • 行動與網路地圖
  • 處理位置資料的資料科學家
  • 需要離線地理空間邏輯的應用程式

使用建議

  • 需要 GeoJSON 輸入格式
  • 僅限基本地理空間功能
  • 無內建地圖渲染
  • 效能取決於資料大小
  • 未針對非常大的資料集進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。


TurfDart Logo

A TurfJs-like geospatial analysis library written in pure Dart.


pub package dart unit tests dart publish License: MIT

–> Join our Dart / Flutter GIS Community on Discord <–

TurfDart is a Dart library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. You can use TurfDart in your Flutter applications on the web, mobile and desktop or in pure Dart applications running on the server.

As the foundation, we are using Geotypes, a lightweight dart library that provides a strong GeoJSON object model and fully RFC 7946 compliant serializers.

Most of the functionality is a translation from turf.js, the progress can be found here.

Get started

  • Get the Dart tools
  • Install the library with dart pub add turf
  • Import the library in your code and use it. For example:
import 'package:turf/helpers.dart';
import 'package:turf/src/line_segment.dart';

Feature<Polygon> poly = Feature<Polygon>(
  geometry: Polygon(coordinates: [
    [
      Position(0, 0),
      Position(2, 2),
      Position(0, 1),
      Position(0, 0),
    ],
    [
      Position(0, 0),
      Position(1, 1),
      Position(0, 1),
      Position(0, 0),
    ],
  ]),
);

void main() {
  var total = segmentReduce<int>(
    poly,
    (previousValue, currentSegment, initialValue, featureIndex,
        multiFeatureIndex, geometryIndex, segmentIndex) {
      if (previousValue != null) {
        previousValue++;
      }
      return previousValue;
    },
    0,
    combineNestedGeometries: false,
  );
  print(total);
  // total ==  6
}

GeoJSON Object Model

polymorphism

Notable Design Decisions
  • Nested GeometryCollections (as described in RFC 7946 section 3.1.8) are not supported which takes a slightly firmer stance than the "should avoid" language in the specification

Tests and Benchmarks

Tests are run with dart test and benchmarks can be run with dart run benchmark

Any new benchmarks must be named *_benchmark.dart and reside in the ./benchmark folder.

所屬分類

依賴

依賴清單 6 項

原始碼儲存庫

使用此套件的專案