GEOS 3.13.1
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;
27}
28}
29
30using namespace geos::geom;
31
32namespace geos { // geos.
33namespace operation { // geos.operation
34namespace overlayng { // geos.operation.overlayng
35
64class GEOS_DLL RingClipper {
65
66private:
67
68 // Constants
69 static constexpr int BOX_LEFT = 3;
70 static constexpr int BOX_TOP = 2;
71 static constexpr int BOX_RIGHT = 1;
72 static constexpr int BOX_BOTTOM = 0;
73
74 // Members
75 const Envelope clipEnv;
76
77 // Methods
78
82 std::unique_ptr<CoordinateSequence> clipToBoxEdge(const CoordinateSequence* pts, int edgeIndex, bool closeRing) const;
83
89 void intersection(const Coordinate& a, const Coordinate& b, int edgeIndex, Coordinate& rsltPt) const;
90 double intersectionLineY(const Coordinate& a, const Coordinate& b, double y) const;
91 double intersectionLineX(const Coordinate& a, const Coordinate& b, double x) const;
92 bool isInsideEdge(const Coordinate& p, int edgeIndex) const;
93
94
95public:
96
97 RingClipper(const Envelope* env)
98 : clipEnv(*env)
99 {};
100
104 std::unique_ptr<CoordinateSequence> clip(const CoordinateSequence* cs) const;
105
106};
107
108
109} // namespace geos.operation.overlayng
110} // namespace geos.operation
111} // namespace geos
112
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:64
std::unique_ptr< CoordinateSequence > clip(const CoordinateSequence *cs) const
Definition Angle.h:26
Basic namespace for all GEOS functionalities.
Definition geos.h:39