GEOS 3.9.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/CoordinateArraySequence.h>
21#include <geos/geom/CoordinateSequence.h>
22
23// Forward declarations
24namespace geos {
25namespace geom {
26class Coordinate;
29}
30}
31
32using namespace geos::geom;
33
34namespace geos { // geos.
35namespace operation { // geos.operation
36namespace overlayng { // geos.operation.overlayng
37
66class GEOS_DLL RingClipper {
67
68private:
69
70 // Constants
71 static constexpr int BOX_LEFT = 3;
72 static constexpr int BOX_TOP = 2;
73 static constexpr int BOX_RIGHT = 1;
74 static constexpr int BOX_BOTTOM = 0;
75
76 // Members
77 // const Envelope* clipEnv;
78 double clipEnvMinY;
79 double clipEnvMaxY;
80 double clipEnvMinX;
81 double clipEnvMaxX;
82
83 // Methods
84
88 std::unique_ptr<CoordinateArraySequence> clipToBoxEdge(const CoordinateSequence* pts, int edgeIndex, bool closeRing) const;
89
95 void intersection(const Coordinate& a, const Coordinate& b, int edgeIndex, Coordinate& rsltPt) const;
96 double intersectionLineY(const Coordinate& a, const Coordinate& b, double y) const;
97 double intersectionLineX(const Coordinate& a, const Coordinate& b, double x) const;
98 bool isInsideEdge(const Coordinate& p, int edgeIndex) const;
99
100
101public:
102
103 RingClipper(const Envelope* env)
104 : clipEnvMinY(env->getMinY())
105 , clipEnvMaxY(env->getMaxY())
106 , clipEnvMinX(env->getMinX())
107 , clipEnvMaxX(env->getMaxX())
108 {};
109
113 std::unique_ptr<CoordinateArraySequence> clip(const CoordinateSequence* cs) const;
114
115};
116
117
118} // namespace geos.operation.overlayng
119} // namespace geos.operation
120} // namespace geos
121
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:37
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
double getMinX() const
Returns the Envelope minimum x-value. min x > max x indicates that this is a null Envelope.
double getMaxX() const
Returns the Envelope maximum x-value. min x > max x indicates that this is a null Envelope.
double getMaxY() const
Returns the Envelope maximum y-value. min y > max y indicates that this is a null Envelope.
double getMinY() const
Returns the Envelope minimum y-value. min y > max y indicates that this is a null Envelope.
Definition: RingClipper.h:66
std::unique_ptr< CoordinateArraySequence > clip(const CoordinateSequence *cs) const
Definition: IndexedNestedRingTester.h:27
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26