Class XYEncodingUtils

java.lang.Object
org.apache.lucene.geo.XYEncodingUtils

public final class XYEncodingUtils extends Object
reusable cartesian geometry encoding methods
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final double
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static float
    checkVal(float x)
    validates value is a number and finite
    static float
    decode(byte[] src, int offset)
    Turns quantized value from byte array back into a double.
    static float
    decode(int encoded)
    Turns quantized value from encode(float) back into a double.
    static int
    encode(float x)
    Quantizes double (64 bit) values into 32 bits
    static double[]
    Convert an array of float numbers to double numbers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • XYEncodingUtils

      private XYEncodingUtils()
  • Method Details

    • checkVal

      static float checkVal(float x)
      validates value is a number and finite
    • encode

      public static int encode(float x)
      Quantizes double (64 bit) values into 32 bits
      Parameters:
      x - cartesian value
      Returns:
      encoded value as a 32-bit int
      Throws:
      IllegalArgumentException - if value is out of bounds
    • decode

      public static float decode(int encoded)
      Turns quantized value from encode(float) back into a double.
      Parameters:
      encoded - encoded value: 32-bit quantized value.
      Returns:
      decoded value value.
    • decode

      public static float decode(byte[] src, int offset)
      Turns quantized value from byte array back into a double.
      Parameters:
      src - byte array containing 4 bytes to decode at offset
      offset - offset into src to decode from.
      Returns:
      decoded value.
    • floatArrayToDoubleArray

      public static double[] floatArrayToDoubleArray(float[] f)
      Convert an array of float numbers to double numbers.
      Parameters:
      f - The input floats
      Returns:
      Corresponding double array.