@erikmichelson/open-location-code-ts
    Preparing search index...

    Function shorten

    • Remove characters from the start of an OLC code.

      This uses a reference location to determine how many initial characters can be removed from the OLC code. The number of characters that can be removed depends on the distance between the code center and the reference location.

      Parameters

      • code: string

        The full code to shorten.

      • latitude: number

        The latitude to use for the reference location.

      • longitude: number

        The longitude to use for the reference location.

      Returns string

      The code, shortened as much as possible that it is still the closest matching code to the reference location.

      if the passed code is not a valid full code or the reference location values are not numbers.