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

套件詳情v3.1.0

google_polyline_algorithm

Google 多線段編碼壓縮演算法的 Dart 實現,一種損失性壓縮演算法。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2.9萬
喜歡數
55
Pub 分數
160

安裝套件

flutter pub add google_polyline_algorithm

套件介紹

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

Google 的 Polyline 編碼演算法的 Dart 實作,用於將緯度與經度座標壓縮為緊湊的字串格式。這種損失性壓縮可減少地圖路徑的資料大小,非常適合在地理定位應用中進行高效傳輸與儲存。此套件支援所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux。讓開發者能以最小的開銷編碼與解碼折線,同時維持大多數地圖使用情境所需的足夠準確度。

適用情境

  • 地圖路線可視化
  • 高效能的GPS資料傳輸
  • 地理路徑的緊湊儲存
  • 即時位置追蹤
  • 地理空間資料分享
  • 離線地圖資料

主要特色

  • 有損座標壓縮
  • 跨平台支援
  • 簡單的編碼/解碼 API
  • 高效能
  • 適用於典型的地圖距離
  • 輕量級依賴

適合對象

  • 行動與Web地圖應用
  • 基於位置的服務
  • 路線規劃工具
  • 高效資料的地理空間 API
  • 處理大型GPS數據集的應用程式

使用建議

  • 由於壓縮導致的精度損失
  • 不適合高精度科學測量
  • 需要仔細處理極端緯度下的邊緣情況
  • 僅限折線幾何
  • 可能需要對關鍵導航系統進行驗證

原始 README

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

google_polyline_algorithm

Build codecov Pub GitHub GitHub stars

Dart implementation of Googles Polyline Encoding lossy compression Algorithm.

Getting Started

This package adds following methods to work with Googles Polyline Encoding Algorithm:

  • encodePoint(num current, {num previous = 0, int accuracyExponent = 5}) encodes a single coordinate

  • encodePolyline(List<List<num>> coordinates, {int accuracyExponent = 5}) encodes a list of coordinates into an encoded polyline stirng

  • decodePolyline(String polyline, {int accuracyExponent = 5}) decodes an encoded polyline string into a list of coordinates

Examples

import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';

final coord = encodePoint(-179.9832104);
print(coord);
// output is `~oia@'

final coords = encodePolyline([
  [38.5, -120.2],
  [40.7, -120.95],
  [43.252, -126.453],
]);
print(coords);
// output is `_p~iF~ps|U_ulLnnqC_mqNvxq`@'

final polyline = decodePolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
print(polyline);
// output is [[38.5, -120.2],[40.7, -120.95],[43.252, -126.453],]

所屬分類

原始碼儲存庫

使用此套件的專案