OmniSciDB  e465130ba1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Geo_namespace::GeoTypesFactory Class Reference

#include <geo_types.h>

Static Public Member Functions

static std::unique_ptr< GeoBasecreateGeoType (const std::string &wkt)
 
static std::unique_ptr< GeoBasecreateGeoType (OGRGeometry *geom)
 
static bool getGeoColumns (const std::string &wkt, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
 
static bool getGeoColumns (OGRGeometry *geom, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
 
static bool getGeoColumns (const std::vector< std::string > *wkt_column, SQLTypeInfo &ti, std::vector< std::vector< double >> &coords_column, std::vector< std::vector< double >> &bounds_column, std::vector< std::vector< int >> &ring_sizes_column, std::vector< std::vector< int >> &poly_rings_column, const bool promote_poly_to_mpoly=false)
 
static void getNullGeoColumns (SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
 

Static Private Member Functions

static std::unique_ptr
< Geo_namespace::GeoBase
createGeoTypeImpl (OGRGeometry *geom, const bool owns_geom_obj=true)
 
static void getGeoColumnsImpl (const std::unique_ptr< GeoBase > &geospatial_base, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
 

Detailed Description

Definition at line 135 of file geo_types.h.

Member Function Documentation

std::unique_ptr< GeoBase > Geo_namespace::GeoTypesFactory::createGeoType ( const std::string &  wkt)
static

Definition at line 446 of file geo_types.cpp.

References Geo_namespace::GeoBase::createFromWktString(), and createGeoTypeImpl().

Referenced by getGeoColumns().

446  {
447  OGRGeometry* geom = nullptr;
448  const auto err = GeoBase::createFromWktString(wkt, &geom);
449  if (err != OGRERR_NONE) {
450  throw GeoTypesError("GeoFactory", err);
451  }
453 }
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: geo_types.cpp:147
static std::unique_ptr< Geo_namespace::GeoBase > createGeoTypeImpl(OGRGeometry *geom, const bool owns_geom_obj=true)
Definition: geo_types.cpp:560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr< GeoBase > Geo_namespace::GeoTypesFactory::createGeoType ( OGRGeometry *  geom)
static

Definition at line 455 of file geo_types.cpp.

References createGeoTypeImpl().

455  {
456  return GeoTypesFactory::createGeoTypeImpl(geom, false);
457 }
static std::unique_ptr< Geo_namespace::GeoBase > createGeoTypeImpl(OGRGeometry *geom, const bool owns_geom_obj=true)
Definition: geo_types.cpp:560

+ Here is the call graph for this function:

std::unique_ptr< GeoBase > Geo_namespace::GeoTypesFactory::createGeoTypeImpl ( OGRGeometry *  geom,
const bool  owns_geom_obj = true 
)
staticprivate

Definition at line 560 of file geo_types.cpp.

Referenced by createGeoType().

561  {
562  switch (wkbFlatten(geom->getGeometryType())) {
563  case wkbPoint:
564  return std::unique_ptr<GeoPoint>(new GeoPoint(geom, owns_geom_obj));
565  case wkbLineString:
566  return std::unique_ptr<GeoLineString>(new GeoLineString(geom, owns_geom_obj));
567  case wkbPolygon:
568  return std::unique_ptr<GeoPolygon>(new GeoPolygon(geom, owns_geom_obj));
569  case wkbMultiPolygon:
570  return std::unique_ptr<GeoMultiPolygon>(new GeoMultiPolygon(geom, owns_geom_obj));
571  default:
572  throw GeoTypesError(
573  "GeoTypesFactory",
574  "Unrecognized geometry type: " + std::string(geom->getGeometryName()));
575  }
576 }

+ Here is the caller graph for this function:

bool Geo_namespace::GeoTypesFactory::getGeoColumns ( const std::string &  wkt,
SQLTypeInfo ti,
std::vector< double > &  coords,
std::vector< double > &  bounds,
std::vector< int > &  ring_sizes,
std::vector< int > &  poly_rings,
const bool  promote_poly_to_mpoly = false 
)
static

Definition at line 459 of file geo_types.cpp.

References createGeoType(), logger::ERROR, getGeoColumnsImpl(), getNullGeoColumns(), LOG, SQLTypeInfoCore< TYPE_FACET_PACK >::set_input_srid(), and SQLTypeInfoCore< TYPE_FACET_PACK >::set_output_srid().

Referenced by Parser::InsertValuesStmt::analyze(), Importer_NS::TypedImportBuffer::convert_arrow_val_to_import_buffer(), Parser::AddColumnStmt::execute(), getGeoColumns(), Importer_NS::import_thread_delimited(), Importer_NS::import_thread_shapefile(), MapDHandler::load_table(), MapDHandler::load_table_binary_columnar(), and RelAlgTranslator::translateGeoLiteral().

465  {
466  try {
467  if (wkt.empty() || wkt == "NULL") {
469  ti, coords, bounds, ring_sizes, poly_rings, promote_poly_to_mpoly);
470  return true;
471  }
472 
473  const auto geospatial_base = GeoTypesFactory::createGeoType(wkt);
474 
475  int srid = 0;
476  ti.set_input_srid(srid);
477  ti.set_output_srid(srid);
478 
479  getGeoColumnsImpl(geospatial_base,
480  ti,
481  coords,
482  bounds,
483  ring_sizes,
484  poly_rings,
485  promote_poly_to_mpoly);
486 
487  } catch (const std::exception& e) {
488  LOG(ERROR) << "Geospatial Import Error: " << e.what();
489  return false;
490  }
491 
492  return true;
493 }
#define LOG(tag)
Definition: Logger.h:188
void set_input_srid(int d)
Definition: sqltypes.h:422
void set_output_srid(int s)
Definition: sqltypes.h:424
static void getGeoColumnsImpl(const std::unique_ptr< GeoBase > &geospatial_base, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
Definition: geo_types.cpp:578
static void getNullGeoColumns(SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
Definition: geo_types.cpp:626
static std::unique_ptr< GeoBase > createGeoType(const std::string &wkt)
Definition: geo_types.cpp:446

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Geo_namespace::GeoTypesFactory::getGeoColumns ( OGRGeometry *  geom,
SQLTypeInfo ti,
std::vector< double > &  coords,
std::vector< double > &  bounds,
std::vector< int > &  ring_sizes,
std::vector< int > &  poly_rings,
const bool  promote_poly_to_mpoly = false 
)
static

Definition at line 495 of file geo_types.cpp.

References createGeoType(), logger::ERROR, getGeoColumnsImpl(), LOG, SQLTypeInfoCore< TYPE_FACET_PACK >::set_input_srid(), and SQLTypeInfoCore< TYPE_FACET_PACK >::set_output_srid().

501  {
502  try {
503  const auto geospatial_base = GeoTypesFactory::createGeoType(geom);
504 
505  int srid = 0;
506  ti.set_input_srid(srid);
507  ti.set_output_srid(srid);
508 
509  getGeoColumnsImpl(geospatial_base,
510  ti,
511  coords,
512  bounds,
513  ring_sizes,
514  poly_rings,
515  promote_poly_to_mpoly);
516 
517  } catch (const std::exception& e) {
518  LOG(ERROR) << "Geospatial Import Error: " << e.what();
519  return false;
520  }
521 
522  return true;
523 }
#define LOG(tag)
Definition: Logger.h:188
void set_input_srid(int d)
Definition: sqltypes.h:422
void set_output_srid(int s)
Definition: sqltypes.h:424
static void getGeoColumnsImpl(const std::unique_ptr< GeoBase > &geospatial_base, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
Definition: geo_types.cpp:578
static std::unique_ptr< GeoBase > createGeoType(const std::string &wkt)
Definition: geo_types.cpp:446

+ Here is the call graph for this function:

bool Geo_namespace::GeoTypesFactory::getGeoColumns ( const std::vector< std::string > *  wkt_column,
SQLTypeInfo ti,
std::vector< std::vector< double >> &  coords_column,
std::vector< std::vector< double >> &  bounds_column,
std::vector< std::vector< int >> &  ring_sizes_column,
std::vector< std::vector< int >> &  poly_rings_column,
const bool  promote_poly_to_mpoly = false 
)
static

Definition at line 525 of file geo_types.cpp.

References logger::ERROR, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), getGeoColumns(), and LOG.

531  {
532  try {
533  for (const auto wkt : *wkt_column) {
534  std::vector<double> coords;
535  std::vector<double> bounds;
536  std::vector<int> ring_sizes;
537  std::vector<int> poly_rings;
538 
539  SQLTypeInfo row_ti;
541  wkt, row_ti, coords, bounds, ring_sizes, poly_rings, promote_poly_to_mpoly);
542 
543  if (ti.get_type() != row_ti.get_type()) {
544  throw GeoTypesError("GeoFactory", "Columnar: Geometry type mismatch");
545  }
546  coords_column.push_back(coords);
547  bounds_column.push_back(bounds);
548  ring_sizes_column.push_back(ring_sizes);
549  poly_rings_column.push_back(poly_rings);
550  }
551 
552  } catch (const std::exception& e) {
553  LOG(ERROR) << "Geospatial column Import Error: " << e.what();
554  return false;
555  }
556 
557  return true;
558 }
#define LOG(tag)
Definition: Logger.h:188
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:328
static bool getGeoColumns(const std::string &wkt, SQLTypeInfo &ti, std::vector< double > &coords, std::vector< double > &bounds, std::vector< int > &ring_sizes, std::vector< int > &poly_rings, const bool promote_poly_to_mpoly=false)
Definition: geo_types.cpp:459

+ Here is the call graph for this function:

void Geo_namespace::GeoTypesFactory::getGeoColumnsImpl ( const std::unique_ptr< GeoBase > &  geospatial_base,
SQLTypeInfo ti,
std::vector< double > &  coords,
std::vector< double > &  bounds,
std::vector< int > &  ring_sizes,
std::vector< int > &  poly_rings,
const bool  promote_poly_to_mpoly = false 
)
staticprivate

Definition at line 578 of file geo_types.cpp.

References CHECK(), CHECK_GT, Geo_namespace::GeoBase::kLINESTRING, kLINESTRING, Geo_namespace::GeoBase::kMULTIPOLYGON, kMULTIPOLYGON, Geo_namespace::GeoBase::kPOINT, kPOINT, Geo_namespace::GeoBase::kPOLYGON, kPOLYGON, and SQLTypeInfoCore< TYPE_FACET_PACK >::set_type().

Referenced by getGeoColumns().

584  {
585  switch (geospatial_base->getType()) {
587  const auto geospatial_point = dynamic_cast<GeoPoint*>(geospatial_base.get());
588  CHECK(geospatial_point);
589  geospatial_point->getColumns(coords);
590  ti.set_type(kPOINT);
591  break;
592  }
594  const auto geospatial_linestring =
595  dynamic_cast<GeoLineString*>(geospatial_base.get());
596  CHECK(geospatial_linestring);
597  geospatial_linestring->getColumns(coords, bounds);
598  ti.set_type(kLINESTRING);
599  break;
600  }
602  const auto geospatial_poly = dynamic_cast<GeoPolygon*>(geospatial_base.get());
603  CHECK(geospatial_poly);
604  geospatial_poly->getColumns(coords, ring_sizes, bounds);
605  if (promote_poly_to_mpoly) {
606  if (ring_sizes.size()) {
607  CHECK_GT(coords.size(), 0u);
608  poly_rings.push_back(1 + geospatial_poly->getNumInteriorRings());
609  }
610  }
611  ti.set_type(kPOLYGON);
612  break;
613  }
615  const auto geospatial_mpoly = dynamic_cast<GeoMultiPolygon*>(geospatial_base.get());
616  CHECK(geospatial_mpoly);
617  geospatial_mpoly->getColumns(coords, ring_sizes, poly_rings, bounds);
619  break;
620  }
621  default:
622  throw std::runtime_error("Unrecognized geospatial type");
623  }
624 }
HOST DEVICE void set_type(SQLTypes t)
Definition: sqltypes.h:418
#define CHECK_GT(x, y)
Definition: Logger.h:209
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Geo_namespace::GeoTypesFactory::getNullGeoColumns ( SQLTypeInfo ti,
std::vector< double > &  coords,
std::vector< double > &  bounds,
std::vector< int > &  ring_sizes,
std::vector< int > &  poly_rings,
const bool  promote_poly_to_mpoly = false 
)
static

