GEOS  3.6.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 #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 {
76  public:
77 
86  static std::auto_ptr<geom::Geometry> clip(const geom::Geometry & geom,
87  const Rectangle & rect);
88 
101  static std::auto_ptr<geom::Geometry> clipBoundary(const geom::Geometry & geom,
102  const Rectangle & rect);
103 
104 private:
105 
106  RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect);
107 
108  std::auto_ptr<geom::Geometry> clipBoundary();
109 
110  std::auto_ptr<geom::Geometry> clip();
111 
112  const geom::Geometry &_geom;
113  const Rectangle &_rect;
114  const geom::GeometryFactory *_gf;
116 
117  void clip_geom(const geom::Geometry * g,
119  const Rectangle & rect,
120  bool keep_polygons);
121 
122  void clip_point(const geom::Point * g,
124  const Rectangle & rect);
125 
126  void clip_multipoint(const geom::MultiPoint * g,
128  const Rectangle & rect);
129 
130  void clip_linestring(const geom::LineString * g,
132  const Rectangle & rect);
133 
134  void clip_multilinestring(const geom::MultiLineString * g,
136  const Rectangle & rect);
137 
138  void clip_polygon(const geom::Polygon * g,
140  const Rectangle & rect,
141  bool keep_polygons);
142 
143  void clip_multipolygon(const geom::MultiPolygon * g,
145  const Rectangle & rect,
146  bool keep_polygons);
147 
148  void clip_geometrycollection(
149  const geom::GeometryCollection * g,
151  const Rectangle & rect,
152  bool keep_polygons);
153 
154  void clip_polygon_to_linestrings(const geom::Polygon * g,
156  const Rectangle & rect);
157 
158  void clip_polygon_to_polygons(const geom::Polygon * g,
160  const Rectangle & rect);
161 
162 
169  bool clip_linestring_parts(const geom::LineString * gi,
171  const Rectangle & rect);
172 
173 }; // class RectangleIntersection
174 
175 } // namespace geos::operation::intersection
176 } // namespace geos::operation
177 } // namespace geos
178 
179 #endif // GEOS_OP_RECTANGLE_INTERSECTION_H
Models a collection of Polygons.
Definition: MultiPolygon.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Speed-optimized clipping of a Geometry with a rectangle.
Definition: RectangleIntersection.h:74
Definition: LineString.h:70
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
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:56
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Definition: MultiPoint.h:55
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:67
Models a collection of (}s.
Definition: MultiLineString.h:51
Clipping rectangle.
Definition: Rectangle.h:51