OmniSciDB  f17484ade4
 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 1811 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().

1813  {
1814  int64_t nofpoints = size / (is_geoint ? sizeof(int32_t) * 2 : sizeof(double) * 2);
1815  std::vector<int32_t> result;
1816  result.reserve(2 * nofpoints);
1817  if (is_geoint) {
1818  const int32_t* buf = reinterpret_cast<const int32_t*>(data);
1819  result.assign(buf, buf + 2 * nofpoints);
1820  } else {
1821  const double* buf = reinterpret_cast<const double*>(data);
1822  for (int64_t i = 0; i < nofpoints; i++) {
1823  result.push_back(compress_x_coord(buf, 2 * i));
1824  result.push_back(compress_y_coord(buf, 2 * i));
1825  }
1826  }
1827  return result;
1828 }
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 1843 of file heavydbTypes.h.

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

1843  {
1844  std::vector<int32_t> result;
1845  const size_t nofpoints = coords.size() / 2;
1846  result.reserve(coords.size());
1847  const double* buf = coords.data();
1848  for (size_t i = 0; i < nofpoints; i++) {
1849  result.push_back(compress_x_coord(buf, 2 * i));
1850  result.push_back(compress_y_coord(buf, 2 * i));
1851  }
1852  return result;
1853 }
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 1867 of file heavydbTypes.h.

References compress_coords(), and run_benchmark_import::result.

1868  {
1869  std::vector<std::vector<int32_t>> result;
1870  result.reserve(coords.size());
1871  for (size_t i = 0; i < coords.size(); i++) {
1872  result.push_back(compress_coords(coords[i]));
1873  }
1874  return result;
1875 }
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 1887 of file heavydbTypes.h.

References compress_coords(), and run_benchmark_import::result.

1888  {
1889  std::vector<std::vector<std::vector<int32_t>>> result;
1890  result.reserve(coords.size());
1891  for (size_t i = 0; i < coords.size(); i++) {
1892  result.push_back(compress_coords(coords[i]));
1893  }
1894  return result;
1895 }
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 1698 of file heavydbTypes.h.

References Geospatial::compress_longitude_coord_geoint32().

Referenced by compress_coords(), and points_to_vector().

1698  {
1699  return static_cast<int32_t>(Geospatial::compress_longitude_coord_geoint32(x[index]));
1700 }
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 1702 of file heavydbTypes.h.

References Geospatial::compress_latitude_coord_geoint32().

Referenced by compress_coords(), and points_to_vector().

1702  {
1703  return static_cast<int32_t>(Geospatial::compress_latitude_coord_geoint32(x[index + 1]));
1704 }
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 1830 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().

1832  {
1833  int64_t nofpoints = size / (is_geoint ? sizeof(int32_t) * 2 : sizeof(double) * 2);
1834  std::vector<double> result;
1835  result.reserve(2 * nofpoints);
1836  for (int64_t i = 0; i < nofpoints; i++) {
1837  result.push_back(decompress_x_coord(data, 2 * i, is_geoint));
1838  result.push_back(decompress_y_coord(data, 2 * i, is_geoint));
1839  }
1840  return result;
1841 }
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 1855 of file heavydbTypes.h.

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

1855  {
1856  std::vector<double> result;
1857  const size_t nofpoints = coords.size() / 2;
1858  result.reserve(coords.size());
1859  const int8_t* buf = reinterpret_cast<const int8_t*>(coords.data());
1860  for (size_t i = 0; i < nofpoints; i++) {
1861  result.push_back(decompress_x_coord(buf, 2 * i, true));
1862  result.push_back(decompress_y_coord(buf, 2 * i, true));
1863  }
1864  return result;
1865 }
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 1877 of file heavydbTypes.h.

References decompress_coords(), and run_benchmark_import::result.

1878  {
1879  std::vector<std::vector<double>> result;
1880  result.reserve(coords.size());
1881  for (size_t i = 0; i < coords.size(); i++) {
1882  result.push_back(decompress_coords(coords[i]));
1883  }
1884  return result;
1885 }
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 1897 of file heavydbTypes.h.

References decompress_coords(), and run_benchmark_import::result.

1898  {
1899  std::vector<std::vector<std::vector<double>>> result;
1900  result.reserve(coords.size());
1901  for (size_t i = 0; i < coords.size(); i++) {
1902  result.push_back(decompress_coords(coords[i]));
1903  }
1904  return result;
1905 }
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 1706 of file heavydbTypes.h.

References Geospatial::decompress_longitude_coord_geoint32().

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

1708  {
1709  if (is_geoint) {
1711  reinterpret_cast<const int32_t*>(data)[index]);
1712  } else {
1713  return reinterpret_cast<const double*>(data)[index];
1714  }
1715 }
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 1728 of file heavydbTypes.h.

References decompress_x_coord(), and to_string().

