h3_dart 0.7.0 copy "h3_dart: ^0.7.0" to clipboard
h3_dart: ^0.7.0 copied to clipboard

The package provides Dart version of the H3 Core library, a hexagon-based geographic grid system

Build & Test codecov License: Apache 2.0

H3 Dart #

If you are building a Flutter app use h3_flutter instead.

A platform neutral wrapper around Uber's H3 library. Internally it delegates to h3_ffi on the VM and to h3_web on the web.

final h3Factory = const H3Factory();
const kIsWeb = identical(0, 0.0); // taken from https://api.flutter.dev/flutter/foundation/kIsWeb-constant.html
final h3 = kIsWeb 
  ? h3Factory.web() 
  : h3Factory.byPath('path/to/library.dll');
// Get hexagons in specified triangle.
final hexagons = h3.polyfill(
  resolution: 5,
  coordinates: [
    GeoCoord(20.4522, 54.7104),
    GeoCoord(37.6173, 55.7558),
    GeoCoord(39.7015, 47.2357),
  ],
);

There are also few methods ported from JS library Geojson2H3, to access them you should instantiate Geojson2H3 class using const Geojson2H3(h3). It uses package:geojson2h3 internally.

Setup #

If you are building a Flutter app use h3_flutter instead.

VM #

  1. Build the native library using scripts/build_h3.sh or compile the C source manually. The h3_ffi/c directory has a git submodule pointing to the original H3 repository, pinned to the correct version.

  2. Load the compiled binary with H3Factory().byPath():

    final h3 = const H3Factory().byPath('path/to/library.dll')
    

Web #

  1. Include h3-js in your index.html:

    <script defer src="https://unpkg.com/h3-js@4.2.1"></script>
    

    Note, main.dart.js import should go after this line

  2. Load the web implementation:

    final h3 = const H3Factory().web();
    
3
likes
160
points
183
downloads

Publisher

verified publisherfestelo.net

Weekly Downloads

The package provides Dart version of the H3 Core library, a hexagon-based geographic grid system

Repository (GitHub)
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

ffi, geojson2h3, h3_common, h3_ffi, h3_web

More

Packages that depend on h3_dart