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

latlong2 封面
套件詳情v0.10.1

latlong2

用於常見緯度和經度計算的輕量級程式庫

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
133萬
喜歡數
403
Pub 分數
150

安裝套件

flutter pub add latlong2

套件介紹

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

latlong2 是一個輕量級的 Dart 庫,專為高效且精確的緯度與經度計算而設計。它提供基本的地物空間工具,例如距離計算、中點確定與座標轉換。此庫以效能與簡潔為設計核心,支援 Android、iOS、Web、macOS、Windows 與 Linux 等多個平台。對於需要基礎地理定位運算卻不希望有大型地圖框架開銷的應用程式而言,這是一個理想的選擇。其清晰的 API 讓整合至 Flutter 專案變得輕鬆簡單。

適用情境

  • 計算兩個坐標之間的距離
  • 查找位置之間的中點
  • 在座標格式之間轉換
  • 地理圍欄和近距離檢測
  • 基於地圖的應用開發

主要特色

  • 輕量且快速
  • 跨平台支援
  • 簡單直覺的 API
  • 支援常見的地理空間操作
  • 無外部依賴

適合對象

  • 需要地理定位計算的 Flutter 應用
  • 開發地圖功能的開發者
  • 需要最少地理空間邏輯的專案
  • 原型設計基於位置的服務
  • 針對多個平台的應用程式

使用建議

  • 不包含完整的地圖渲染
  • 僅限基本地理空間計算
  • 無內建地理編碼或反向地理編碼
  • 不適合複雜的GIS任務
  • 需要手動處理極點等邊緣情況

原始 README

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

This is a fork of https://github.com/MikeMitterer/dart-latlong. The goal is to keep it up to date with Dart language changes.

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 = Distance();

// km = 423
final double km = distance.as(LengthUnit.kilometer,
    LatLng(52.518611, 13.408056), LatLng(51.519475, 7.46694444));

// meter = 422591.551
final double meter = distance(
  LatLng(52.518611, 13.408056),
  LatLng(51.519475, 7.46694444),
);

Offset

final Distance distance = const Distance();
final num distanceInMeter = (earthRadius * pi / 4).round();

final p1 = 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 = 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

   https://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

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案