GEOS  3.13.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 #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 }
39 namespace operation {
40 namespace intersection {
41 class Rectangle;
42 class RectangleIntersectionBuilder;
43 }
44 }
45 }
46 
47 namespace geos {
48 namespace operation { // geos::operation
49 namespace intersection { // geos::operation::intersection
50 
73 class GEOS_DLL RectangleIntersection {
74 public:
75 
84  static std::unique_ptr<geom::Geometry> clip(const geom::Geometry& geom,
85  const Rectangle& rect);
86 
98  static std::unique_ptr<geom::Geometry> clipBoundary(const geom::Geometry& geom,
99  const Rectangle& rect);
100 
101 private:
102 
103  RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect);
104 
105  std::unique_ptr<geom::Geometry> clipBoundary();
106 
107  std::unique_ptr<geom::Geometry> clip();
108 
109  const geom::Geometry& _geom;
110  const Rectangle& _rect;
111  const geom::GeometryFactory* _gf;
112 
113  void clip_geom(const geom::Geometry* g,
115  const Rectangle& rect,
116  bool keep_polygons);
117 
118  void clip_point(const geom::Point* g,
120  const Rectangle& rect);
121 
122  void clip_multipoint(const geom::MultiPoint* g,
124  const Rectangle& rect);
125 
126  void clip_linestring(const geom::LineString* g,
128  const Rectangle& rect);
129 
130  void clip_multilinestring(const geom::MultiLineString* g,
132  const Rectangle& rect);
133 
134  void clip_polygon(const geom::Polygon* g,
136  const Rectangle& rect,
137  bool keep_polygons);
138 
139  void clip_multipolygon(const geom::MultiPolygon* g,
141  const Rectangle& rect,
142  bool keep_polygons);
143 
144  void clip_geometrycollection(
145  const geom::GeometryCollection* g,
147  const Rectangle& rect,
148  bool keep_polygons);
149 
150  void clip_polygon_to_linestrings(const geom::Polygon* g,
152  const Rectangle& rect);
153 
154  void clip_polygon_to_polygons(const geom::Polygon* g,
156  const Rectangle& rect);
157 
158 
165  bool clip_linestring_parts(const geom::LineString* gi,
167  const Rectangle& rect);
168 
169 }; // class RectangleIntersection
170 
171 } // namespace geos::operation::intersection
172 } // namespace geos::operation
173 } // namespace geos
174 
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:51
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:65
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: LineString.h:65
Models a collection of LineStrings.
Definition: MultiLineString.h:49
Definition: MultiPoint.h:50
Definition: MultiPolygon.h:58
Definition: Point.h:61
Represents a linear polygon, which may include holes.
Definition: Polygon.h:60
Rebuild geometries from subpaths left by clipping with a rectangle.
Definition: RectangleIntersectionBuilder.h:63
Speed-optimized clipping of a Geometry with a rectangle.
Definition: RectangleIntersection.h:73
static std::unique_ptr< geom::Geometry > clipBoundary(const geom::Geometry &geom, const Rectangle &rect)
Clip boundary of a geometry with a rectangle.
static std::unique_ptr< geom::Geometry > clip(const geom::Geometry &geom, const Rectangle &rect)
Clip geometry with a rectangle.
Clipping rectangle.
Definition: operation/intersection/Rectangle.h:51
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25