パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.0

georange

ジオハッシュのエンコード、デコード、2点間の距離の計算、およびデータベースクエリを支援するための緯度と経度の範囲をジオハッシュとして生成するのに役立つパッケージ(Firestoreでのみテスト済み)。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
263
いいね数
33
Pub ポイント
150

パッケージをインストール

flutter pub add georange

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

georange は、位置情報タスクに特化したFlutter/Dartパッケージであり、ジオハッシュのエンコードおよびデコード、2つの地理座標間の距離の計算、緯度と経度の範囲をジオハッシュとして生成する機能を提供します。これらの機能は、特に地空間アプリケーションにおけるデータベースクエリの最適化に役立ち、Firestore向けに特定のテストと最適化が行われています。このパッケージはAndroid、iOS、Web、macOS、Windows、Linuxなど複数のプラットフォームをサポートしており、クロスプラットフォーム開発に非常に柔軟に対応しています。

用途

  • 地理空間データのインデックス化
  • Firestore をベースとした位置検索
  • 座標間の距離計算
  • リアルタイムでの位置追跡
  • 場所に応じた検索機能
  • 効率的な範囲ベースのデータベースフィルタリング

主な機能

  • ジオハッシュのエンコードとデコード
  • 2点間の距離計算
  • クエリ用のジオハッシュ範囲の生成
  • Firestore 向けに最適化されています
  • クロスプラットフォーム互換性
  • 地理空間操作のためのシンプルな API

適している対象

  • 場所ベースのアプリを開発する開発者
  • 効率的な地理空間データベースクエリを必要とするアプリ
  • 地図データを含むFirestoreを使用するプロジェクト
  • クロスプラットフォームのモバイルおよびWebアプリケーション
  • 迅速な近接検索を必要とするアプリケーション

注意事項

  • 主にFirestoreでテストされました
  • ジオハッシュベースの空間インデックスに制限される
  • ジオハッシュの概念を理解する必要があります
  • 非地理空間データベース向けに最適化されていません
  • 正確な座標入力に依存します
  • エッジケースの地理空間クエリには追加の論理が必要になる可能性があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

georange

Dart License: MIT Pub Version

Georange is a package that helps with encoding geohashes, decoding geohashes,calculating distance between 2 points and generating latitudinal and longitudinal ranges as geohashes to help with the querying of databases (Tested on Firestore Only).

Heavily influenced by GeoFlutterFire

Buy Me A Coffee

Getting Started

You should ensure that you add Georange as a dependency in your flutter project.

dependencies:
  georange: <latest-version>

You should then run flutter packages get

Example

There is a detailed example project in the example folder.

Initialize

Import georange to your dart file and initialize

import 'package:georange/georange.dart';
GeoRange georange = GeoRange();
Encode LatLng

This method encodes the latitude and longitude

var encoded = georange.encode(-1.2862368,36.8195783);
print(encoded);

prints kzf0tvg5n

Decode Geohash

Decode a [geohash] into a pair of latitude and longitude.

Point decoded = georange.decode("kzf0tvg5n");
print(decoded);

prints -1.2862372398376465 36.819584369659424

Generate Range
  Range range = georange.geohashRange(-1.2921, 36.8219, distance: 10);
  print(range.lower);
  print(range.upper);

prints kzf05k6hh kzf30mptu

Calculate Distance between 2 Points
  Point point1 = Point(latitude: -4.0435, longitude: 39.6682); //Mombasa
  Point point2 = Point(latitude: -1.2921, longitude: 36.8219); // Nairobi

  var distance = georange.distance(point1, point2);
  print(distance);

prints 439.716 Distance in Kilometres

Usage with Firestore

  1. Add a document to firestore with a geohash field or a different name
  final FirebaseFirestore _db;
  ...
  String myhash = georange.encode(-1.2862368,36.8195783);
  await _db.collection("locations").add({
    "geohash":myhash,
  })
  ...
  1. Query Firestore (Runs like a normal firestore query)
final FirebaseFirestore _db;

GeoRange georange = GeoRange();

Range range = georange.geohashRange(currentLocation.latitude, currentLocation.longitude, distance:10);

QuerySnapshot snapshot = await _db
 .collection("locations")
 .where("geohash", isGreaterThanOrEqualTo: range.lower)
 .where("geohash", isLessThanOrEqualTo: range.upper)
 .limit(10)
 .get();

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。