org.apache.lucene.spatial.util

## Class GeoEncodingUtils

- java.lang.Object
- - org.apache.lucene.spatial.util.GeoEncodingUtils

-     public final class GeoEncodingUtils
      extends Object

  Basic reusable geopoint encoding methods
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static short` | `BITS` number of bits used for quantizing latitude and longitude values
    `static int` | `BUF_SIZE_LONG` The maximum term length (used for `byte[]` buffer size) for encoding `geoEncoded` values.
    `static double` | `TOLERANCE` rounding error for quantized latitude and longitude values

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static double` | `compare(double v1, double v2)` Compare two position values within a `TOLERANCE` factor
    `protected static long` | `fromBytes(byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7, byte b8)` Converts 8 bytes to a long value
    `static void` | `geoCodedToPrefixCoded(long hash, int shift, BytesRefBuilder bytes)` Convert a geocoded morton long into a prefix coded geo term
    `static String` | `geoTermToString(long term)` Converts a long value into a bit string (useful for debugging)
    `static int` | `getPrefixCodedShift(BytesRef val)` Get the prefix coded geo term shift value
    `static Long` | `mortonHash(double lon, double lat)`
    `static double` | `mortonUnhashLat(long hash)`
    `static double` | `mortonUnhashLon(long hash)`
    `static long` | `prefixCodedToGeoCoded(BytesRef val)` Convert a prefix coded geo term back into the geocoded morton long
    `protected static long` | `scaleLat(double val)`
    `protected static long` | `scaleLon(double val)`
    `protected static double` | `unscaleLat(long val)`
    `protected static double` | `unscaleLon(long val)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BITS

          public static final short BITS

      number of bits used for quantizing latitude and longitude values
      See Also:
        Constant Field Values

    - #### BUF_SIZE_LONG

          public static final int BUF_SIZE_LONG

      The maximum term length (used for `byte[]` buffer size) for encoding `geoEncoded` values.
      See Also:
        `geoCodedToPrefixCodedBytes(long, int, BytesRefBuilder)`, Constant Field Values

    - #### TOLERANCE

          public static final double TOLERANCE

      rounding error for quantized latitude and longitude values
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### mortonHash

          public static final Long mortonHash(double lon,
                        double lat)

    - #### mortonUnhashLon

          public static final double mortonUnhashLon(long hash)

    - #### mortonUnhashLat

          public static final double mortonUnhashLat(long hash)

    - #### scaleLon

          protected static final long scaleLon(double val)

    - #### scaleLat

          protected static final long scaleLat(double val)

    - #### unscaleLon

          protected static final double unscaleLon(long val)

    - #### unscaleLat

          protected static final double unscaleLat(long val)

    - #### compare

          public static double compare(double v1,
                       double v2)

      Compare two position values within a `TOLERANCE` factor

    - #### geoCodedToPrefixCoded

          public static void geoCodedToPrefixCoded(long hash,
                                   int shift,
                                   BytesRefBuilder bytes)

      Convert a geocoded morton long into a prefix coded geo term

    - #### prefixCodedToGeoCoded

          public static long prefixCodedToGeoCoded(BytesRef val)

      Convert a prefix coded geo term back into the geocoded morton long

    - #### getPrefixCodedShift

          public static int getPrefixCodedShift(BytesRef val)

      Get the prefix coded geo term shift value

    - #### fromBytes

          protected static long fromBytes(byte b1,
                       byte b2,
                       byte b3,
                       byte b4,
                       byte b5,
                       byte b6,
                       byte b7,
                       byte b8)

      Converts 8 bytes to a long value

    - #### geoTermToString

          public static String geoTermToString(long term)

      Converts a long value into a bit string (useful for debugging)

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.