패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.0

georange

지오해시 인코딩, 디코딩, 두 지점 간 거리 계산 및 데이터베이스 쿼리에 도움이 되는 위도 및 경도 범위를 지오해시로 생성하는 데 도움을 주는 패키지(단 Firestore에서만 테스트됨).

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
263
좋아요
33
Pub 점수
150

패키지 설치

flutter pub add georange

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

georange는 지리 정보 작업을 위한 Flutter/Dart 패키지로, 지오해시 인코딩 및 디코딩, 두 지리적 점 사이의 거리 계산, 위도와 경도 범위를 지오해시로 생성하는 기능을 제공합니다. 이러한 기능은 지오스페이셜 애플리케이션에서 데이터베이스 쿼리를 최적화하는 데 특히 유용하며, Firestore에 특화된 테스트 및 최적화가 수행되었습니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하여 크로스플랫폼 개발에 매우 유연하게 활용할 수 있습니다.

사용 사례

  • 지리공간 데이터 인덱싱
  • Firestore 기반 위치 쿼리
  • 좌표 간 거리 계산
  • 실시간 위치 추적
  • 위치 인식 검색 기능
  • 효율적인 범위 기반 데이터베이스 필터링

주요 기능

  • 지오해시 인코딩 및 디코딩
  • 두 점 사이의 거리 계산
  • 쿼리용 지오해시 범위 생성
  • Firestore에 최적화됨
  • 크로스 플랫폼 호환성
  • 지리공간 연산을 위한 간단한 API

적합한 대상

  • 위치 기반 앱을 개발하는 개발자
  • 효율적인 지리공간 데이터베이스 쿼리를 필요로 하는 앱
  • 지리 정보 데이터를 사용하는 Firestore 프로젝트
  • 크로스 플랫폼 모바일 및 웹 애플리케이션
  • 빠른 근접 검색이 필요한 애플리케이션

고려 사항

  • 주로 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();

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.