Class MortonEncoder


  • public class MortonEncoder
    extends Object
    Quantizes lat/lon points and bit interleaves them into a binary morton code in the range of 0x00000000... : 0xFFFFFFFF... https://en.wikipedia.org/wiki/Z-order_curve This is useful for bitwise operations in raster space
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double decodeLatitude​(long hash)
      decode latitude value from morton encoded geo point
      static double decodeLongitude​(long hash)
      decode longitude value from morton encoded geo point
      static long encode​(double latitude, double longitude)
      Main encoding method to quantize lat/lon points and bit interleave them into a binary morton code in the range of 0x00000000...
      static long encodeCeil​(double latitude, double longitude)
      Quantizes lat/lon points and bit interleaves them into a sortable morton code ranging from 0x00 : 0xFF...
      static String geoTermToString​(long term)
      Converts a long value into a full 64 bit string (useful for debugging)
    • Method Detail

      • encode

        public static final long encode​(double latitude,
                                        double longitude)
        Main encoding method to quantize lat/lon points and bit interleave them into a binary morton code in the range of 0x00000000... : 0xFFFFFFFF...
        Parameters:
        latitude - latitude value: must be within standard +/-90 coordinate bounds.
        longitude - longitude value: must be within standard +/-180 coordinate bounds.
        Returns:
        bit interleaved encoded values as a 64-bit long
        Throws:
        IllegalArgumentException - if latitude or longitude is out of bounds
      • encodeCeil

        public static final long encodeCeil​(double latitude,
                                            double longitude)
        Quantizes lat/lon points and bit interleaves them into a sortable morton code ranging from 0x00 : 0xFF... https://en.wikipedia.org/wiki/Z-order_curve This is useful for bitwise operations in raster space
        Parameters:
        latitude - latitude value: must be within standard +/-90 coordinate bounds.
        longitude - longitude value: must be within standard +/-180 coordinate bounds.
        Returns:
        bit interleaved encoded values as a 64-bit long
        Throws:
        IllegalArgumentException - if latitude or longitude is out of bounds
      • decodeLatitude

        public static final double decodeLatitude​(long hash)
        decode latitude value from morton encoded geo point
      • decodeLongitude

        public static final double decodeLongitude​(long hash)
        decode longitude value from morton encoded geo point
      • geoTermToString

        public static String geoTermToString​(long term)
        Converts a long value into a full 64 bit string (useful for debugging)