GEOS 3.15.0beta1
CurveBuilder.h
1/**********************************************************************
2*
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2026 ISciences LLC
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 Foundations.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#pragma once
16
17#include <geos/export.h>
18
19#include <memory>
20#include <vector>
21
22namespace geos::geom {
24class Curve;
25class GeometryFactory;
26class SimpleCurve;
27}
28
29namespace geos::geom::util {
30
33class GEOS_DLL CurveBuilder {
34public:
35 CurveBuilder(const GeometryFactory& gfact, bool hasZ, bool hasM);
36
37 // Add all coordinates in the provided geometry
38 void add(const Curve& geom);
39
40 // Add all coordinates in the provided sequence
41 void add(const CoordinateSequence& seq, bool isCurved);
42
43 // Add coordinates between the specified indices (inclusive)
44 void add(const CoordinateSequence& seq, std::size_t from, std::size_t to, bool isCurved);
45
46 // Close the ring, if necessary, using a linear segment
47 void closeRing();
48
49 // Get the result geometry
50 std::unique_ptr<Curve> getGeometry();
51
52 // Get a reference to the CoordinateSequence to which
53 // coordinates are currently being added.
54 CoordinateSequence& getSeq(bool isCurved);
55
56 bool hasZ() const {
57 return m_hasZ;
58 }
59
60 bool hasM() const {
61 return m_hasM;
62 }
63
64 bool hasActiveSequence() const {
65 return m_pts != nullptr;
66 }
67
68 bool isCurved() const {
69 return m_isCurved;
70 }
71
72 void setOutputLinearRing(bool outputLinearRing) {
73 m_outputLinearRing = outputLinearRing;
74 }
75
76private:
77 void finishCurve();
78 void finishLine();
79
80 std::vector<std::unique_ptr<SimpleCurve>> m_curves;
81 std::unique_ptr<CoordinateSequence> m_pts{nullptr};
82 const GeometryFactory& m_gfact;
83 const bool m_hasZ;
84 const bool m_hasM;
85 bool m_outputLinearRing{true};
86 bool m_isCurved{false};
87};
88
89}
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:72
Provides classes that parse and modify Geometry objects.
Definition ComponentCoordinateExtracter.h:28
Definition Angle.h:26