Coverage Report

Created: 2026-08-13 07:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/src/operation/relateng/IMPredicate.cpp
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (c) 2024 Martin Davis
7
 * Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
8
 *
9
 * This is free software; you can redistribute and/or modify it under
10
 * the terms of the GNU Lesser General Public Licence as published
11
 * by the Free Software Foundation.
12
 * See the COPYING file for more information.
13
 *
14
 **********************************************************************/
15
16
#include <geos/operation/relateng/IMPredicate.h>
17
#include <geos/geom/Envelope.h>
18
#include <geos/geom/Location.h>
19
#include <geos/constants.h>
20
21
#include <sstream>
22
23
24
using geos::geom::Envelope;
25
using geos::geom::Location;
26
27
28
namespace geos {      // geos
29
namespace operation { // geos.operation
30
namespace relateng {  // geos.operation.relateng
31
32
33
/* public static */
34
bool
35
IMPredicate::isDimsCompatibleWithCovers(int dim0, int dim1)
36
0
{
37
    //- allow Points coveredBy zero-length Lines
38
0
    if (dim0 == Dimension::P && dim1 == Dimension::L)
39
0
        return true;
40
0
    return dim0 >= dim1;
41
0
}
42
43
44
/* public */
45
void
46
IMPredicate::init(int dA, int dB)
47
0
{
48
0
    dimA = dA;
49
0
    dimB = dB;
50
0
}
51
52
53
/* public */
54
void
55
IMPredicate::updateDimension(Location locA, Location locB, int dimension)
56
0
{
57
    //-- only record an increased dimension value
58
0
    if (isDimChanged(locA, locB, dimension)) {
59
0
        intMatrix.set(locA, locB, dimension);
60
        //-- set value if predicate value can be known
61
0
        if (isDetermined()) {
62
0
            setValue(valueIM());
63
0
        }
64
0
    }
65
0
}
66
67
68
/* public */
69
bool
70
IMPredicate::isDimChanged(Location locA, Location locB, int dimension) const
71
0
{
72
0
    return dimension > intMatrix.get(locA, locB);
73
0
}
74
75
76
/* protected */
77
bool
78
IMPredicate::intersectsExteriorOf(bool isA) const
79
0
{
80
0
    if (isA) {
81
0
        return isIntersects(Location::EXTERIOR, Location::INTERIOR)
82
0
            || isIntersects(Location::EXTERIOR, Location::BOUNDARY);
83
0
    }
84
0
    else {
85
0
        return isIntersects(Location::INTERIOR, Location::EXTERIOR)
86
0
            || isIntersects(Location::BOUNDARY, Location::EXTERIOR);
87
0
    }
88
0
}
89
90
91
/* protected */
92
bool
93
IMPredicate::isIntersects(Location locA, Location locB) const
94
0
{
95
0
    return intMatrix.get(locA, locB) >= Dimension::P;
96
0
}
97
98
99
/* public */
100
bool
101
IMPredicate::isKnown(Location locA, Location locB) const
102
0
{
103
0
    return intMatrix.get(locA, locB) != DIM_UNKNOWN;
104
0
}
105
106
107
/* public */
108
bool
109
IMPredicate::isDimension(Location locA, Location locB, int dimension) const
110
0
{
111
0
    return intMatrix.get(locA, locB) == dimension;
112
0
}
113
114
115
/* public */
116
int
117
IMPredicate::getDimension(Location locA, Location locB) const
118
0
{
119
0
    return intMatrix.get(locA, locB);
120
0
}
121
122
123
/* public */
124
void
125
IMPredicate::finish()
126
0
{
127
0
    setValue(valueIM());
128
0
}
129
130
131
/* public */
132
std::string
133
IMPredicate::toString() const
134
0
{
135
0
    return name() + ": " + intMatrix.toString();
136
0
}
137
138
139
/* public friend */
140
std::ostream&
141
operator<<(std::ostream& os, const IMPredicate& imp)
142
0
{
143
0
    os << imp.toString() << " " << imp.intMatrix;
144
0
    return os;
145
0
}
146
147
148
149
} // namespace geos.operation.overlayng
150
} // namespace geos.operation
151
} // namespace geos
152
153
154
155