Skip to content

H3-Placekey round trip generating invalid results #44

@craig-walker-orennia

Description

@craig-walker-orennia

We've discovered that converting a valid H3 Index to a Placekey and then converting it back generates an invalid H3 Index. Here's a test example:

import { h3ToPlacekey, placekeyToH3 } from '@placekey/placekey'
import { isValidCell } from "h3-js"

const h3Input = "847b59dffffffff"
const placekey = h3ToPlacekey(h3Input)
const h3Output = placekeyToH3(placekey)
console.log({
  validInput: isValidCell(h3Input),
  h3Input,
  placekey,
  h3Output,
  validOutput: isValidCell(h3Output),
})

Output:

{
  validInput: true,
  h3Input: '847b59dffffffff',
  placekey: '@ff7-swh-m49',
  h3Output: '8a7b59dffffffff',
  validOutput: false
}

Note that the output index is only different in the 2nd digit; 4 changes to an a.

We first discovered this using the Carto spatial library for Snowflake, which uses Placekey and H3 under the covers: https://docs.carto.com/data-and-analysis/analytics-toolbox-for-snowflake/sql-reference/placekey. The same bug exists there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions