OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geo Namespace Reference

Classes

struct  Point2D
 
struct  GeoNestedArray
 
struct  LineString
 
struct  MultiPoint
 
struct  MultiLineString
 
struct  Polygon
 
struct  MultiPolygon
 

Functions

DEVICE int32_t compress_x_coord (const double *x, const int64_t index)
 
DEVICE int32_t compress_y_coord (const double *x, const int64_t index)
 
DEVICE double decompress_x_coord (const int8_t *data, const int64_t index, const bool is_geoint)
 
DEVICE double decompress_y_coord (const int8_t *data, const int64_t index, const bool is_geoint)
 
DEVICE double decompress_x_coord (const int8_t *data, const int64_t index, const bool is_geoint, const int32_t input_srid, const int32_t output_srid)
 
DEVICE double decompress_y_coord (const int8_t *data, const int64_t index, const bool is_geoint, const int32_t input_srid, const int32_t output_srid)
 
DEVICE Point2D get_point (const int8_t *data, const int64_t index, const int32_t input_srid, const int32_t output_srid, const bool is_geoint)
 
template<typename CT >
void points_to_vector (const int8_t *points_buf, const int64_t nof_points, const bool is_geoint, std::vector< CT > &result)
 
std::vector< int32_t > compress_coords (const int8_t *data, const int64_t size, const bool is_geoint)
 
std::vector< double > decompress_coords (const int8_t *data, const int64_t size, const bool is_geoint)
 
std::vector< int32_t > compress_coords (const std::vector< double > &coords)
 
std::vector< double > decompress_coords (const std::vector< int32_t > &coords)
 
std::vector< std::vector
< int32_t > > 
compress_coords (const std::vector< std::vector< double >> &coords)
 
std::vector< std::vector
< double > > 
decompress_coords (const std::vector< std::vector< int32_t >> &coords)
 
std::vector< std::vector
< std::vector< int32_t > > > 
compress_coords (const std::vector< std::vector< std::vector< double >>> &coords)
 
std::vector< std::vector
< std::vector< double > > > 
decompress_coords (const std::vector< std::vector< std::vector< int32_t >>> &coords)
 
bool get_is_geoint (const int8_t *flatbuffer)
 
int32_t get_input_srid (const int8_t *flatbuffer)
 
int32_t get_output_srid (const int8_t *flatbuffer)
 

Function Documentation

std::vector<int32_t> Geo::compress_coords ( const int8_t *  data,
const int64_t  size,
const bool  is_geoint 
)
inline

Definition at line 1818 of file heavydbTypes.h.

References compress_x_coord(), compress_y_coord(), and run_benchmark_import::result.

Referenced by compress_coords(), and Geo::GeoNestedArray< Point2D >::fromCoordsWorker().

1820  {
1821  int64_t nofpoints = size / (is_geoint ? sizeof(int32_t) * 2 : sizeof(double) * 2);
1822  std::vector<int32_t> result;
1823  result.reserve(2 * nofpoints);
1824  if (is_geoint) {
1825  const int32_t* buf = reinterpret_cast<const int32_t*>(data);
1826  result.assign(buf, buf + 2 * nofpoints);
1827  } else {
1828  const double* buf = reinterpret_cast<const double*>(data);
1829  for (int64_t i = 0; i < nofpoints; i++) {
1830  result.push_back(compress_x_coord(buf, 2 * i));
1831  result.push_back(compress_y_coord(buf, 2 * i));
1832  }
1833  }
1834  return result;
1835 }
DEVICE int32_t compress_x_coord(const double *x, const int64_t index)
DEVICE int32_t compress_y_coord(const double *x, const int64_t index)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<int32_t> Geo::compress_coords ( const std::vector< double > &  coords)
inline

Definition at line 1850 of file heavydbTypes.h.

References compress_x_coord(), compress_y_coord(), and run_benchmark_import::result.

1850  {
1851  std::vector<int32_t> result;
1852  const size_t nofpoints = coords.size() / 2;
1853  result.reserve(coords.size());
1854  const double* buf = coords.data();
1855  for (size_t i = 0; i < nofpoints; i++) {
1856  result.push_back(compress_x_coord(buf, 2 * i));
1857  result.push_back(compress_y_coord(buf, 2 * i));
1858  }
1859  return result;
1860 }
DEVICE int32_t compress_x_coord(const double *x, const int64_t index)
DEVICE int32_t compress_y_coord(const double *x, const int64_t index)

+ Here is the call graph for this function:

std::vector<std::vector<int32_t> > Geo::compress_coords ( const std::vector< std::vector< double >> &  coords)
inline

Definition at line 1874 of file heavydbTypes.h.

References compress_coords(), and run_benchmark_import::result.

1875  {
1876  std::vector<std::vector<int32_t>> result;
1877  result.reserve(coords.size());
1878  for (size_t i = 0; i < coords.size(); i++) {
1879  result.push_back(compress_coords(coords[i]));
1880  }
1881  return result;
1882 }
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52

+ Here is the call graph for this function:

std::vector<std::vector<std::vector<int32_t> > > Geo::compress_coords ( const std::vector< std::vector< std::vector< double >>> &  coords)
inline

Definition at line 1894 of file heavydbTypes.h.

References compress_coords(), and run_benchmark_import::result.

1895  {
1896  std::vector<std::vector<std::vector<int32_t>>> result;
1897  result.reserve(coords.size());
1898  for (size_t i = 0; i < coords.size(); i++) {
1899  result.push_back(compress_coords(coords[i]));
1900  }
1901  return result;
1902 }
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
Definition: Compression.cpp:52

+ Here is the call graph for this function:

DEVICE int32_t Geo::compress_x_coord ( const double *  x,
const int64_t  index 
)
inline

Definition at line 1705 of file heavydbTypes.h.

References Geospatial::compress_longitude_coord_geoint32().

Referenced by compress_coords(), and points_to_vector().

1705  {
1706  return static_cast<int32_t>(Geospatial::compress_longitude_coord_geoint32(x[index]));
1707 }
DEVICE uint64_t compress_longitude_coord_geoint32(const double coord)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE int32_t Geo::compress_y_coord ( const double *  x,
const int64_t  index 
)
inline

Definition at line 1709 of file heavydbTypes.h.

References Geospatial::compress_latitude_coord_geoint32().

Referenced by compress_coords(), and points_to_vector().

1709  {
1710  return static_cast<int32_t>(Geospatial::compress_latitude_coord_geoint32(x[index + 1]));
1711 }
DEVICE uint64_t compress_latitude_coord_geoint32(const double coord)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<double> Geo::decompress_coords ( const int8_t *  data,
const int64_t  size,
const bool  is_geoint 
)
inline

Definition at line 1837 of file heavydbTypes.h.

References decompress_x_coord(), decompress_y_coord(), and run_benchmark_import::result.

Referenced by decompress_coords(), and Geo::GeoNestedArray< Point2D >::fromCoordsWorker().

1839  {
1840  int64_t nofpoints = size / (is_geoint ? sizeof(int32_t) * 2 : sizeof(double) * 2);
1841  std::vector<double> result;
1842  result.reserve(2 * nofpoints);
1843  for (int64_t i = 0; i < nofpoints; i++) {
1844  result.push_back(decompress_x_coord(data, 2 * i, is_geoint));
1845  result.push_back(decompress_y_coord(data, 2 * i, is_geoint));
1846  }
1847  return result;
1848 }
DEVICE double decompress_x_coord(const int8_t *data, const int64_t index, const bool is_geoint)
DEVICE double decompress_y_coord(const int8_t *data, const int64_t index, const bool is_geoint)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<double> Geo::decompress_coords ( const std::vector< int32_t > &  coords)
inline

Definition at line 1862 of file heavydbTypes.h.

References decompress_x_coord(), decompress_y_coord(), and run_benchmark_import::result.

1862  {
1863  std::vector<double> result;
1864  const size_t nofpoints = coords.size() / 2;
1865  result.reserve(coords.size());
1866  const int8_t* buf = reinterpret_cast<const int8_t*>(coords.data());
1867  for (size_t i = 0; i < nofpoints; i++) {
1868  result.push_back(decompress_x_coord(buf, 2 * i, true));
1869  result.push_back(decompress_y_coord(buf, 2 * i, true));
1870  }
1871  return result;
1872 }
DEVICE double decompress_x_coord(const int8_t *data, const int64_t index, const bool is_geoint)
DEVICE double decompress_y_coord(const int8_t *data, const int64_t index, const bool is_geoint)

+ Here is the call graph for this function:

std::vector<std::vector<double> > Geo::decompress_coords ( const std::vector< std::vector< int32_t >> &  coords)
inline

Definition at line 1884 of file heavydbTypes.h.

References decompress_coords(), and run_benchmark_import::result.

1885  {
1886  std::vector<std::vector<double>> result;
1887  result.reserve(coords.size());
1888  for (size_t i = 0; i < coords.size(); i++) {
1889  result.push_back(decompress_coords(coords[i]));
1890  }
1891  return result;
1892 }
std::shared_ptr< std::vector< T > > decompress_coords(const C &compression, const int8_t *coords, const size_t coords_sz)

+ Here is the call graph for this function:

std::vector<std::vector<std::vector<double> > > Geo::decompress_coords ( const std::vector< std::vector< std::vector< int32_t >>> &  coords)
inline

Definition at line 1904 of file heavydbTypes.h.

References decompress_coords(), and run_benchmark_import::result.

1905  {
1906  std::vector<std::vector<std::vector<double>>> result;
1907  result.reserve(coords.size());
1908  for (size_t i = 0; i < coords.size(); i++) {
1909  result.push_back(decompress_coords(coords[i]));
1910  }
1911  return result;
1912 }
std::shared_ptr< std::vector< T > > decompress_coords(const C &compression, const int8_t *coords, const size_t coords_sz)

+ Here is the call graph for this function:

DEVICE double Geo::decompress_x_coord ( const int8_t *  data,
const int64_t  index,
const bool  is_geoint 
)
inline

Definition at line 1713 of file heavydbTypes.h.

References Geospatial::decompress_longitude_coord_geoint32().

Referenced by decompress_coords(), decompress_x_coord(), get_point(), and points_to_vector().

1715  {
1716  if (is_geoint) {
1718  reinterpret_cast<const int32_t*>(data)[index]);
1719  } else {
1720  return reinterpret_cast<const double*>(data)[index];
1721  }
1722 }
DEVICE double decompress_longitude_coord_geoint32(const int32_t compressed)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE double Geo::decompress_x_coord ( const int8_t *  data,
const int64_t  index,
const bool  is_geoint,
const int32_t  input_srid,
const int32_t  output_srid 
)
inline

Definition at line 1735 of file heavydbTypes.h.

References decompress_x_coord(), and to_string().

1739  {
1740  double x = decompress_x_coord(data, index, is_geoint);
1741  if (input_srid == output_srid || output_srid == 0) {
1742  return x;
1743  } else if (input_srid == 4326 && output_srid == 900913) {
1744  // WGS 84 --> Web Mercator
1745  x *= 111319.490778;
1746  } else {
1747 #ifndef __CUDACC__
1748  throw std::runtime_error("decompress_x_coord: unhandled geo transformation from " +
1749  std::to_string(input_srid) + " to " +
1750  std::to_string(output_srid) + '.');
1751 #endif
1752  }
1753  return x;
1754 }
DEVICE double decompress_x_coord(const int8_t *data, const int64_t index, const bool is_geoint)
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

DEVICE double Geo::decompress_y_coord ( const int8_t *  data,
const int64_t  index,
const bool  is_geoint 
)
inline

Definition at line 1724 of file heavydbTypes.h.

References Geospatial::decompress_latitude_coord_geoint32().

Referenced by decompress_coords(), decompress_y_coord(), get_point(), and points_to_vector().

1726  {
1727  if (is_geoint) {
1729  reinterpret_cast<const int32_t*>(data)[index + 1]);
1730  } else {
1731  return reinterpret_cast<const double*>(data)[index + 1];
1732  }
1733 }
DEVICE double decompress_latitude_coord_geoint32(const int32_t compressed)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE double Geo::decompress_y_coord ( const int8_t *  data,
const int64_t  index,
const bool  is_geoint,
const int32_t  input_srid,
const int32_t  output_srid 
)
inline

Definition at line 1756 of file heavydbTypes.h.

References decompress_y_coord(), and to_string().

1760  {
1761  double y = decompress_y_coord(data, index, is_geoint);
1762  if (input_srid == output_srid || output_srid == 0) {
1763  return y;
1764  } else if (input_srid == 4326 && output_srid == 900913) {
1765  // WGS 84 --> Web Mercator
1766  y = 6378136.99911 * log(tan(.00872664626 * y + .785398163397));
1767  } else {
1768 #ifndef __CUDACC__
1769  throw std::runtime_error("decompress_y_coord: unhandled geo transformation from " +
1770  std::to_string(input_srid) + " to " +
1771  std::to_string(output_srid) + '.');
1772 #endif
1773  }
1774  return y;
1775 }
DEVICE double decompress_y_coord(const int8_t *data, const int64_t index, const bool is_geoint)
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

int32_t Geo::get_input_srid ( const int8_t *  flatbuffer)
inline

Definition at line 1933 of file heavydbTypes.h.

References GeoPointFormatId, and toString().

Referenced by Analyzer::GeoConstant::add_cast(), and Column< GeoPoint >::getItem().

