function getFeatures(bbox, resolution) {
console.log(`Getting features (${resolution})...`);
bbox._nw = { lat: bbox._ne.lat, lng: bbox._sw.lng };
bbox._se = { lat: bbox._sw.lat, lng: bbox._ne.lng };
const fuzzLng = (bbox._se.lng - bbox._sw.lng) * 0.1
const fuzzLat = (bbox._se.lat - bbox._ne.lat) * 0.1
const bboxFeature = ({
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [[
[bbox._sw.lng - fuzzLng, bbox._sw.lat + fuzzLat],
[bbox._nw.lng - fuzzLng, bbox._nw.lat - fuzzLat],
[bbox._ne.lng + fuzzLng, bbox._ne.lat - fuzzLat],
[bbox._se.lng + fuzzLng, bbox._se.lat + fuzzLat],
[bbox._sw.lng - fuzzLng, bbox._sw.lat + fuzzLat]
]]
}
});
const hexagons = geojson2h3.featureToH3Set(bboxFeature, resolution);
const hexPolygon = geojson2h3.h3SetToMultiPolygonFeature(hexagons);
const points = {
"type": "FeatureCollection",
"features": hexagons.map(hex => (
{
"type": "Feature",
"properties": {
"hex": hex
},
"geometry": {
"type": "Point",
"coordinates": h3.h3ToGeo(hex).reverse()
}
}
))
}
console.log("Done Getting features.");
return [hexPolygon, points];
}