OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
h3ToGeo

Functions

EXTENSION_NOINLINE int64_t
H3_EXPORT() 
h3ToGeoPacked (H3Index h3)
 find the lat/lon center point g of the cell h3 More...
 
EXTENSION_NOINLINE double
H3_EXPORT() 
h3ToLon (H3Index h3)
 
EXTENSION_NOINLINE double
H3_EXPORT() 
h3ToLat (H3Index h3)
 

Detailed Description

Functions for h3ToGeo

Function Documentation

EXTENSION_NOINLINE int64_t H3_EXPORT() h3ToGeoPacked ( H3Index  h3)

find the lat/lon center point g of the cell h3

Determines the WGS84 lat/lon coordinates of the center point of an H3 index packed into a 9.22 fixed-point value. This allows 6 decimal places of precision, which equates to a maximum error of 111.32 millimeters at the equator.

To unpack: lon = ((packed_int & 0xffffffff) / 1000000.0) - 180.0 lat = ((packed_int >> 32) / 1000000.0) - 90.0

Parameters
h3The H3 index.
Returns
64-bit int packed with the lat/lon coordinates

Definition at line 853 of file h3Index.hpp.

References _h3ToGeo(), GeoCoord, LAT_INDEX, LON_INDEX, and radsToDegs().

853  {
854  GeoCoord(g);
855  _h3ToGeo(h3, g);
856 
857  // and pack as two 9.22 fixed-point values into 64-bits. Going to preserve 6 decimal
858  // places (hence the 1000000.0 magic number). Lon range will be 0-360 and lat 0-180 in
859  // order to keep the cast to int64_t positive for easier packing. We could add extra
860  // precision if we use a uint64_t, but unfortunately uint64_t is an unsupported type
861  // thru calcite. The +0.5 is for rounding.
862  int64_t decimal_lon =
863  static_cast<int64_t>((radsToDegs(g[LON_INDEX]) + 180.0f) * 1000000.0 + 0.5);
864  int64_t decimal_lat =
865  static_cast<int64_t>((radsToDegs(g[LAT_INDEX]) + 90.f) * 1000000.0 + 0.5);
866  return (decimal_lon & 0xFFFFFFFF) | ((decimal_lat & 0XFFFFFFFF) << 32);
867 }
EXTENSION_NOINLINE bool _h3ToGeo(H3Index h3, GeoCoord(g))
Definition: h3Index.hpp:834
#define GeoCoord(variable_name)
Definition: h3api.h:94
EXTENSION_INLINE double H3_EXPORT() radsToDegs(double radians)
converts radians to degrees
Definition: geoCoord.hpp:111
#define LAT_INDEX
Definition: h3api.h:92
#define LON_INDEX
Definition: h3api.h:93

+ Here is the call graph for this function:

EXTENSION_NOINLINE double H3_EXPORT() h3ToLat ( H3Index  h3)

Determines the WGS84 longitude coordinate of the center point of an H3 index.

Parameters
h3The H3 index.
Returns
WGS84 latitude in double precision

Definition at line 887 of file h3Index.hpp.

References _h3ToGeo(), GeoCoord, LAT_INDEX, and radsToDegs().

887  {
888  GeoCoord(g);
889  _h3ToGeo(h3, g);
890  return radsToDegs(g[LAT_INDEX]);
891 }
EXTENSION_NOINLINE bool _h3ToGeo(H3Index h3, GeoCoord(g))
Definition: h3Index.hpp:834
#define GeoCoord(variable_name)
Definition: h3api.h:94
EXTENSION_INLINE double H3_EXPORT() radsToDegs(double radians)
converts radians to degrees
Definition: geoCoord.hpp:111
#define LAT_INDEX
Definition: h3api.h:92

+ Here is the call graph for this function:

EXTENSION_NOINLINE double H3_EXPORT() h3ToLon ( H3Index  h3)

Determines the WGS84 longitude coordinate of the center point of an H3 index.

Parameters
h3The H3 index.
Returns
WGS84 longitude in double precision

Definition at line 875 of file h3Index.hpp.

References _h3ToGeo(), GeoCoord, LON_INDEX, and radsToDegs().

875  {
876  GeoCoord(g);
877  _h3ToGeo(h3, g);
878  return radsToDegs(g[LON_INDEX]);
879 }
EXTENSION_NOINLINE bool _h3ToGeo(H3Index h3, GeoCoord(g))
Definition: h3Index.hpp:834
#define GeoCoord(variable_name)
Definition: h3api.h:94
EXTENSION_INLINE double H3_EXPORT() radsToDegs(double radians)
converts radians to degrees
Definition: geoCoord.hpp:111
#define LON_INDEX
Definition: h3api.h:93

+ Here is the call graph for this function: