GEOS 3.15.0dev
LineLimiter.h
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#pragma once
16
17#include <geos/geom/CoordinateSequence.h>
18
19#include <geos/export.h>
20#include <array>
21#include <memory>
22#include <vector>
23
24// Forward declarations
25namespace geos {
26namespace geom {
27class Envelope;
28class Coordinate;
29class CoordinateSequence;
30}
31}
32
33namespace geos { // geos.
34namespace operation { // geos.operation
35namespace overlayng { // geos.operation.overlayng
36
54class GEOS_DLL LineLimiter {
57 using CoordinateXY = geos::geom::CoordinateXY;
59
60private:
61
62 // Members
63 const Envelope* limitEnv;
64 std::unique_ptr<geom::CoordinateSequence> ptList;
65 const CoordinateXY* lastOutside;
66 std::vector<std::unique_ptr<CoordinateSequence>> sections;
67 bool hasZ{false};
68 bool hasM{false};
69
70 // Methods
71 template<typename CoordType>
72 void addPoint(const CoordType& p);
73
74 template<typename CoordType>
75 void addOutside(const CoordType& p);
76 bool isLastSegmentIntersecting(const CoordinateXY& p) const;
77 bool isSectionOpen() const;
78
79 template<typename CoordType>
80 void startSection();
81 void finishSection();
82
83
84public:
85
86 LineLimiter(const Envelope* env)
87 : limitEnv(env)
88 , ptList(nullptr)
89 , lastOutside(nullptr)
90 {};
91
92 std::vector<std::unique_ptr<CoordinateSequence>>& limit(const CoordinateSequence *pts);
93
94};
95
96
97} // namespace geos.operation.overlayng
98} // namespace geos.operation
99} // namespace geos
100
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:220
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Definition LineLimiter.h:54
Basic namespace for all GEOS functionalities.
Definition geos.h:38