搜索插件、代码仓与 APP 分类

插件详情v0.6.1

latlong

用于常见纬度和经度计算的轻量级库

近 30 天下载
2300
喜欢数
116
Pub 分数
10

安装插件

flutter pub add latlong

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个轻量级的 Dart 库,专为高效的纬度和经度计算而设计。它提供了基本的地理空间操作,例如距离计算、中点确定和坐标转换。非常适合需要基础地理数学运算但又不想引入重型依赖的应用程序。该包易于集成,特别适合需要基于位置逻辑的移动和 Web 应用。它支持核心地理定位工具,开销极小。

适合场景

  • 计算两个坐标之间的距离
  • 查找位置之间的中点
  • 在坐标格式之间进行转换
  • 实施基于位置的筛选
  • 构建导航辅助功能
  • 地理围栏逻辑

主要特点

  • 最小占用空间
  • 支持哈弗辛距离
  • 坐标算术
  • 轻松集成
  • 无外部依赖
  • 跨平台兼容性

适合对象

  • 带有位置功能的移动应用
  • Web 地图工具
  • 简单的地理空间计算
  • 原型定位逻辑
  • 需要轻量级地理定位工具的应用

使用建议

  • 仅限基本地理空间数学
  • 不支持地图渲染
  • 不处理复杂投影
  • 不适合高级GIS任务
  • 无内置地理编码
  • 需要手动处理边缘情况

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

DEPRECATED


This package will not be maintained anymore!

The whole thing landed on TypeScript

Check out the lib on npmjs


LatLong provides a lightweight library for common latitude and longitude calculation.

This library supports both, the "Haversine" and the "Vincenty" algorithm.

"Haversine" is a bit faster but "Vincenty" is far more accurate!

LatLong

Catmull-Rom algorithm is used for smoothing out the path.

Basic usage

Distance
    final Distance distance = new Distance();
    
    // km = 423
    final int km = distance.as(LengthUnit.Kilometer,
     new LatLng(52.518611,13.408056),new LatLng(51.519475,7.46694444));
    
    // meter = 422591.551
    final int meter = distance(
        new LatLng(52.518611,13.408056),
        new LatLng(51.519475,7.46694444)
        );

Offset

    final Distance distance = const Distance();
    final num distanceInMeter = (EARTH_RADIUS * math.PI / 4).round();
    
    final p1 = new LatLng(0.0, 0.0);
    final p2 = distance.offset(p1, distanceInMeter, 180);
    
    // LatLng(latitude:-45.219848, longitude:0.0)
    print(p2.round());
    
    // 45° 13' 11.45" S, 0° 0' 0.00" O
    print(p2.toSexagesimal());
            

Path smoothing

    // zigzag is a list of coordinates
    final Path path = new Path.from(zigzag);
    
    // Result is below
    final Path steps = path.equalize(8,smoothPath: true);

Smooth path

Features and bugs

Please file feature requests and bugs at the issue tracker.

License

Copyright 2015 Michael Mitterer (office@mikemitterer.at),
IT-Consulting and Development Limited, Austrian Branch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language
governing permissions and limitations under the License.

If this plugin is helpful for you - please (Circle) me or star this repo here on GitHub

所属分类

依赖

依赖清单 4 项

  • console_log_handler>=1.1.0 <2.0.0
  • intl>=0.15.0 <1.0.0
  • logging>=0.11.3 <1.0.0
  • validate^1.0.0

源码仓库

使用此插件的项目