GEOS 3.15.0dev
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 {
23class CoordinateSequence;
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 // Close the ring, if necessary, using a linear segment
44 void closeRing();
45
46 // Get the result geometry
47 std::unique_ptr<Curve> getGeometry();
48
49 // Get a reference to the CoordinateSequence to which
50 // coordinates are currently being added.
51 CoordinateSequence& getSeq(bool isCurved);
52
53 bool hasZ() const {
54 return m_hasZ;
55 }
56
57 bool hasM() const {
58 return m_hasM;
59 }
60
61 bool hasActiveSequence() const {
62 return m_pts != nullptr;
63 }
64
65 bool isCurved() const {
66 return m_isCurved;
67 }
68
69 void setOutputLinearRing(bool outputLinearRing) {
70 m_outputLinearRing = outputLinearRing;
71 }
72
73private:
74 void finishCurve();
75 void finishLine();
76
77 std::vector<std::unique_ptr<SimpleCurve>> m_curves;
78 std::unique_ptr<CoordinateSequence> m_pts{nullptr};
79 const GeometryFactory& m_gfact;
80 const bool m_hasZ;
81 const bool m_hasM;
82 bool m_outputLinearRing{true};
83 bool m_isCurved{false};
84};
85
86}
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
Definition CurveBuilder.h:33
Provides classes that parse and modify Geometry objects.
Definition ComponentCoordinateExtracter.h:28
Definition Angle.h:26