OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geospatial::anonymous_namespace{Types.cpp} Namespace Reference

Classes

struct  HexDigitToDecimalTable
 

Functions

uint8_t hex_to_binary (const char &usb, const char &lsb)
 
std::vector< uint8_t > hex_string_to_binary_vector (const std::string &wkb_hex)
 
bool validation_enabled_for_type (const OGRGeometry *geom)
 
void validate_ogr (const OGRGeometry *geom)
 

Variables

constexpr HexDigitToDecimalTable hex_digit_to_decimal_table
 

Function Documentation

std::vector<uint8_t> Geospatial::anonymous_namespace{Types.cpp}::hex_string_to_binary_vector ( const std::string &  wkb_hex)

Definition at line 1030 of file Types.cpp.

References hex_to_binary().

Referenced by Geospatial::GeoTypesFactory::createOGRGeometry().

1030  {
1031  auto num_bytes = wkb_hex.size() >> 1;
1032  std::vector<uint8_t> wkb(num_bytes);
1033  auto* chars = wkb_hex.data();
1034  auto* bytes = wkb.data();
1035  for (size_t i = 0; i < num_bytes; i++) {
1036  auto const& usb = *chars++;
1037  auto const& lsb = *chars++;
1038  *bytes++ = hex_to_binary(usb, lsb);
1039  }
1040  return wkb;
1041 }
uint8_t hex_to_binary(const char &usb, const char &lsb)
Definition: Types.cpp:1026

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8_t Geospatial::anonymous_namespace{Types.cpp}::hex_to_binary ( const char &  usb,
const char &  lsb 
)
inline

Definition at line 1026 of file Types.cpp.

Referenced by hex_string_to_binary_vector().

1026  {
1027  return (hex_digit_to_decimal_table[usb] << 4) | hex_digit_to_decimal_table[lsb];
1028 }
constexpr HexDigitToDecimalTable hex_digit_to_decimal_table
Definition: Types.cpp:1024

+ Here is the caller graph for this function:

void Geospatial::anonymous_namespace{Types.cpp}::validate_ogr ( const OGRGeometry *  geom)

Definition at line 1049 of file Types.cpp.

References CHECK, Geospatial::geos_validate_wkb(), Geospatial::geos_validation_available(), and validation_enabled_for_type().

Referenced by Geospatial::GeoTypesFactory::createGeoType(), and Geospatial::GeoTypesFactory::createOGRGeometry().

1049  {
1050  CHECK(geom);
1052  auto const wkb_size = geom->WkbSize();
1053  std::vector<unsigned char> wkb(wkb_size);
1054  auto const err = geom->exportToWkb(wkbNDR, wkb.data());
1055  if (err == OGRERR_NONE && !geos_validate_wkb(wkb.data(), wkb_size)) {
1056  throw GeoTypesError("GeoFactory", "Geometry is invalid");
1057  }
1058  }
1059 }
bool geos_validate_wkb(const unsigned char *, const size_t)
bool validation_enabled_for_type(const OGRGeometry *geom)
Definition: Types.cpp:1043
bool geos_validation_available()
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Geospatial::anonymous_namespace{Types.cpp}::validation_enabled_for_type ( const OGRGeometry *  geom)

Definition at line 1043 of file Types.cpp.

Referenced by validate_ogr().

1043  {
1044  auto const wkb_type = wkbFlatten(geom->getGeometryType());
1045  // only POLYGON and MULTIPOLYGON for now
1046  return (wkb_type == wkbPolygon) || (wkb_type == wkbMultiPolygon);
1047 }

+ Here is the caller graph for this function:

Variable Documentation

constexpr HexDigitToDecimalTable Geospatial::anonymous_namespace{Types.cpp}::hex_digit_to_decimal_table

Definition at line 1024 of file Types.cpp.