georange
지오해시 인코딩, 디코딩, 두 지점 간 거리 계산 및 데이터베이스 쿼리에 도움이 되는 위도 및 경도 범위를 지오해시로 생성하는 데 도움을 주는 패키지(단 Firestore에서만 테스트됨).
지오해시의 인코딩 및 디코딩을 도와주는 패키지입니다.
any아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
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
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
There is a detailed example project in the example folder.
Import georange to your dart file and initialize
import 'package:georange/georange.dart';
GeoRange georange = GeoRange();
This method encodes the latitude and longitude
var encoded = georange.encode(-1.2862368,36.8195783);
print(encoded);
prints kzf0tvg5n
Decode a [geohash] into a pair of latitude and longitude.
Point decoded = georange.decode("kzf0tvg5n");
print(decoded);
prints
-1.2862372398376465
36.819584369659424
Range range = georange.geohashRange(-1.2921, 36.8219, distance: 10);
print(range.lower);
print(range.upper);
prints
kzf05k6hh
kzf30mptu
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
geohash field or a different name final FirebaseFirestore _db;
...
String myhash = georange.encode(-1.2862368,36.8195783);
await _db.collection("locations").add({
"geohash":myhash,
})
...
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();