OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
import_export::anonymous_namespace{RasterImporter.cpp} Namespace Reference

Functions

SQLTypes gdal_data_type_to_sql_type (const GDALDataType gdal_data_type)
 
GDALDataType sql_type_to_gdal_data_type (const SQLTypes sql_type)
 
std::vector< std::string > get_ome_tiff_band_names (const std::string &tifftag_imagedescription)
 
SQLTypes point_type_to_sql_type (const RasterImporter::PointType point_type)
 
double conv_4326_900913_x (const double x)
 
double conv_4326_900913_y (const double y)
 
std::string get_datasource_driver_name (OGRDataSource *source)
 
bool datasource_requires_libhdf (OGRDataSource *source)
 

Function Documentation

double import_export::anonymous_namespace{RasterImporter.cpp}::conv_4326_900913_x ( const double  x)

Definition at line 249 of file RasterImporter.cpp.

249  {
250  return x * 111319.490778;
251 }
double import_export::anonymous_namespace{RasterImporter.cpp}::conv_4326_900913_y ( const double  y)

Definition at line 253 of file RasterImporter.cpp.

253  {
254  return 6378136.99911 * log(tan(.00872664626 * y + .785398163397));
255 }
bool import_export::anonymous_namespace{RasterImporter.cpp}::datasource_requires_libhdf ( OGRDataSource *  source)

Definition at line 265 of file RasterImporter.cpp.

References get_datasource_driver_name(), and setup::name.

Referenced by import_export::RasterImporter::import().

265  {
266  std::string name = get_datasource_driver_name(source);
267  return name == "HDF5Image" || name == "HDF5" || name == "BAG" || name == "KEA";
268 }
std::string get_datasource_driver_name(OGRDataSource *source)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypes import_export::anonymous_namespace{RasterImporter.cpp}::gdal_data_type_to_sql_type ( const GDALDataType  gdal_data_type)

Definition at line 98 of file RasterImporter.cpp.

References kBIGINT, kDOUBLE, kFLOAT, kINT, kSMALLINT, and to_string().

Referenced by import_export::RasterImporter::detect().

98  {
99  switch (gdal_data_type) {
100  case GDT_Byte:
101  case GDT_Int16:
102  return kSMALLINT;
103  case GDT_UInt16:
104  case GDT_Int32:
105  return kINT;
106  case GDT_UInt32:
107  return kBIGINT;
108  case GDT_Float32:
109  return kFLOAT;
110  case GDT_Float64:
111  return kDOUBLE;
112  case GDT_CInt16:
113  case GDT_CInt32:
114  case GDT_CFloat32:
115  case GDT_CFloat64:
116  default:
117  break;
118  }
119  throw std::runtime_error("Unknown/unsupported GDAL data type: " +
120  std::to_string(gdal_data_type));
121 }
std::string to_string(char const *&&v)
Definition: sqltypes.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string import_export::anonymous_namespace{RasterImporter.cpp}::get_datasource_driver_name ( OGRDataSource *  source)

Definition at line 257 of file RasterImporter.cpp.

References CHECK, and setup::name.

Referenced by datasource_requires_libhdf(), and import_export::RasterImporter::import().

257  {
258  CHECK(source);
259  auto driver = source->GetDriver();
260  CHECK(driver);
261  std::string name = driver->GetDescription();
262  return name;
263 }
#define CHECK(condition)
Definition: Logger.h:291
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function:

std::vector<std::string> import_export::anonymous_namespace{RasterImporter.cpp}::get_ome_tiff_band_names ( const std::string &  tifftag_imagedescription)

Definition at line 142 of file RasterImporter.cpp.

References setup::name, and run_benchmark_import::parser.

Referenced by import_export::RasterImporter::getRawBandNamesForFormat().

