OmniSciDB  c1a53651b2
 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)
 

Function Documentation

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

Definition at line 248 of file RasterImporter.cpp.

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

Definition at line 252 of file RasterImporter.cpp.

252  {
253  return 6378136.99911 * log(tan(.00872664626 * y + .785398163397));
254 }
SQLTypes import_export::anonymous_namespace{RasterImporter.cpp}::gdal_data_type_to_sql_type ( const GDALDataType  gdal_data_type)

Definition at line 97 of file RasterImporter.cpp.

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

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

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

+ Here is the call graph for this function:

+ 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 141 of file RasterImporter.cpp.

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

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

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

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

+ 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 122 of file RasterImporter.cpp.

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: