GEOS  3.13.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
23 namespace geos {
24 namespace geom {
25 class Coordinate;
26 class CoordinateSequence;
27 }
28 }
29 
30 using namespace geos::geom;
31 
32 namespace geos { // geos.
33 namespace operation { // geos.operation
34 namespace overlayng { // geos.operation.overlayng
35 
64 class GEOS_DLL RingClipper {
65 
66 private:
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 
95 public:
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:216
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Definition: RingClipper.h:64
std::unique_ptr< CoordinateSequence > clip(const CoordinateSequence *cs) const
Definition: Angle.h:26
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25