OmniSciDB  c1a53651b2
 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, SQLTypeInfo &ti, 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,
SQLTypeInfo ti,
std::vector< double > &  coords,
const bool  is_lon_lat_order 
)

Definition at line 133 of file TextFileBufferParser.cpp.

References Geospatial::GeoPoint::getColumns(), foreign_storage::TextFileBufferParser::isCoordinateScalar(), gpu_enabled::swap(), and SQLTypeInfo::transforms().

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

137  {
138  double lon = std::atof(std::string(lon_str).c_str());
139  double lat = NAN;
140 
141  if (TextFileBufferParser::isCoordinateScalar(lat_str)) {
142  lat = std::atof(std::string(lat_str).c_str());
143  }
144 
145  // Swap coordinates if this table uses a reverse order: lat/lon
146  if (!is_lon_lat_order) {
147  std::swap(lat, lon);
148  }
149 
150  // TODO: should check if POINT column should have been declared with
151  // SRID WGS 84, EPSG 4326 ? if (col_ti.get_dimension() != 4326) {
152  // throw std::runtime_error("POINT column " + cd->columnName + " is
153  // not WGS84, cannot insert lon/lat");
154  // }
155 
156  if (std::isinf(lat) || std::isnan(lat) || std::isinf(lon) || std::isnan(lon)) {
157  return false;
158  }
159 
160  if (ti.transforms()) {
161  Geospatial::GeoPoint pt{std::vector<double>{lon, lat}};
162  if (!pt.transform(ti)) {
163  return false;
164  }
165  pt.getColumns(coords);
166  return true;
167  }
168 
169  coords.push_back(lon);
170  coords.push_back(lat);
171  return true;
172 }
void getColumns(std::vector< double > &coords) const
Definition: Types.cpp:567
bool transforms() const
Definition: sqltypes.h:615
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