GEOS  3.11.1
RectangleIntersection.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2014 Mika Heiskanen <mika.heiskanen@fmi.fi>
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 <memory>
20 
21 #ifdef _MSC_VER
22 #pragma warning(push)
23 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
24 #endif
25 
26 // Forward declarations
27 namespace geos {
28 namespace geom {
29 class Point;
30 class MultiPoint;
31 class Polygon;
32 class MultiPolygon;
33 class LineString;
34 class MultiLineString;
35 class Geometry;
36 class GeometryCollection;
37 class GeometryFactory;
38 class CoordinateSequenceFactory;
39 }
40 namespace operation {
41 namespace intersection {
42 class Rectangle;
43 class RectangleIntersectionBuilder;
44 }
45 }
46 }
47 
48 namespace geos {
49 namespace operation { // geos::operation
50 namespace intersection { // geos::operation::intersection
51 
74 class GEOS_DLL RectangleIntersection {
75 public:
76 
85  static std::unique_ptr<geom::Geometry> clip(const geom::Geometry& geom,
86  const Rectangle& rect);
87 
99  static std::unique_ptr<geom::Geometry> clipBoundary(const geom::Geometry& geom,
100  const Rectangle& rect);
101 
102 private:
103 
104  RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect);
105 
106  std::unique_ptr<geom::Geometry> clipBoundary();
107 
108  std::unique_ptr<geom::Geometry> clip();
109 
110  const geom::Geometry& _geom;
111  const Rectangle& _rect;
112  const geom::GeometryFactory* _gf;
114 
115  void clip_geom(const geom::Geometry* g,
117  const Rectangle& rect,
118  bool keep_polygons);
119 
120  void clip_point(const geom::Point* g,
122  const Rectangle& rect);
123 
124  void clip_multipoint(const geom::MultiPoint* g,
126  const Rectangle& rect);
127 
128  void clip_linestring(const geom::LineString* g,
130  const Rectangle& rect);
131 
132  void clip_multilinestring(const geom::MultiLineString* g,
134  const Rectangle& rect);
135 
136  void clip_polygon(const geom::Polygon* g,
138  const Rectangle& rect,
139  bool keep_polygons);
140 
141  void clip_multipolygon(const geom::MultiPolygon* g,
143  const Rectangle& rect,
144  bool keep_polygons);
145 
146  void clip_geometrycollection(
147  const geom::GeometryCollection* g,
149  const Rectangle& rect,
150  bool keep_polygons);
151 
152  void clip_polygon_to_linestrings(const geom::Polygon* g,
154  const Rectangle& rect);
155 
156  void clip_polygon_to_polygons(const geom::Polygon* g,
158  const Rectangle& rect);
159 
160 
167  bool clip_linestring_parts(const geom::LineString* gi,
169  const Rectangle& rect);
170 
171 }; // class RectangleIntersection
172 
173 } // namespace geos::operation::intersection
174 } // namespace geos::operation
175 } // namespace geos
176 
Definition: MultiPolygon.h:59
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Speed-optimized clipping of a Geometry with a rectangle.
Definition: RectangleIntersection.h:74
Definition: LineString.h:66
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:52
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
Definition: MultiPoint.h:51
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:44
Rebuild geometries from subpaths left by clipping with a rectangle.
Definition: RectangleIntersectionBuilder.h:62
Definition: Point.h:63
Models a collection of LineStrings.
Definition: MultiLineString.h:50
Clipping rectangle.
Definition: Rectangle.h:50