geohashtree 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

GeohashTree #

Dart GeohashTree #

Pub Version Master

GeohashTree is a tree implimentation to speed up spacial queries through geohash indexing. This is useful for dynamically querying small selections of locations in a certain radius for example to display in a map as the user scrolls. The GeohashTree can have a variable depth with the default set at 9. This corresponds to a geohash of precision or length 9.

Install #

To get this plugin, add geohashtree as a dependency in your pubspec.yaml file. For example:

  geohashtree: ^1.0.2

Usage #

It is possible to add spatial based values to the tree with a geohash or directly with lat lng coordinates.

import 'package:geohashtree/geohashtree.dart';

GeohashTree<String> tree = GeohashTree<String>(); 
tree.add("6g3mc", "iguazu"); 
tree.addLatLng(-25.686667, -54.444722, "also iguazu");

To get all the coordinates in a tree within a radius of 5000 meters from the point 25.6953° S, 54.4367° W use getGeohashesByProximity(). The precision parameter dictates how specific the geohash match should be. Precision 5 return matches of geohash of length 5, which in this case would be all geohashes that start with "6g3mc". Precision 1 return matches of geohash of length 1, which in this case would be all geohashes that start with "6".

List<String> values = tree.getGeohashesByProximity(-25.686667, -54.444722,5000, precision: 9);

Issues #

Please file any issues, bugs or feature requests as an issue on our GitHub page.

Want to contribute #

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature) submit a pull request.

[1.0.2] #

  • Added updateLatLng method

[1.0.1] #

  • Minor fixes

[1.0.0] #

  • Initial release.


import 'package:geohashtree/geohashtree.dart';

void main() { 

  // initialize tree
  GeohashTree<String> tree = GeohashTree<String>(); 

  // add values to the tree
  tree.add("6g3mc", "iguazu"); 
  tree.addLatLng(-25.686667, -54.444722, "also iguazu");

  //update value 
  tree.update("6g3mc", (s)=>"iguazu_falls");  
  tree.updateLatLng(-25.686667, -54.444722, (s)=>"iguazu_falls");  

  //get value

  //get all values and geohashes

  //get all values in specific radius
  List<String> values = tree.getGeohashesByProximity(-25.686667, -54.444722,5000, precision: 9);

  //remove geohahs from the tree

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  geohashtree: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:geohashtree/geohashtree.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Health suggestions

Format lib/geohashtree.dart.

Run dartfmt to format lib/geohashtree.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
dart_geohash ^1.0.2 1.0.2
proximity_hash ^1.0.1 1.0.1
Dev dependencies
test ^1.2.0