Traverse tree through nodepages. Create a nodebox for each node in the tree and test if it overlaps with the bounds created by user. If it's a leaf node(the highest resolution) and it overlaps, add it to the list of nodes to be pulled later.
| 544 | // If it's a leaf node(the highest resolution) and it overlaps, add |
| 545 | // it to the list of nodes to be pulled later. |
| 546 | void EsriReader::traverseTree(PagePtr page, int node) |
| 547 | { |
| 548 | int index = node % m_nodeCap; |
| 549 | |
| 550 | // find node information |
| 551 | NL::json& j = *page; |
| 552 | int firstNode = j["nodes"][0]["resourceId"].get<int>(); |
| 553 | int name = j["nodes"][index]["resourceId"].get<int>(); |
| 554 | int firstChild = j["nodes"][index]["firstChild"].get<int>(); |
| 555 | int cCount = j["nodes"][index]["childCount"].get<int>(); |
| 556 | |
| 557 | // find density information |
| 558 | double area = j["nodes"][index][ |
| 559 | m_version >= Version("2.0") ? |
| 560 | "lodThreshold" : |
| 561 | "effectiveArea" ].get<double>(); |
| 562 | int pCount = j["nodes"][index][ |
| 563 | m_version >= Version("2.0") ? |
| 564 | "vertexCount" : |
| 565 | "pointCount" ].get<int>(); |
| 566 | |
| 567 | double density = pCount / area; |
| 568 | |
| 569 | try |
| 570 | { |
| 571 | Obb obb(j["nodes"][index]["obb"]); |
| 572 | if (m_ecefTransform) |
| 573 | obb.transform(*m_ecefTransform); |
| 574 | if (m_args->obb.valid() && !obb.intersect(m_args->obb)) |
| 575 | return; |
| 576 | } |
| 577 | catch (const EsriError& err) |
| 578 | { |
| 579 | throwError(err.what()); |
| 580 | } |
| 581 | catch (const NL::json::exception& err) |
| 582 | { |
| 583 | throwError(err.what()); |
| 584 | } |
| 585 | |
| 586 | // if it's a child node and we're fetching full density, add leaf nodes |
| 587 | if (m_args->max_density == -1 && m_args->min_density == -1 && cCount == 0) |
| 588 | { |
| 589 | std::unique_lock<std::mutex> lock(m_mutex); |
| 590 | m_nodes.push_back(name); |
| 591 | return; |
| 592 | } |
| 593 | if (density < m_args->max_density && density > m_args->min_density) |
| 594 | { |
| 595 | std::unique_lock<std::mutex> lock(m_mutex); |
| 596 | m_nodes.push_back(name); |
| 597 | } |
| 598 | |
| 599 | // if have no children, we're done this branch,. |
| 600 | if (cCount == 0) |
| 601 | return; |
| 602 | |
| 603 | for (int i = 0; i < cCount; ++i) |