GEOS  3.8.0dev
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 #ifndef GEOS_OP_RECTANGLE_INTERSECTION_H
16 #define GEOS_OP_RECTANGLE_INTERSECTION_H
17 
18 #include <geos/export.h>
19 
20 #include <memory>
21 
22 #ifdef _MSC_VER
23 #pragma warning(push)
24 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
25 #endif
26 
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 class Point;
31 class MultiPoint;
32 class Polygon;
33 class MultiPolygon;
34 class LineString;
35 class MultiLineString;
36 class Geometry;
37 class GeometryCollection;
38 class GeometryFactory;
39 class CoordinateSequenceFactory;
40 }
41 namespace operation {
42 namespace intersection {
43 class Rectangle;
44 class RectangleIntersectionBuilder;
45 }
46 }
47 }
48 
49 namespace geos {
50 namespace operation { // geos::operation
51 namespace intersection { // geos::operation::intersection
52 
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 
100  static std::unique_ptr<geom::Geometry> clipBoundary(const geom::Geometry& geom,
101  const Rectangle& rect);
102 
103 private:
104 
105  RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect);
106 
107  std::unique_ptr<geom::Geometry> clipBoundary();
108 
109  std::unique_ptr<geom::Geometry> clip();
110 
111  const geom::Geometry& _geom;
112  const Rectangle& _rect;
113  const geom::GeometryFactory* _gf;
115 
116  void clip_geom(const geom::Geometry* g,
118  const Rectangle& rect,
119  bool keep_polygons);
120 
121  void clip_point(const geom::Point* g,
123  const Rectangle& rect);
124 
125  void clip_multipoint(const geom::MultiPoint* g,
127  const Rectangle& rect);
128 
129  void clip_linestring(const geom::LineString* g,
131  const Rectangle& rect);
132 
133  void clip_multilinestring(const geom::MultiLineString* g,
135  const Rectangle& rect);
136 
137  void clip_polygon(const geom::Polygon* g,
139  const Rectangle& rect,
140  bool keep_polygons);
141 
142  void clip_multipolygon(const geom::MultiPolygon* g,
144  const Rectangle& rect,
145  bool keep_polygons);
146 
147  void clip_geometrycollection(
148  const geom::GeometryCollection* g,
150  const Rectangle& rect,
151  bool keep_polygons);
152 
153  void clip_polygon_to_linestrings(const geom::Polygon* g,
155  const Rectangle& rect);
156 
157  void clip_polygon_to_polygons(const geom::Polygon* g,
159  const Rectangle& rect);
160 
161 
168  bool clip_linestring_parts(const geom::LineString* gi,
170  const Rectangle& rect);
171 
172 }; // class RectangleIntersection
173 
174 } // namespace geos::operation::intersection
175 } // namespace geos::operation
176 } // namespace geos
177 
178 #endif // GEOS_OP_RECTANGLE_INTERSECTION_H
Models a collection of Polygons.
Definition: MultiPolygon.h:59
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Speed-optimized clipping of a Geometry with a rectangle.
Definition: RectangleIntersection.h:74
Definition: LineString.h:69
Represents a linear polygon, which may include holes.
Definition: Polygon.h:65
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Definition: MultiPoint.h:54
A factory to create concrete instances of CoordinateSequences.
Definition: CoordinateSequenceFactory.h:47
Rebuild geometries from subpaths left by clipping with a rectangle.
Definition: RectangleIntersectionBuilder.h:63
Definition: Point.h:66
Models a collection of (}s.
Definition: MultiLineString.h:51
Clipping rectangle.
Definition: Rectangle.h:51