OmniSciDB  c0231cc57d
 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 126 of file TextFileBufferParser.cpp.

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

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

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