| 343 | |
| 344 | |
| 345 | bool XMLSchema::load(xmlDocPtr doc) |
| 346 | { |
| 347 | xmlNode* root = xmlDocGetRootElement(doc); |
| 348 | // print_element_names(root); |
| 349 | |
| 350 | if (!Utils::iequals((const char*)root->name, "PointCloudSchema")) |
| 351 | { |
| 352 | std::cerr << "First node of document was not named 'PointCloudSchema'"; |
| 353 | return false; |
| 354 | } |
| 355 | |
| 356 | const unsigned SENTINEL_POS = 100000; |
| 357 | unsigned missingPos = SENTINEL_POS + 1; |
| 358 | |
| 359 | xmlNode* dimension = root->children; |
| 360 | pdal::Metadata metadata; |
| 361 | for (xmlNode *dimension = root->children; dimension; |
| 362 | dimension = dimension->next) |
| 363 | { |
| 364 | // Read off orientation setting |
| 365 | if (std::string((const char*)dimension->name) == "orientation") |
| 366 | { |
| 367 | xmlChar* n = xmlNodeListGetString(doc, dimension->children, 1); |
| 368 | if (!n) |
| 369 | { |
| 370 | std::cerr << "Unable to fetch orientation.\n"; |
| 371 | return false; |
| 372 | } |
| 373 | std::string orientation = std::string((const char*)n); |
| 374 | xmlFree(n); |
| 375 | |
| 376 | if (Utils::iequals(orientation, "dimension")) |
| 377 | m_orientation = Orientation::DimensionMajor; |
| 378 | else |
| 379 | m_orientation = Orientation::PointMajor; |
| 380 | continue; |
| 381 | } |
| 382 | |
| 383 | if (std::string((const char*)dimension->name) == "metadata") |
| 384 | { |
| 385 | m_metadata = MetadataNode("root"); |
| 386 | if (!loadMetadata(dimension, m_metadata)) |
| 387 | return false; |
| 388 | continue; |
| 389 | } |
| 390 | |
| 391 | if (dimension->type != XML_ELEMENT_NODE || |
| 392 | !Utils::iequals((const char*)dimension->name, "dimension")) |
| 393 | continue; |
| 394 | |
| 395 | XMLDim dim; |
| 396 | dim.m_position = SENTINEL_POS; |
| 397 | for (xmlNode *properties = dimension->children; properties; |
| 398 | properties = properties->next) |
| 399 | { |
| 400 | if (properties->type != XML_ELEMENT_NODE) |
| 401 | continue; |
| 402 |
nothing calls this directly
no test coverage detected