Definition at line 626 of file geo_types.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kLINESTRING, kMULTIPOLYGON, kPOINT, kPOLYGON, NULL_ARRAY_DOUBLE, and NULL_DOUBLE.

Referenced by Importer_NS::TypedImportBuffer::convert_arrow_val_to_import_buffer(), getGeoColumns(), Importer_NS::import_thread_delimited(), and Importer_NS::import_thread_shapefile().

631  {
632  auto t = ti.get_type();
633  switch (t) {
634  case kPOINT: {
635  // NULL fixlen coords array
636  coords.push_back(NULL_ARRAY_DOUBLE);
637  coords.push_back(NULL_DOUBLE);
638  } break;
639  case kLINESTRING:
640  case kPOLYGON:
641  case kMULTIPOLYGON: {
642  // Leaving coords array empty
643  // NULL fixlen bounds array
644  bounds.push_back(NULL_ARRAY_DOUBLE);
645  bounds.push_back(NULL_DOUBLE);
646  bounds.push_back(NULL_DOUBLE);
647  bounds.push_back(NULL_DOUBLE);
648  // Leaving ring_sizes and poly_rings arrays empty
649  } break;
650  default:
651  throw std::runtime_error("Unsupported NULL geo");
652  }
653 }
#define NULL_DOUBLE
Definition: sqltypes.h:179
#define NULL_ARRAY_DOUBLE
Definition: sqltypes.h:187
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:328

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: