Coverage Report

Created: 2025-11-12 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/include/geos/geom/SimpleCurve.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
7
 * Copyright (C) 2005 2006 Refractions Research Inc.
8
 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
9
 * Copyright (C) 2024 ISciences, LLC
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/Curve.h>
21
#include <geos/geom/Geometry.h>
22
23
namespace geos {
24
namespace geom {
25
26
class GEOS_DLL SimpleCurve : public Curve {
27
public:
28
29
    using Curve::apply_ro;
30
    using Curve::apply_rw;
31
32
    void apply_ro(CoordinateFilter* filter) const override;
33
34
    void apply_ro(CoordinateSequenceFilter& filter) const override;
35
36
    void apply_rw(CoordinateSequenceFilter& filter) override;
37
38
    void apply_rw(const CoordinateFilter* filter) override;
39
40
    bool equalsExact(const Geometry* other, double tolerance = 0)
41
    const override;
42
43
    bool equalsIdentical(const Geometry* other) const override;
44
45
    /**
46
     * \brief
47
     * Returns a MultiPoint.
48
     * Empty for closed Curve, a Point for each vertex otherwise.
49
     */
50
    std::unique_ptr<Geometry> getBoundary() const override;
51
52
    const CoordinateXY* getCoordinate() const override;
53
54
    /// Returns coordinate dimension.
55
    uint8_t getCoordinateDimension() const override;
56
57
    virtual const Coordinate& getCoordinateN(std::size_t n) const;
58
59
    std::unique_ptr<CoordinateSequence> getCoordinates() const override;
60
61
    /// Returns a read-only pointer to internal CoordinateSequence
62
    const CoordinateSequence* getCoordinatesRO() const;
63
64
    const SimpleCurve* getCurveN(std::size_t) const override;
65
66
    /// \brief
67
    /// Return the end point of the LineString
68
    /// or NULL if this is an EMPTY LineString.
69
    ///
70
    virtual std::unique_ptr<Point> getEndPoint() const;
71
72
    const Envelope* getEnvelopeInternal() const override
73
22.9M
    {
74
22.9M
        return &envelope;
75
22.9M
    }
76
77
    std::size_t getNumCurves() const override;
78
79
    std::size_t getNumPoints() const override;
80
81
    virtual std::unique_ptr<Point> getPointN(std::size_t n) const;
82
83
    /// \brief
84
    /// Return the start point of the LineString
85
    /// or NULL if this is an EMPTY LineString.
86
    ///
87
    virtual std::unique_ptr<Point> getStartPoint() const;
88
89
    bool hasM() const override;
90
91
    bool hasZ() const override;
92
93
    bool isClosed() const override;
94
95
    virtual bool isCoordinate(CoordinateXY& pt) const;
96
97
    virtual bool isCurved() const = 0;
98
99
    bool isEmpty() const override;
100
101
    /** \brief
102
     * Normalizes a SimpleCurve.
103
     *
104
     * A normalized simple curve
105
     * has the first point which is not equal to its reflected point
106
     * less than the reflected point.
107
     */
108
    void normalize() override;
109
110
    /**
111
     * \brief
112
     * Take ownership of the CoordinateSequence managed by this geometry.
113
     * After releasing the coordinates, the geometry should be considered
114
     * in a moved-from state and should not be accessed.
115
     * @return this Geometry's CoordinateSequence.
116
     */
117
    std::unique_ptr<CoordinateSequence> releaseCoordinates();
118
119
protected:
120
121
    SimpleCurve(const SimpleCurve& other);
122
123
    SimpleCurve(std::unique_ptr<CoordinateSequence>&& newCoords,
124
                bool isLinear,
125
                const GeometryFactory& factory);
126
127
    int compareToSameClass(const Geometry* ls) const override;
128
129
    Envelope computeEnvelopeInternal(bool isLinear) const;
130
131
    // TODO: hold value or shared_ptr instead of unique_ptr?
132
    std::unique_ptr<CoordinateSequence> points;
133
    mutable Envelope envelope;
134
135
136
private:
137
138
    void normalizeClosed();
139
};
140
141
}
142
}