geo_triangle_grid 1.1.1 copy "geo_triangle_grid: ^1.1.1" to clipboard
geo_triangle_grid: ^1.1.1 copied to clipboard

A package for creating a triangle grid on a map and converting them into hash for fast search.

A package for creating a triangle grid on a map. The grid is created by dividing the map into icosphere with 20 triangles and each triangle is divided into 4 smaller triangles and so on.

Features #

  • Create triangle from location (latitude, longitude)
  • Create location from triangle
  • Get center of triangle
  • Get triangles of specified depth in bounds

Getting started #

Install the package by adding the following to your pubspec.yaml:

geo_triangle_grid: ^1.1.1

Import the package in your code:

import 'package:geo_triangle_grid/geo_triangle_grid.dart';

Usage #

Here is a simple example of usage:

final location = LatLng(51.507351, -0.127758);
final triangleHash = TriangleGrid.latLngToHash(location);
print(triangleHash);
// prints: F203320022
final triangle = TriangleGrid.hashToLatLngTriangle(triangleHash);
print(triangle);
// prints: LatLng(latitude: 51.507351,  longitude: -0.127758)

TriangleGrid.latLngToHash #

Converts a location to a triangle hash. The second parameter is optional and it is the length of the triangle grid. If not provided, the default value is 20.

String TriangleGrid.latLngToHash(LatLng location, [ int depth = 20 ]);

TriangleGrid.hashToLatLngTriangle #

Converts a triangle hash to a triangle with points.

LatLngTriangle TriangleGrid.latLngToHash(String hash);

TriangleGrid.hashToLatLng #

Converts a triangle hash to a location.

LatLng TriangleGrid.hashToLatLng(String hash);

LatLngTriangle.center #

Gets the center of the triangle.

LatLng get LatLngTriangle.center;

Aditional methods #

Package also provides some additional methods to work with vectors and triangles. All of them have documentation, you can find them in the API Reference.

2
likes
160
points
42
downloads

Publisher

unverified uploader

Weekly Downloads

A package for creating a triangle grid on a map and converting them into hash for fast search.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on geo_triangle_grid