GEOS 3.14.0dev
RingClipper.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/export.h>
18
19#include <geos/geom/Envelope.h>
20#include <geos/geom/CoordinateSequence.h>
21
22// Forward declarations
23namespace geos {
24namespace geom {
25class Coordinate;
26class CoordinateSequence;
27}
28}
29
30namespace geos { // geos.
31namespace operation { // geos.operation
32namespace overlayng { // geos.operation.overlayng
33
62class GEOS_DLL RingClipper {
66
67private:
68
69 // Constants
70 static constexpr int BOX_LEFT = 3;
71 static constexpr int BOX_TOP = 2;
72 static constexpr int BOX_RIGHT = 1;
73 static constexpr int BOX_BOTTOM = 0;
74
75 // Members
76 const Envelope clipEnv;
77
78 // Methods
79
83 std::unique_ptr<CoordinateSequence> clipToBoxEdge(const CoordinateSequence* pts, int edgeIndex, bool closeRing) const;
84
90 void intersection(const Coordinate& a, const Coordinate& b, int edgeIndex, Coordinate& rsltPt) const;
91 double intersectionLineY(const Coordinate& a, const Coordinate& b, double y) const;
92 double intersectionLineX(const Coordinate& a, const Coordinate& b, double x) const;
93 bool isInsideEdge(const Coordinate& p, int edgeIndex) const;
94
95
96public:
97
98 RingClipper(const Envelope* env)
99 : clipEnv(*env)
100 {};
101
105 std::unique_ptr<CoordinateSequence> clip(const CoordinateSequence* cs) const;
106
107};
108
109
110} // namespace geos.operation.overlayng
111} // namespace geos.operation
112} // namespace geos
113
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:217
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Definition RingClipper.h:62
std::unique_ptr< CoordinateSequence > clip(const CoordinateSequence *cs) const
Basic namespace for all GEOS functionalities.
Definition geos.h:39