Class XYEncodingUtils


  • public final class XYEncodingUtils
    extends java.lang.Object
    reusable cartesian geometry encoding methods
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private XYEncodingUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkVal​(double x)
      validates value is within +/-Float.MAX_VALUE coordinate bounds
      static double decode​(byte[] src, int offset)
      Turns quantized value from byte array back into a double.
      static double decode​(int encoded)
      Turns quantized value from encode(double) back into a double.
      static int encode​(double x)
      Quantizes double (64 bit) values into 32 bits
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XYEncodingUtils

        private XYEncodingUtils()
    • Method Detail

      • checkVal

        public static void checkVal​(double x)
        validates value is within +/-Float.MAX_VALUE coordinate bounds
      • encode

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

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

        public static double 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.