Coverage Report

Created: 2026-03-20 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/src/operation/overlayng/OverlayEdge.cpp
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
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
#include <geos/operation/overlayng/MaximalEdgeRing.h>
16
#include <geos/operation/overlayng/OverlayEdge.h>
17
#include <geos/operation/overlayng/OverlayLabel.h>
18
#include <geos/operation/overlayng/OverlayEdgeRing.h>
19
#include <geos/geom/Location.h>
20
#include <geos/geom/Coordinate.h>
21
#include <geos/geom/CoordinateSequence.h>
22
23
24
using geos::geom::CoordinateSequence;
25
using geos::geom::Coordinate;
26
using geos::geom::Location;
27
28
29
namespace geos {      // geos
30
namespace operation { // geos.operation
31
namespace overlayng { // geos.operation.overlayng
32
33
/*public*/
34
std::shared_ptr<const CoordinateSequence>
35
OverlayEdge::getCoordinatesOriented() const
36
0
{
37
0
    if (direction) {
38
0
        return pts;
39
0
    }
40
0
    std::unique_ptr<CoordinateSequence> ptsCopy = pts->clone();
41
0
    ptsCopy->reverse();
42
0
    return ptsCopy;
43
0
}
44
45
/**
46
* Adds the coordinates of this edge to the given list,
47
* in the direction of the edge.
48
* Duplicate coordinates are removed
49
* (which means that this is safe to use for a path
50
* of connected edges in the topology graph).
51
*
52
* @param coords the coordinate list to add to
53
*/
54
/*public*/
55
void
56
OverlayEdge::addCoordinates(CoordinateSequence* coords) const
57
3.51M
{
58
3.51M
    bool isFirstEdge = coords->size() > 0;
59
3.51M
    if (direction) {
60
3.39M
        std::size_t startIndex = 1;
61
3.39M
        if (isFirstEdge) {
62
3.24M
            startIndex = 0;
63
3.24M
        }
64
3.39M
        coords->add(*pts, startIndex, pts->size() - 1, false);
65
3.39M
    }
66
113k
    else { // is backward
67
113k
        int startIndex = (int)(pts->size()) - 2;
68
113k
        if (isFirstEdge) {
69
63.2k
            startIndex = (int)(pts->size()) - 1;
70
63.2k
        }
71
621k
        for (int i = startIndex; i >= 0; i--) {
72
507k
            coords->add(*pts, static_cast<std::size_t>(i), static_cast<std::size_t>(i), false);
73
507k
        }
74
113k
    }
75
3.51M
}
76
/*public friend*/
77
std::ostream&
78
operator<<(std::ostream& os, const OverlayEdge& oe)
79
0
{
80
0
    os << "OE( " << oe.orig();
81
0
    if (oe.pts->size() > 2) {
82
0
        os << ", " << oe.directionPt();
83
0
    }
84
0
    os << " .. " << oe.dest() << " ) ";
85
0
    oe.label->toString(oe.direction, os);
86
0
    os << oe.resultSymbol();
87
0
    os << " / Sym: ";
88
0
    oe.symOE()->getLabel()->toString(oe.symOE()->direction, os);
89
0
    os << oe.symOE()->resultSymbol();
90
0
    return os;
91
0
}
92
93
/*public*/
94
std::string
95
OverlayEdge::resultSymbol() const
96
0
{
97
0
    if (isInResultArea()) return std::string(" resA");
98
0
    if (isInResultLine()) return std::string(" resL");
99
0
    return std::string("");
100
0
}
101
102
103
104
} // namespace geos.operation.overlayng
105
} // namespace geos.operation
106
} // namespace geos
107
108