Coverage Report

Created: 2025-10-10 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/src/operation/polygonize/HoleAssigner.cpp
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2019 Daniel Baston <dbaston@gmail.com>
7
 *
8
 * This is free software; you can redistribute and/or modify it under
9
 * the terms of the GNU Lesser General Public Licence as published
10
 * by the Free Software Foundation.
11
 * See the COPYING file for more information.
12
 *
13
 **********************************************************************
14
 *
15
 * Last port: operation/polygonize/HoleAssigner.java 0b3c7e3eb0d3e
16
 *
17
 **********************************************************************/
18
19
#include <geos/operation/polygonize/HoleAssigner.h>
20
#include <geos/util/Interrupt.h>
21
22
namespace geos {
23
namespace operation {
24
namespace polygonize {
25
26
void
27
0
HoleAssigner::buildIndex() {
28
0
    for (EdgeRing* shell : m_shells) {
29
0
        m_shellIndex.insert(shell->getRingInternal()->getEnvelopeInternal(), shell);
30
0
    }
31
0
}
32
33
void
34
HoleAssigner::assignHolesToShells(std::vector<EdgeRing*> & holes, std::vector<EdgeRing*> & shells)
35
0
{
36
0
    HoleAssigner assigner(shells);
37
0
    assigner.assignHolesToShells(holes);
38
39
0
}
40
41
0
void HoleAssigner::assignHolesToShells(std::vector<EdgeRing*> & holes) {
42
0
    for (const auto& holeER : holes) {
43
0
        assignHoleToShell(holeER);
44
0
        GEOS_CHECK_FOR_INTERRUPTS();
45
0
    }
46
0
}
47
48
void
49
HoleAssigner::assignHoleToShell(EdgeRing* holeER)
50
0
{
51
0
    EdgeRing* shell = findEdgeRingContaining(holeER);
52
53
0
    if(shell != nullptr) {
54
0
        shell->addHole(holeER);
55
0
    }
56
0
}
57
58
std::vector<EdgeRing*>
59
0
HoleAssigner::findShells(const geom::Envelope& e) {
60
0
    std::vector<EdgeRing*> shells;
61
0
    m_shellIndex.query(e, shells);
62
63
0
    return shells;
64
0
}
65
66
EdgeRing*
67
0
HoleAssigner::findEdgeRingContaining(EdgeRing* testEr) {
68
0
    const geos::geom::Envelope* e = testEr->getRingInternal()->getEnvelopeInternal();
69
70
0
    std::vector<EdgeRing*> candidateShells = findShells(*e);
71
72
0
    return testEr->findEdgeRingContaining(candidateShells);
73
0
}
74
75
}
76
}
77
}