OmniSciDB  085a039ca4
 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 125 of file TextFileBufferParser.cpp.

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

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

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