h3ToFeature method
Converts a single H3 hexagon with index h3Index
to a Polygon
feature
It's possible to add optional feature properties
Implementation
Map h3ToFeature(BigInt h3Index, {Map? properties}) {
final boundary = _h3.h3ToGeoBoundary(h3Index);
// Wrap in an array for a single-loop polygon
final coordinates = [
[
for (final b in boundary) [b.lon, b.lat],
[boundary.first.lon, boundary.first.lat],
],
];
return {
'type': _feature,
'id': h3Index.toString(),
'geometry': {
'type': _polygon,
'coordinates': coordinates,
},
'properties': properties ?? {},
};
}