function geoJsonToCells()

in website/src/components/explorer/index.tsx [72:104]


function geoJsonToCells(
  geoJson: Feature | Polygon | MultiPolygon,
  userResolution: number,
) {
  // TODO: Handle point geometries, lines, etc. Only polygons and multipolygons supported.
  // TODO: Pass containment in to featureToH3Set.
  if (geoJson.type === "Polygon" || geoJson.type === "MultiPolygon") {
    geoJson = {
      type: "Feature",
      geometry: geoJson,
    } as Feature;
  }

  const hasUserResolution = userResolution !== -1;

  for (let res = 0; res < 16; res++) {
    const cells = geojson2h3.featureToH3Set(geoJson, res);
    if (
      (!hasUserResolution &&
        (cells.length > CELL_COUNT_THRESHOLD || res === 15)) ||
      (hasUserResolution &&
        (cells.length > CELL_COUNT_UPPER_THRESHOLD || res === userResolution))
    ) {
      return {
        splitUserInput: cells,
        showCellId: false,
        showResolutionInput: res,
        inputGeoJson: geoJson,
      };
    }
  }
  return null;
}