1933  {
1934  FlatBufferManager m{const_cast<int8_t*>(flatbuffer)};
1935  switch (m.format()) {
1936  case GeoPointFormatId:
1937  return m.getGeoPointMetadata()->input_srid;
1938  default:
1939 #ifndef __CUDACC__
1940  throw std::runtime_error("get_input_srid: unexpected format " +
1941  ::toString(m.format()));
1942 #else
1943  return -1;
1944 #endif
1945  }
1946 }
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1703

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Geo::get_is_geoint ( const int8_t *  flatbuffer)
inline

Definition at line 1917 of file heavydbTypes.h.

References GeoPointFormatId, and toString().

Referenced by Column< GeoPoint >::getItem().

1917  {
1918  FlatBufferManager m{const_cast<int8_t*>(flatbuffer)};
1919  switch (m.format()) {
1920  case GeoPointFormatId:
1921  return m.getGeoPointMetadata()->is_geoint;
1922  default:
1923 #ifndef __CUDACC__
1924  throw std::runtime_error("get_is_geoint: unexpected format " +
1925  ::toString(m.format()));
1926 #else
1927  return false;
1928 #endif
1929  }
1930 }
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1703

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t Geo::get_output_srid ( const int8_t *  flatbuffer)
inline

Definition at line 1949 of file heavydbTypes.h.

References GeoPointFormatId, and toString().

Referenced by Column< GeoPoint >::getItem().

1949  {
1950  FlatBufferManager m{const_cast<int8_t*>(flatbuffer)};
1951  switch (m.format()) {
1952  case GeoPointFormatId:
1953  return m.getGeoPointMetadata()->output_srid;
1954  default:
1955 #ifndef __CUDACC__
1956  throw std::runtime_error("get_output_srid: unexpected format " +
1957  ::toString(m.format()));
1958 #else
1959  return -1;
1960 #endif
1961  }
1962 }
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1703

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DEVICE Point2D Geo::get_point ( const int8_t *  data,
const int64_t  index,
const int32_t  input_srid,
const int32_t  output_srid,
const bool  is_geoint 
)
inline

Definition at line 1777 of file heavydbTypes.h.

References decompress_x_coord(), and decompress_y_coord().

Referenced by Column< GeoPoint >::getItem(), and Geo::GeoNestedArray< Point2D >::getPoint().

1781  {
1782  Point2D point{decompress_x_coord(data, index, is_geoint, input_srid, output_srid),
1783  decompress_y_coord(data, index, is_geoint, input_srid, output_srid)};
1784  return point;
1785 }
DEVICE double decompress_x_coord(const int8_t *data, const int64_t index, const bool is_geoint)
DEVICE double decompress_y_coord(const int8_t *data, const int64_t index, const bool is_geoint)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename CT >
void Geo::points_to_vector ( const int8_t *  points_buf,
const int64_t  nof_points,
const bool  is_geoint,
std::vector< CT > &  result 
)
inline

Definition at line 1790 of file heavydbTypes.h.

References compress_x_coord(), compress_y_coord(), decompress_x_coord(), and decompress_y_coord().

Referenced by Geo::GeoNestedArray< Point2D >::toCoordsWorker().

1793  {
1794  result.reserve(2 * nof_points);
1795  if (is_geoint) {
1796  if constexpr (std::is_same<CT, double>::value) {
1797  for (int64_t i = 0; i < nof_points; i++) {
1798  result.push_back(decompress_x_coord(points_buf, 2 * i, is_geoint));
1799  result.push_back(decompress_y_coord(points_buf, 2 * i, is_geoint));
1800  }
1801  } else {
1802  const int32_t* buf = reinterpret_cast<const int32_t*>(points_buf);
1803  result.assign(buf, buf + 2 * nof_points);
1804  }
1805  } else {
1806  const double* buf = reinterpret_cast<const double*>(points_buf);
1807  if constexpr (std::is_same<CT, double>::value) {
1808  result.assign(buf, buf + 2 * nof_points);
1809  } else {
1810  for (int64_t i = 0; i < nof_points; i++) {
1811  result.push_back(compress_x_coord(buf, 2 * i));
1812  result.push_back(compress_y_coord(buf, 2 * i));
1813  }
1814  }
1815  }
1816 }
DEVICE double decompress_x_coord(const int8_t *data, const int64_t index, const bool is_geoint)
DEVICE double decompress_y_coord(const int8_t *data, const int64_t index, const bool is_geoint)
DEVICE int32_t compress_x_coord(const double *x, const int64_t index)
DEVICE int32_t compress_y_coord(const double *x, const int64_t index)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: