OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::anonymous_namespace{TextFileBufferParser.cpp} Namespace Reference

Functions

bool set_coordinates_from_separate_lon_lat_columns (const std::string_view lon_str, const std::string_view lat_str, std::vector< double > &coords, const bool is_lon_lat_order)
 

Variables

constexpr bool PROMOTE_POLYGON_TO_MULTIPOLYGON = true
 

Function Documentation

bool foreign_storage::anonymous_namespace{TextFileBufferParser.cpp}::set_coordinates_from_separate_lon_lat_columns ( const std::string_view  lon_str,
const std::string_view  lat_str,
std::vector< double > &  coords,
const bool  is_lon_lat_order 
)

Definition at line 120 of file TextFileBufferParser.cpp.

References foreign_storage::TextFileBufferParser::isCoordinateScalar(), and gpu_enabled::swap().

Referenced by foreign_storage::TextFileBufferParser::processGeoColumn().

123  {
124  double lon = std::atof(std::string(lon_str).c_str());
125  double lat = NAN;
126 
127  if (TextFileBufferParser::isCoordinateScalar(lat_str)) {
128  lat = std::atof(std::string(lat_str).c_str());
129  }
130 
131  // Swap coordinates if this table uses a reverse order: lat/lon
132  if (!is_lon_lat_order) {
133  std::swap(lat, lon);
134  }
135 
136  // TODO: should check if POINT column should have been declared with
137  // SRID WGS 84, EPSG 4326 ? if (col_ti.get_dimension() != 4326) {
138  // throw std::runtime_error("POINT column " + cd->columnName + " is
139  // not WGS84, cannot insert lon/lat");
140  // }
141 
142  if (std::isinf(lat) || std::isnan(lat) || std::isinf(lon) || std::isnan(lon)) {
143  return false;
144  }
145  coords.push_back(lon);
146  coords.push_back(lat);
147  return true;
148 }
DEVICE void swap(ARGS &&...args)
Definition: gpu_enabled.h:114

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

constexpr bool foreign_storage::anonymous_namespace{TextFileBufferParser.cpp}::PROMOTE_POLYGON_TO_MULTIPOLYGON = true