MCPcopy Create free account
hub / github.com/OSGeo/PROJ / BuildQuadTree

Function BuildQuadTree

src/transformations/tinshift_impl.hpp:388–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386// ---------------------------------------------------------------------------
387
388static std::unique_ptr<NS_PROJ::QuadTree::QuadTree<unsigned>>
389BuildQuadTree(const TINShiftFile &file, bool forward) {
390 auto quadtree = std::unique_ptr<NS_PROJ::QuadTree::QuadTree<unsigned>>(
391 new NS_PROJ::QuadTree::QuadTree<unsigned>(GetBounds(file, forward)));
392 const auto &triangles = file.triangles();
393 const auto &vertices = file.vertices();
394 const int idxX = file.transformHorizontalComponent() && !forward ? 2 : 0;
395 const int idxY = file.transformHorizontalComponent() && !forward ? 3 : 1;
396 const unsigned colCount = file.verticesColumnCount();
397 for (size_t i = 0; i < triangles.size(); ++i) {
398 const unsigned i1 = triangles[i].idx1;
399 const unsigned i2 = triangles[i].idx2;
400 const unsigned i3 = triangles[i].idx3;
401 const double x1 = vertices[i1 * colCount + idxX];
402 const double y1 = vertices[i1 * colCount + idxY];
403 const double x2 = vertices[i2 * colCount + idxX];
404 const double y2 = vertices[i2 * colCount + idxY];
405 const double x3 = vertices[i3 * colCount + idxX];
406 const double y3 = vertices[i3 * colCount + idxY];
407 NS_PROJ::QuadTree::RectObj rect;
408 rect.minx = x1;
409 rect.miny = y1;
410 rect.maxx = x1;
411 rect.maxy = y1;
412 rect.minx = std::min(rect.minx, x2);
413 rect.miny = std::min(rect.miny, y2);
414 rect.maxx = std::max(rect.maxx, x2);
415 rect.maxy = std::max(rect.maxy, y2);
416 rect.minx = std::min(rect.minx, x3);
417 rect.miny = std::min(rect.miny, y3);
418 rect.maxx = std::max(rect.maxx, x3);
419 rect.maxy = std::max(rect.maxy, y3);
420 quadtree->insert(static_cast<unsigned>(i), rect);
421 }
422
423 return quadtree;
424}
425
426// ---------------------------------------------------------------------------
427

Callers 2

forwardMethod · 0.85
inverseMethod · 0.85

Calls 5

GetBoundsFunction · 0.85
verticesColumnCountMethod · 0.80
sizeMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected