Package org.apache.lucene.geo
Class XYEncodingUtils
java.lang.Object
org.apache.lucene.geo.XYEncodingUtils
reusable cartesian geometry encoding methods
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
static final double
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
decode
(byte[] src, int offset) Turns quantized value from byte array back into a double.static float
decode
(int encoded) Turns quantized value fromencode(float)
back into a double.static int
encode
(float x) Quantizes double (64 bit) values into 32 bitsstatic double[]
floatArrayToDoubleArray
(float[] f) Convert an array offloat
numbers todouble
numbers.
-
Field Details
-
MIN_VAL_INCL
public static final double MIN_VAL_INCL- See Also:
-
MAX_VAL_INCL
public static final double MAX_VAL_INCL- See Also:
-
-
Method Details
-
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 fromencode(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 atoffset
offset
- offset intosrc
to decode from.- Returns:
- decoded value.
-
floatArrayToDoubleArray
public static double[] floatArrayToDoubleArray(float[] f) Convert an array offloat
numbers todouble
numbers.- Parameters:
f
- The input floats- Returns:
- Corresponding double array.
-