Coverage Report

Created: 2026-06-10 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/include/geos/geom/SurfaceImpl.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2024 ISciences, LLC
7
 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
8
 * Copyright (C) 2005 2006 Refractions Research Inc.
9
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
10
 *
11
 * This is free software; you can redistribute and/or modify it under
12
 * the terms of the GNU Lesser General Public Licence as published
13
 * by the Free Software Foundation.
14
 * See the COPYING file for more information.
15
 *
16
 **********************************************************************/
17
18
#pragma once
19
20
#include <geos/geom/CoordinateSequenceFilter.h>
21
#include <geos/geom/Curve.h>
22
#include <geos/geom/GeometryComponentFilter.h>
23
#include <geos/geom/GeometryFilter.h>
24
#include <geos/geom/LinearRing.h>
25
#include <geos/geom/Surface.h>
26
#include <geos/util/IllegalArgumentException.h>
27
28
namespace geos {
29
namespace geom {
30
31
template<typename RingType>
32
class SurfaceImpl : public Surface {
33
34
protected:
35
36
    SurfaceImpl(const SurfaceImpl& p)
37
        :
38
5.09M
        Surface(p),
39
5.09M
        shell(static_cast<RingType*>(p.shell->clone().release())),
40
5.09M
        holes(p.holes.size())
41
5.09M
    {
42
6.73M
        for (std::size_t i = 0; i < holes.size(); ++i) {
43
1.63M
            holes[i].reset(static_cast<RingType*>(p.holes[i]->clone().release()));
44
1.63M
        }
45
5.09M
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::SurfaceImpl(geos::geom::SurfaceImpl<geos::geom::LinearRing> const&)
Line
Count
Source
38
5.09M
        Surface(p),
39
5.09M
        shell(static_cast<RingType*>(p.shell->clone().release())),
40
5.09M
        holes(p.holes.size())
41
5.09M
    {
42
6.73M
        for (std::size_t i = 0; i < holes.size(); ++i) {
43
1.63M
            holes[i].reset(static_cast<RingType*>(p.holes[i]->clone().release()));
44
1.63M
        }
45
5.09M
    }
geos::geom::SurfaceImpl<geos::geom::Curve>::SurfaceImpl(geos::geom::SurfaceImpl<geos::geom::Curve> const&)
Line
Count
Source
38
24
        Surface(p),
39
24
        shell(static_cast<RingType*>(p.shell->clone().release())),
40
24
        holes(p.holes.size())
41
24
    {
42
53
        for (std::size_t i = 0; i < holes.size(); ++i) {
43
29
            holes[i].reset(static_cast<RingType*>(p.holes[i]->clone().release()));
44
29
        }
45
24
    }
46
47
    /**
48
     * Constructs a <code>Surface</code> with the given exterior
49
     * and interior boundaries.
50
     *
51
     * @param  newShell  the outer boundary of the new Polygon,
52
     *                   or <code>null</code> or an empty
53
             *         Curve if the empty geometry
54
     *                   is to be created.
55
     *
56
     * @param  newHoles  the rings defining the inner
57
     *                   boundaries of the new Surface, or
58
     *                   null or empty Curve
59
     *                   if the empty geometry is to be created.
60
     *
61
     * @param newFactory the GeometryFactory used to create this geometry
62
     *
63
     * Polygon will take ownership of shell and hole curves
64
     */
65
    SurfaceImpl(std::unique_ptr<RingType>&& newShell,
66
                const GeometryFactory& newFactory) :
67
189k
        Surface(&newFactory),
68
189k
        shell(std::move(newShell))
69
189k
    {
70
189k
        if (shell == nullptr) {
71
0
            shell.reset(static_cast<RingType*>(createEmptyRing(newFactory).release()));
72
0
        }
73
74
189k
        validateConstruction();
75
189k
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::SurfaceImpl(std::__1::unique_ptr<geos::geom::LinearRing, std::__1::default_delete<geos::geom::LinearRing> >&&, geos::geom::GeometryFactory const&)
Line
Count
Source
67
188k
        Surface(&newFactory),
68
188k
        shell(std::move(newShell))
69
188k
    {
70
188k
        if (shell == nullptr) {
71
0
            shell.reset(static_cast<RingType*>(createEmptyRing(newFactory).release()));
72
0
        }
73
74
188k
        validateConstruction();
75
188k
    }
geos::geom::SurfaceImpl<geos::geom::Curve>::SurfaceImpl(std::__1::unique_ptr<geos::geom::Curve, std::__1::default_delete<geos::geom::Curve> >&&, geos::geom::GeometryFactory const&)
Line
Count
Source
67
1.50k
        Surface(&newFactory),
68
1.50k
        shell(std::move(newShell))
69
1.50k
    {
70
1.50k
        if (shell == nullptr) {
71
0
            shell.reset(static_cast<RingType*>(createEmptyRing(newFactory).release()));
72
0
        }
73
74
1.50k
        validateConstruction();
75
1.50k
    }
76
77
    SurfaceImpl(std::unique_ptr<RingType>&& newShell,
78
                std::vector<std::unique_ptr<RingType>>&& newHoles,
79
                const GeometryFactory& newFactory) :
80
1.71M
        Surface(&newFactory),
81
1.71M
        shell(std::move(newShell)),
82
1.71M
        holes(std::move(newHoles))
83
1.71M
    {
84
1.71M
        if (shell == nullptr) {
85
0
            shell.reset(static_cast<RingType*>(createEmptyRing(newFactory).release()));
86
0
        }
87
88
1.71M
        validateConstruction();
89
1.71M
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::SurfaceImpl(std::__1::unique_ptr<geos::geom::LinearRing, std::__1::default_delete<geos::geom::LinearRing> >&&, std::__1::vector<std::__1::unique_ptr<geos::geom::LinearRing, std::__1::default_delete<geos::geom::LinearRing> >, std::__1::allocator<std::__1::unique_ptr<geos::geom::LinearRing, std::__1::default_delete<geos::geom::LinearRing> > > >&&, geos::geom::GeometryFactory const&)
Line
Count
Source
80
1.71M
        Surface(&newFactory),
81
1.71M
        shell(std::move(newShell)),
82
1.71M
        holes(std::move(newHoles))
83
1.71M
    {
84
1.71M
        if (shell == nullptr) {
85
0
            shell.reset(static_cast<RingType*>(createEmptyRing(newFactory).release()));
86
0
        }
87
88
1.71M
        validateConstruction();
89
1.71M
    }
geos::geom::SurfaceImpl<geos::geom::Curve>::SurfaceImpl(std::__1::unique_ptr<geos::geom::Curve, std::__1::default_delete<geos::geom::Curve> >&&, std::__1::vector<std::__1::unique_ptr<geos::geom::Curve, std::__1::default_delete<geos::geom::Curve> >, std::__1::allocator<std::__1::unique_ptr<geos::geom::Curve, std::__1::default_delete<geos::geom::Curve> > > >&&, geos::geom::GeometryFactory const&)
Line
Count
Source
80
92
        Surface(&newFactory),
81
92
        shell(std::move(newShell)),
82
92
        holes(std::move(newHoles))
83
92
    {
84
92
        if (shell == nullptr) {
85
0
            shell.reset(static_cast<RingType*>(createEmptyRing(newFactory).release()));
86
0
        }
87
88
92
        validateConstruction();
89
92
    }
90
91
public:
92
93
    const RingType*
94
    getExteriorRing() const override
95
40.1M
    {
96
40.1M
        return shell.get();
97
40.1M
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::getExteriorRing() const
Line
Count
Source
95
40.1M
    {
96
40.1M
        return shell.get();
97
40.1M
    }
geos::geom::SurfaceImpl<geos::geom::Curve>::getExteriorRing() const
Line
Count
Source
95
11.2k
    {
96
11.2k
        return shell.get();
97
11.2k
    }
98
99
    RingType*
100
    getExteriorRing() override
101
2.42k
    {
102
2.42k
        return shell.get();
103
2.42k
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::getExteriorRing()
Line
Count
Source
101
2.42k
    {
102
2.42k
        return shell.get();
103
2.42k
    }
Unexecuted instantiation: geos::geom::SurfaceImpl<geos::geom::Curve>::getExteriorRing()
104
105
    const RingType*
106
    getInteriorRingN(std::size_t n) const override
107
5.01M
    {
108
5.01M
        return holes[n].get();
109
5.01M
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::getInteriorRingN(unsigned long) const
Line
Count
Source
107
5.01M
    {
108
5.01M
        return holes[n].get();
109
5.01M
    }
geos::geom::SurfaceImpl<geos::geom::Curve>::getInteriorRingN(unsigned long) const
Line
Count
Source
107
910
    {
108
910
        return holes[n].get();
109
910
    }
110
111
    RingType*
112
    getInteriorRingN(std::size_t n) override
113
287
    {
114
287
        return holes[n].get();
115
287
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::getInteriorRingN(unsigned long)
Line
Count
Source
113
287
    {
114
287
        return holes[n].get();
115
287
    }
Unexecuted instantiation: geos::geom::SurfaceImpl<geos::geom::Curve>::getInteriorRingN(unsigned long)
116
117
    size_t getNumInteriorRing() const override
118
17.9M
    {
119
17.9M
        return holes.size();
120
17.9M
    }
geos::geom::SurfaceImpl<geos::geom::LinearRing>::getNumInteriorRing() const
Line
Count
Source
118
17.9M
    {
119
17.9M
        return holes.size();
120
17.9M
    }
geos::geom::SurfaceImpl<geos::geom::Curve>::getNumInteriorRing() const
Line
Count
Source
118
3.95k
    {
119
3.95k
        return holes.size();
120
3.95k
    }
121
122
    /**
123
    * \brief
124
    * Take ownership of this Surface's exterior ring.
125
    * After releasing the exterior ring, the Surface should be
126
    * considered in a moved-from state and should not be accessed,
127
    * except to release the interior rings (if desired.)
128
    * @return exterior ring
129
    */
130
    std::unique_ptr<RingType>
131
    releaseExteriorRing()
132
    {
133
        return std::move(shell);
134
    }
135
136
    /**
137
    * \brief
138
    * Take ownership of this Surfaces's interior rings.
139
    * After releasing the rings, the Surface should be
140
    * considered in a moved-from state and should not be accessed,
141
    * except to release the exterior ring (if desired.)
142
    * @return vector of rings (may be empty)
143
    */
144
    std::vector<std::unique_ptr<RingType>> releaseInteriorRings()
145
    {
146
        return std::move(holes);
147
    }
148
149
protected:
150
    std::unique_ptr<RingType> shell;
151
    std::vector<std::unique_ptr<RingType>> holes;
152
153
};
154
155
}
156
}