1732  {
1733  double x = decompress_x_coord(data, index, is_geoint);
1734  if (input_srid == output_srid || output_srid == 0) {
1735  return x;
1736  } else if (input_srid == 4326 && output_srid == 900913) {
1737  // WGS 84 --> Web Mercator
1738  x *= 111319.490778;
1739  } else {
1740 #ifndef __CUDACC__
1741  throw std::runtime_error("decompress_x_coord: unhandled geo transformation from " +
1742  std::to_string(input_srid) + " to " +
1743  std::to_string(output_srid) + '.');
1744 #endif
1745  }
1746  return x;
1747 }
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 1717 of file heavydbTypes.h.

References Geospatial::decompress_latitude_coord_geoint32().

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

1719  {
1720  if (is_geoint) {
1722  reinterpret_cast<const int32_t*>(data)[index + 1]);
1723  } else {
1724  return reinterpret_cast<const double*>(data)[index + 1];
1725  }
1726 }
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 1749 of file heavydbTypes.h.

References decompress_y_coord(), and to_string().

1753  {
1754  double y = decompress_y_coord(data, index, is_geoint);
1755  if (input_srid == output_srid || output_srid == 0) {
1756  return y;
1757  } else if (input_srid == 4326 && output_srid == 900913) {
1758  // WGS 84 --> Web Mercator
1759  y = 6378136.99911 * log(tan(.00872664626 * y + .785398163397));
1760  } else {
1761 #ifndef __CUDACC__
1762  throw std::runtime_error("decompress_y_coord: unhandled geo transformation from " +
1763  std::to_string(input_srid) + " to " +
1764  std::to_string(output_srid) + '.');
1765 #endif
1766  }
1767  return y;
1768 }
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 1926 of file heavydbTypes.h.

References GeoPointFormatId, and toString().

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

1926  {
1927  FlatBufferManager m{const_cast<int8_t*>(flatbuffer)};
1928  switch (m.format()) {
1929  case GeoPointFormatId:
1930  return m.getGeoPointMetadata()->input_srid;
1931  default:
1932 #ifndef __CUDACC__
1933  throw std::runtime_error("get_input_srid: unexpected format " +
1934  ::toString(m.format()));
1935 #else
1936  return -1;
1937 #endif
1938  }
1939 }
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64

+ 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 1910 of file heavydbTypes.h.

References GeoPointFormatId, and toString().

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

1910  {
1911  FlatBufferManager m{const_cast<int8_t*>(flatbuffer)};
1912  switch (m.format()) {
1913  case GeoPointFormatId:
1914  return m.getGeoPointMetadata()->is_geoint;
1915  default:
1916 #ifndef __CUDACC__
1917  throw std::runtime_error("get_is_geoint: unexpected format " +
1918  ::toString(m.format()));
1919 #else
1920  return false;
1921 #endif
1922  }
1923 }
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64

+ 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 1942 of file heavydbTypes.h.

References GeoPointFormatId, and toString().

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

1942  {
1943  FlatBufferManager m{const_cast<int8_t*>(flatbuffer)};
1944  switch (m.format()) {
1945  case GeoPointFormatId:
1946  return m.getGeoPointMetadata()->output_srid;
1947  default:
1948 #ifndef __CUDACC__
1949  throw std::runtime_error("get_output_srid: unexpected format " +
1950  ::toString(m.format()));
1951 #else
1952  return -1;
1953 #endif
1954  }
1955 }
std::string toString(const QueryDescriptionType &type)
Definition: Types.h:64

+ 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 1770 of file heavydbTypes.h.

References decompress_x_coord(), and decompress_y_coord().

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

1774  {
1775  Point2D point{decompress_x_coord(data, index, is_geoint, input_srid, output_srid),
1776  decompress_y_coord(data, index, is_geoint, input_srid, output_srid)};
1777  return point;
1778 }
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 1783 of file heavydbTypes.h.

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

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

1786  {
1787  result.reserve(2 * nof_points);
1788  if (is_geoint) {
1789  if constexpr (std::is_same<CT, double>::value) {
1790  for (int64_t i = 0; i < nof_points; i++) {
1791  result.push_back(decompress_x_coord(points_buf, 2 * i, is_geoint));
1792  result.push_back(decompress_y_coord(points_buf, 2 * i, is_geoint));
1793  }
1794  } else {
1795  const int32_t* buf = reinterpret_cast<const int32_t*>(points_buf);
1796  result.assign(buf, buf + 2 * nof_points);
1797  }
1798  } else {
1799  const double* buf = reinterpret_cast<const double*>(points_buf);
1800  if constexpr (std::is_same<CT, double>::value) {
1801  result.assign(buf, buf + 2 * nof_points);
1802  } else {
1803  for (int64_t i = 0; i < nof_points; i++) {
1804  result.push_back(compress_x_coord(buf, 2 * i));
1805  result.push_back(compress_y_coord(buf, 2 * i));
1806  }
1807  }
1808  }
1809 }
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: