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:

dependencies:
  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.

example/main.dart

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
  tree.getGeohash("6g3mc");

  //get all values and geohashes
  tree.geohashes;
  tree.values;

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

  //remove geohahs from the tree
  tree.remove("6g3mc");
  tree.removeWhere((geohash,value)=>geohash=="6g3mc");
  
}

Use this package as a library

1. Depend on it

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


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
60
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.

Dependencies

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