搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目