143  {
144  // expected schema:
145  //
146  // ...
147  // <Image ...>
148  // <Pixels ...>
149  // <Channel ID="Channel:0:<index>" Name="<name>" ...>
150  // ...
151  // </Channel>
152  // ...
153  // </Pixels>
154  // </Image>
155  // ...
156 
157  using Document = xercesc_3_2::DOMDocument;
158  using Element = xercesc_3_2::DOMElement;
159  using String = xercesc_3_2::XMLString;
160  using Utils = xercesc_3_2::XMLPlatformUtils;
161  using Parser = xercesc_3_2::XercesDOMParser;
162  using Source = xercesc_3_2::MemBufInputSource;
163 
164  Utils::Initialize();
165 
166  std::unordered_map<std::string, XMLCh*> tags;
167 
168  ScopeGuard release_tags = [&] {
169  for (auto& tag : tags) {
170  String::release(&tag.second);
171  }
172  };
173 
174  tags.emplace("ID", String::transcode("ID"));
175  tags.emplace("Name", String::transcode("Name"));
176  tags.emplace("Buffer", String::transcode("Buffer"));
177  tags.emplace("Image", String::transcode("Image"));
178  tags.emplace("Pixels", String::transcode("Pixels"));
179  tags.emplace("Channel", String::transcode("Channel"));
180 
181  auto get_tag = [&](const std::string& name) -> const XMLCh* {
182  return tags.find(name)->second;
183  };
184 
185  Parser parser;
186 
187  parser.setValidationScheme(Parser::Val_Never);
188  parser.setDoNamespaces(false);
189  parser.setDoSchema(false);
190  parser.setLoadExternalDTD(false);
191 
192  Source source(reinterpret_cast<const XMLByte*>(tifftag_imagedescription.c_str()),
193  tifftag_imagedescription.length(),
194  get_tag("Buffer"));
195 
196  parser.parse(source);
197 
198  std::vector<std::string> band_names;
199 
200  auto const* document = parser.getDocument();
201  if (document) {
202  auto const* root_element = document->getDocumentElement();
203  if (root_element) {
204  auto const* image_list = root_element->getElementsByTagName(get_tag("Image"));
205  if (image_list && image_list->getLength() > 0) {
206  auto const* image_element = dynamic_cast<const Element*>(image_list->item(0));
207  auto const* pixels_list = image_element->getElementsByTagName(get_tag("Pixels"));
208  if (pixels_list && pixels_list->getLength() > 0) {
209  auto const* pixels_element = dynamic_cast<const Element*>(pixels_list->item(0));
210  auto const* channel_list =
211  pixels_element->getElementsByTagName(get_tag("Channel"));
212  for (XMLSize_t i = 0; i < channel_list->getLength(); i++) {
213  auto const* channel_element =
214  dynamic_cast<const Element*>(channel_list->item(i));
215  auto const* name_attribute = channel_element->getAttribute(get_tag("Name"));
216  if (name_attribute) {
217  auto const* name = String::transcode(name_attribute);
218  if (name) {
219  band_names.emplace_back(name);
220  }
221  }
222  }
223  }
224  }
225  }
226  }
227 
228  return band_names;
229 }
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function:

SQLTypes import_export::anonymous_namespace{RasterImporter.cpp}::point_type_to_sql_type ( const RasterImporter::PointType  point_type)

Definition at line 231 of file RasterImporter.cpp.

References CHECK, import_export::RasterImporter::kDouble, kDOUBLE, import_export::RasterImporter::kFloat, kFLOAT, import_export::RasterImporter::kInt, kINT, kNULLT, import_export::RasterImporter::kPoint, kPOINT, import_export::RasterImporter::kSmallInt, and kSMALLINT.

Referenced by import_export::RasterImporter::getPointNamesAndSQLTypes().

231  {
232  switch (point_type) {
233  case RasterImporter::PointType::kSmallInt:
234  return kSMALLINT;
235  case RasterImporter::PointType::kInt:
236  return kINT;
237  case RasterImporter::PointType::kFloat:
238  return kFLOAT;
239  case RasterImporter::PointType::kDouble:
240  return kDOUBLE;
241  case RasterImporter::PointType::kPoint:
242  return kPOINT;
243  default:
244  CHECK(false);
245  }
246  return kNULLT;
247 }
#define CHECK(condition)
Definition: Logger.h:291
Definition: sqltypes.h:72

+ Here is the caller graph for this function:

GDALDataType import_export::anonymous_namespace{RasterImporter.cpp}::sql_type_to_gdal_data_type ( const SQLTypes  sql_type)

Definition at line 123 of file RasterImporter.cpp.

References kBIGINT, kDOUBLE, kFLOAT, kINT, kSMALLINT, kTINYINT, and to_string().

Referenced by import_export::RasterImporter::getRawPixels().

123  {
124  switch (sql_type) {
125  case kTINYINT:
126  case kSMALLINT:
127  return GDT_Int16;
128  case kINT:
129  return GDT_Int32;
130  case kBIGINT:
131  return GDT_UInt32;
132  case kFLOAT:
133  return GDT_Float32;
134  case kDOUBLE:
135  return GDT_Float64;
136  default:
137  break;
138  }
139  throw std::runtime_error("Unknown/unsupported SQL type: " + to_string(sql_type));
140 }
std::string to_string(char const *&&v)
Definition: sqltypes.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function: