/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/CPP/geos.x/i/geos/geom/Geometry.h | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 1 | 1 | 100.0 |
branch | n/a | ||
condition | n/a | ||
subroutine | n/a | ||
pod | n/a | ||
total | 1 | 1 | 100.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | /********************************************************************** | ||||||
2 | * | ||||||
3 | * GEOS - Geometry Engine Open Source | ||||||
4 | * http://geos.osgeo.org | ||||||
5 | * | ||||||
6 | * Copyright (C) 2009 2011 Sandro Santilli |
||||||
7 | * Copyright (C) 2005 2006 Refractions Research Inc. | ||||||
8 | * Copyright (C) 2001-2002 Vivid Solutions Inc. | ||||||
9 | * | ||||||
10 | * This is free software; you can redistribute and/or modify it under | ||||||
11 | * the terms of the GNU Lesser General Public Licence as published | ||||||
12 | * by the Free Software Foundation. | ||||||
13 | * See the COPYING file for more information. | ||||||
14 | * | ||||||
15 | ********************************************************************** | ||||||
16 | * | ||||||
17 | * Last port: geom/Geometry.java rev. 1.112 | ||||||
18 | * | ||||||
19 | **********************************************************************/ | ||||||
20 | |||||||
21 | #ifndef GEOS_GEOM_GEOMETRY_H | ||||||
22 | #define GEOS_GEOM_GEOMETRY_H | ||||||
23 | |||||||
24 | #ifndef USE_UNSTABLE_GEOS_CPP_API | ||||||
25 | #ifndef _MSC_VER | ||||||
26 | # warning "The GEOS C++ API is unstable, please use the C API instead" | ||||||
27 | # warning "HINT: #include geos_c.h" | ||||||
28 | #else | ||||||
29 | #pragma message("The GEOS C++ API is unstable, please use the C API instead") | ||||||
30 | #pragma message("HINT: #include geos_c.h") | ||||||
31 | #endif | ||||||
32 | #endif | ||||||
33 | |||||||
34 | #include |
||||||
35 | #include |
||||||
36 | #include |
||||||
37 | #include |
||||||
38 | #include |
||||||
39 | #include |
||||||
40 | |||||||
41 | #include |
||||||
42 | #include |
||||||
43 | #include |
||||||
44 | #include |
||||||
45 | |||||||
46 | #ifdef _MSC_VER | ||||||
47 | #pragma warning(push) | ||||||
48 | #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class | ||||||
49 | #pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list | ||||||
50 | #endif | ||||||
51 | |||||||
52 | // Forward declarations | ||||||
53 | namespace geos { | ||||||
54 | namespace geom { | ||||||
55 | class Coordinate; | ||||||
56 | class CoordinateFilter; | ||||||
57 | class CoordinateSequence; | ||||||
58 | class CoordinateSequenceFilter; | ||||||
59 | class GeometryComponentFilter; | ||||||
60 | class GeometryFactory; | ||||||
61 | class GeometryFilter; | ||||||
62 | class IntersectionMatrix; | ||||||
63 | class PrecisionModel; | ||||||
64 | class Point; | ||||||
65 | } | ||||||
66 | namespace io { // geos.io | ||||||
67 | class Unload; | ||||||
68 | } // namespace geos.io | ||||||
69 | } | ||||||
70 | |||||||
71 | namespace geos { | ||||||
72 | namespace geom { // geos::geom | ||||||
73 | |||||||
74 | /// Geometry types | ||||||
75 | enum GeometryTypeId { | ||||||
76 | /// a point | ||||||
77 | GEOS_POINT, | ||||||
78 | /// a linestring | ||||||
79 | GEOS_LINESTRING, | ||||||
80 | /// a linear ring (linestring with 1st point == last point) | ||||||
81 | GEOS_LINEARRING, | ||||||
82 | /// a polygon | ||||||
83 | GEOS_POLYGON, | ||||||
84 | /// a collection of points | ||||||
85 | GEOS_MULTIPOINT, | ||||||
86 | /// a collection of linestrings | ||||||
87 | GEOS_MULTILINESTRING, | ||||||
88 | /// a collection of polygons | ||||||
89 | GEOS_MULTIPOLYGON, | ||||||
90 | /// a collection of heterogeneus geometries | ||||||
91 | GEOS_GEOMETRYCOLLECTION | ||||||
92 | }; | ||||||
93 | |||||||
94 | /** | ||||||
95 | * \class Geometry geom.h geos.h | ||||||
96 | * | ||||||
97 | * \brief Basic implementation of Geometry, constructed and | ||||||
98 | * destructed by GeometryFactory. | ||||||
99 | * | ||||||
100 | * clone returns a deep copy of the object. |
||||||
101 | * Use GeometryFactory to construct. | ||||||
102 | * | ||||||
103 | * Binary Predicates |
||||||
104 | * Because it is not clear at this time | ||||||
105 | * what semantics for spatial | ||||||
106 | * analysis methods involving GeometryCollection s would be useful, |
||||||
107 | * GeometryCollection s are not supported as arguments to binary |
||||||
108 | * predicates (other than convexHull ) or the relate |
||||||
109 | * method. | ||||||
110 | * | ||||||
111 | * Set-Theoretic Methods |
||||||
112 | * | ||||||
113 | * The spatial analysis methods will | ||||||
114 | * return the most specific class possible to represent the result. If the | ||||||
115 | * result is homogeneous, a Point , LineString , or |
||||||
116 | * Polygon will be returned if the result contains a single |
||||||
117 | * element; otherwise, a MultiPoint , MultiLineString , |
||||||
118 | * or MultiPolygon will be returned. If the result is |
||||||
119 | * heterogeneous a GeometryCollection will be returned.
|
||||||
120 | * | ||||||
121 | * Because it is not clear at this time what semantics for set-theoretic | ||||||
122 | * methods involving GeometryCollection s would be useful, |
||||||
123 | * GeometryCollections |
||||||
124 | * are not supported as arguments to the set-theoretic methods. | ||||||
125 | * | ||||||
126 | * Representation of Computed Geometries |
||||||
127 | * | ||||||
128 | * The SFS states that the result | ||||||
129 | * of a set-theoretic method is the "point-set" result of the usual | ||||||
130 | * set-theoretic definition of the operation (SFS 3.2.21.1). However, there are | ||||||
131 | * sometimes many ways of representing a point set as a Geometry . |
||||||
132 | *
|
||||||
133 | * | ||||||
134 | * The SFS does not specify an unambiguous representation of a given point set | ||||||
135 | * returned from a spatial analysis method. One goal of JTS is to make this | ||||||
136 | * specification precise and unambiguous. JTS will use a canonical form for | ||||||
137 | * Geometry s returned from spatial analysis methods. The canonical |
||||||
138 | * form is a Geometry which is simple and noded: |
||||||
139 | * |
||||||
140 | * |
||||||
141 | * the JTS definition of isSimple . |
||||||
142 | * LineString s. It |
||||||
143 | * means that all intersection points on LineString s will be |
||||||
144 | * present as endpoints of LineString s in the result. |
||||||
145 | * | ||||||
146 | * This definition implies that non-simple geometries which are arguments to | ||||||
147 | * spatial analysis methods must be subjected to a line-dissolve process to | ||||||
148 | * ensure that the results are simple. | ||||||
149 | * | ||||||
150 | * Constructed Points And The Precision Model |
||||||
151 | * | ||||||
152 | * The results computed by the set-theoretic methods may | ||||||
153 | * contain constructed points which are not present in the input Geometry. | ||||||
154 | * These new points arise from intersections between line segments in the | ||||||
155 | * edges of the input Geometry. In the general case it is not | ||||||
156 | * possible to represent constructed points exactly. This is due to the fact | ||||||
157 | * that the coordinates of an intersection point may contain twice as many bits | ||||||
158 | * of precision as the coordinates of the input line segments. In order to | ||||||
159 | * represent these constructed points explicitly, JTS must truncate them to fit | ||||||
160 | * the PrecisionModel. | ||||||
161 | * | ||||||
162 | * Unfortunately, truncating coordinates moves them slightly. Line segments | ||||||
163 | * which would not be coincident in the exact result may become coincident in | ||||||
164 | * the truncated representation. This in turn leads to "topology collapses" -- | ||||||
165 | * situations where a computed element has a lower dimension than it would in | ||||||
166 | * the exact result. | ||||||
167 | * | ||||||
168 | * When JTS detects topology collapses during the computation of spatial | ||||||
169 | * analysis methods, it will throw an exception. If possible the exception will | ||||||
170 | * report the location of the collapse. | ||||||
171 | * | ||||||
172 | * equals(Object) and hashCode are not overridden, so that when two | ||||||
173 | * topologically equal Geometries are added to HashMaps and HashSets, they | ||||||
174 | * remain distinct. This behaviour is desired in many cases. | ||||||
175 | * | ||||||
176 | */ | ||||||
177 | class GEOS_DLL Geometry { | ||||||
178 | |||||||
179 | public: | ||||||
180 | |||||||
181 | friend class GeometryFactory; | ||||||
182 | |||||||
183 | /// A vector of const Geometry pointers | ||||||
184 | using ConstVect = std::vector |
||||||
185 | |||||||
186 | /// A vector of non-const Geometry pointers | ||||||
187 | using NonConstVect = std::vector |
||||||
188 | |||||||
189 | /// An unique_ptr of Geometry | ||||||
190 | using Ptr = std::unique_ptr |
||||||
191 | |||||||
192 | /// Make a deep-copy of this Geometry | ||||||
193 | virtual Geometry* clone() const=0; | ||||||
194 | |||||||
195 | /// Destroy Geometry and all components | ||||||
196 | virtual ~Geometry(); | ||||||
197 | |||||||
198 | |||||||
199 | /** | ||||||
200 | * \brief | ||||||
201 | * Gets the factory which contains the context in which this | ||||||
202 | * geometry was created. | ||||||
203 | * | ||||||
204 | * @return the factory for this geometry | ||||||
205 | */ | ||||||
206 | 2 | const GeometryFactory* getFactory() const { return _factory; } | |||||
207 | |||||||
208 | /** | ||||||
209 | * \brief | ||||||
210 | * A simple scheme for applications to add their own custom data to | ||||||
211 | * a Geometry. | ||||||
212 | * An example use might be to add an object representing a | ||||||
213 | * Coordinate Reference System. | ||||||
214 | * | ||||||
215 | * Note that user data objects are not present in geometries created | ||||||
216 | * by construction methods. | ||||||
217 | * | ||||||
218 | * @param newUserData an object, the semantics for which are | ||||||
219 | * defined by the application using this Geometry | ||||||
220 | */ | ||||||
221 | void setUserData(void* newUserData) { _userData=newUserData; } | ||||||
222 | |||||||
223 | /** | ||||||
224 | * \brief | ||||||
225 | * Gets the user data object for this geometry, if any. | ||||||
226 | * | ||||||
227 | * @return the user data object, or null if none set |
||||||
228 | */ | ||||||
229 | void* getUserData() const { return _userData; } | ||||||
230 | |||||||
231 | /* | ||||||
232 | * \brief | ||||||
233 | * Returns the ID of the Spatial Reference System used by the | ||||||
234 | * Geometry . |
||||||
235 | * | ||||||
236 | * GEOS supports Spatial Reference System information in the simple way | ||||||
237 | * defined in the SFS. A Spatial Reference System ID (SRID) is present | ||||||
238 | * in each Geometry object. Geometry |
||||||
239 | * provides basic accessor operations for this field, but no others. | ||||||
240 | * The SRID is represented as an integer. | ||||||
241 | * | ||||||
242 | * @return the ID of the coordinate space in which the | ||||||
243 | * Geometry is defined. |
||||||
244 | * | ||||||
245 | */ | ||||||
246 | virtual int getSRID() const { return SRID; } | ||||||
247 | |||||||
248 | /* | ||||||
249 | * Sets the ID of the Spatial Reference System used by the | ||||||
250 | * Geometry . |
||||||
251 | */ | ||||||
252 | virtual void setSRID(int newSRID) { SRID=newSRID; } | ||||||
253 | |||||||
254 | /** | ||||||
255 | * \brief | ||||||
256 | * Get the PrecisionModel used to create this Geometry. | ||||||
257 | */ | ||||||
258 | const PrecisionModel* getPrecisionModel() const; | ||||||
259 | |||||||
260 | /// \brief | ||||||
261 | /// Returns a vertex of this Geometry, | ||||||
262 | /// or NULL if this is the empty geometry | ||||||
263 | /// | ||||||
264 | virtual const Coordinate* getCoordinate() const=0; //Abstract | ||||||
265 | |||||||
266 | /** | ||||||
267 | * \brief | ||||||
268 | * Returns this Geometry vertices. | ||||||
269 | * Caller takes ownership of the returned object. | ||||||
270 | */ | ||||||
271 | virtual CoordinateSequence* getCoordinates() const=0; //Abstract | ||||||
272 | |||||||
273 | /// Returns the count of this Geometrys vertices. | ||||||
274 | virtual std::size_t getNumPoints() const=0; //Abstract | ||||||
275 | |||||||
276 | /// Returns false if the Geometry not simple. | ||||||
277 | virtual bool isSimple() const; | ||||||
278 | |||||||
279 | /// Return a string representation of this Geometry type | ||||||
280 | virtual std::string getGeometryType() const=0; //Abstract | ||||||
281 | |||||||
282 | /// Return an integer representation of this Geometry type | ||||||
283 | virtual GeometryTypeId getGeometryTypeId() const=0; //Abstract | ||||||
284 | |||||||
285 | /// Returns the number of geometries in this collection | ||||||
286 | /// (or 1 if this is not a collection) | ||||||
287 | virtual std::size_t getNumGeometries() const { return 1; } | ||||||
288 | |||||||
289 | /// Returns a pointer to the nth Geometry int this collection | ||||||
290 | /// (or self if this is not a collection) | ||||||
291 | virtual const Geometry* getGeometryN(std::size_t /*n*/) const { return this; } | ||||||
292 | |||||||
293 | /** | ||||||
294 | * \brief Tests the validity of this Geometry . |
||||||
295 | * | ||||||
296 | * Subclasses provide their own definition of "valid". | ||||||
297 | * | ||||||
298 | * @return true if this Geometry is valid |
||||||
299 | * | ||||||
300 | * @see IsValidOp | ||||||
301 | */ | ||||||
302 | virtual bool isValid() const; | ||||||
303 | |||||||
304 | /// Returns whether or not the set of points in this Geometry is empty. | ||||||
305 | virtual bool isEmpty() const=0; //Abstract | ||||||
306 | |||||||
307 | /// Polygon overrides to check for actual rectangle | ||||||
308 | virtual bool isRectangle() const { return false; } | ||||||
309 | |||||||
310 | /// Returns the dimension of this Geometry (0=point, 1=line, 2=surface) | ||||||
311 | virtual Dimension::DimensionType getDimension() const=0; //Abstract | ||||||
312 | |||||||
313 | /// Returns the coordinate dimension of this Geometry (2=XY, 3=XYZ, 4=XYZM in future). | ||||||
314 | virtual int getCoordinateDimension() const=0; //Abstract | ||||||
315 | |||||||
316 | /** | ||||||
317 | * \brief | ||||||
318 | * Returns the boundary, or an empty geometry of appropriate | ||||||
319 | * dimension if this Geometry is empty. |
||||||
320 | * | ||||||
321 | * (In the case of zero-dimensional geometries, | ||||||
322 | * an empty GeometryCollection is returned.) | ||||||
323 | * For a discussion of this function, see the OpenGIS Simple | ||||||
324 | * Features Specification. As stated in SFS Section 2.1.13.1, | ||||||
325 | * "the boundary of a Geometry is a set of Geometries of the | ||||||
326 | * next lower dimension." | ||||||
327 | * | ||||||
328 | * @return the closure of the combinatorial boundary | ||||||
329 | * of this Geometry . |
||||||
330 | * Ownershipof the returned object transferred to caller. | ||||||
331 | */ | ||||||
332 | virtual Geometry* getBoundary() const=0; //Abstract | ||||||
333 | |||||||
334 | /// Returns the dimension of this Geometrys inherent boundary. | ||||||
335 | virtual int getBoundaryDimension() const=0; //Abstract | ||||||
336 | |||||||
337 | /// Returns this Geometrys bounding box. | ||||||
338 | virtual Geometry* getEnvelope() const; | ||||||
339 | |||||||
340 | /** \brief | ||||||
341 | * Returns the minimum and maximum x and y values in this Geometry, | ||||||
342 | * or a null Envelope if this Geometry is empty. | ||||||
343 | */ | ||||||
344 | virtual const Envelope* getEnvelopeInternal() const; | ||||||
345 | |||||||
346 | /** | ||||||
347 | * Tests whether this geometry is disjoint from the specified geometry. | ||||||
348 | * | ||||||
349 | * The disjoint predicate has the following equivalent |
||||||
350 | * definitions: | ||||||
351 | * - The two geometries have no point in common | ||||||
352 | * - The DE-9IM Intersection Matrix for the two geometries matches | ||||||
353 | * [FF*FF****] |
||||||
354 | * - ! g.intersects(this) |
||||||
355 | * (disjoint is the inverse of intersects ) |
||||||
356 | * | ||||||
357 | * @param g the Geometry with which to compare this Geometry | ||||||
358 | * @return true if the two Geometry s are disjoint |
||||||
359 | * | ||||||
360 | * @see Geometry::intersects | ||||||
361 | */ | ||||||
362 | virtual bool disjoint(const Geometry *other) const; | ||||||
363 | |||||||
364 | /** \brief | ||||||
365 | * Returns true if the DE-9IM intersection matrix for the two | ||||||
366 | * Geometrys is FT*******, F**T***** or F***T****. | ||||||
367 | */ | ||||||
368 | virtual bool touches(const Geometry *other) const; | ||||||
369 | |||||||
370 | /// Returns true if disjoint returns false. | ||||||
371 | virtual bool intersects(const Geometry *g) const; | ||||||
372 | |||||||
373 | /** | ||||||
374 | * Tests whether this geometry crosses the specified geometry. | ||||||
375 | * | ||||||
376 | * The crosses predicate has the following equivalent |
||||||
377 | * definitions: | ||||||
378 | * - The geometries have some but not all interior points in common. | ||||||
379 | * - The DE-9IM Intersection Matrix for the two geometries matches | ||||||
380 | * - [T*T******] (for P/L, P/A, and L/A situations) |
||||||
381 | * - [T*****T**] (for L/P, A/P, and A/L situations) |
||||||
382 | * - [0********] (for L/L situations) |
||||||
383 | * For any other combination of dimensions this predicate returns | ||||||
384 | * false . |
||||||
385 | * | ||||||
386 | * The SFS defined this predicate only for P/L, P/A, L/L, and L/A | ||||||
387 | * situations. | ||||||
388 | * JTS extends the definition to apply to L/P, A/P and A/L situations | ||||||
389 | * as well, in order to make the relation symmetric. | ||||||
390 | * | ||||||
391 | * @param g the Geometry with which to compare this |
||||||
392 | * Geometry |
||||||
393 | *@return true if the two Geometry s cross. |
||||||
394 | */ | ||||||
395 | virtual bool crosses(const Geometry *g) const; | ||||||
396 | |||||||
397 | /** \brief | ||||||
398 | * Returns true if the DE-9IM intersection matrix for the two | ||||||
399 | * Geometrys is T*F**F***. | ||||||
400 | */ | ||||||
401 | virtual bool within(const Geometry *g) const; | ||||||
402 | |||||||
403 | /// Returns true if other.within(this) returns true. | ||||||
404 | virtual bool contains(const Geometry *g) const; | ||||||
405 | |||||||
406 | /** \brief | ||||||
407 | * Returns true if the DE-9IM intersection matrix for the two | ||||||
408 | * Geometrys is T*T***T** (for two points or two surfaces) | ||||||
409 | * 1*T***T** (for two curves). | ||||||
410 | */ | ||||||
411 | virtual bool overlaps(const Geometry *g) const; | ||||||
412 | |||||||
413 | /** | ||||||
414 | * \brief | ||||||
415 | * Returns true if the elements in the DE-9IM intersection matrix | ||||||
416 | * for the two Geometrys match the elements in intersectionPattern. | ||||||
417 | * | ||||||
418 | * IntersectionPattern elements may be: 0 1 2 T ( = 0, 1 or 2) | ||||||
419 | * F ( = -1) * ( = -1, 0, 1 or 2). | ||||||
420 | * | ||||||
421 | * For more information on the DE-9IM, see the OpenGIS Simple | ||||||
422 | * Features Specification. | ||||||
423 | * | ||||||
424 | * @throws util::IllegalArgumentException if either arg is a collection | ||||||
425 | * | ||||||
426 | */ | ||||||
427 | virtual bool relate(const Geometry *g, | ||||||
428 | const std::string& intersectionPattern) const; | ||||||
429 | |||||||
430 | bool relate(const Geometry& g, const std::string& intersectionPattern) const | ||||||
431 | { | ||||||
432 | return relate(&g, intersectionPattern); | ||||||
433 | } | ||||||
434 | |||||||
435 | /// Returns the DE-9IM intersection matrix for the two Geometrys. | ||||||
436 | virtual IntersectionMatrix* relate(const Geometry *g) const; | ||||||
437 | IntersectionMatrix* relate(const Geometry &g) const { | ||||||
438 | return relate(&g); | ||||||
439 | } | ||||||
440 | |||||||
441 | /** | ||||||
442 | * \brief | ||||||
443 | * Returns true if the DE-9IM intersection matrix for the two | ||||||
444 | * Geometrys is T*F**FFF*. | ||||||
445 | */ | ||||||
446 | virtual bool equals(const Geometry *g) const; | ||||||
447 | |||||||
448 | /** \brief | ||||||
449 | * Returns true if this geometry covers the |
||||||
450 | * specified geometry. | ||||||
451 | * | ||||||
452 | * The covers predicate has the following |
||||||
453 | * equivalent definitions: | ||||||
454 | * | ||||||
455 | * - Every point of the other geometry is a point of this geometry. | ||||||
456 | * - The DE-9IM Intersection Matrix for the two geometries is | ||||||
457 | * T*****FF* |
||||||
458 | * or *T****FF* |
||||||
459 | * or ***T**FF* |
||||||
460 | * or ****T*FF* |
||||||
461 | * - g.coveredBy(this) |
||||||
462 | * (covers is the inverse of coveredBy ) |
||||||
463 | * | ||||||
464 | * If either geometry is empty, the value of this predicate | ||||||
465 | * is false. | ||||||
466 | * | ||||||
467 | * This predicate is similar to {@link #contains}, | ||||||
468 | * but is more inclusive (i.e. returns true for more cases). | ||||||
469 | * In particular, unlike contains it does not distinguish |
||||||
470 | * between points in the boundary and in the interior of geometries. | ||||||
471 | * For most situations, covers should be used in |
||||||
472 | * preference to contains . |
||||||
473 | * As an added benefit, covers is more amenable to |
||||||
474 | * optimization, and hence should be more performant. | ||||||
475 | * | ||||||
476 | * @param g | ||||||
477 | * the Geometry with which to compare this |
||||||
478 | * Geometry |
||||||
479 | * | ||||||
480 | * @return true if this Geometry |
||||||
481 | * covers g |
||||||
482 | * | ||||||
483 | * @see Geometry::contains | ||||||
484 | * @see Geometry::coveredBy | ||||||
485 | */ | ||||||
486 | bool covers(const Geometry* g) const; | ||||||
487 | |||||||
488 | /** \brief | ||||||
489 | * Tests whether this geometry is covered by the | ||||||
490 | * specified geometry. | ||||||
491 | * | ||||||
492 | * The coveredBy predicate has the following |
||||||
493 | * equivalent definitions: | ||||||
494 | * | ||||||
495 | * - Every point of this geometry is a point of the other geometry. | ||||||
496 | * - The DE-9IM Intersection Matrix for the two geometries matches | ||||||
497 | * [T*F**F***] |
||||||
498 | * or [*TF**F***] |
||||||
499 | * or [**FT*F***] |
||||||
500 | * or [**F*TF***] |
||||||
501 | * - g.covers(this) |
||||||
502 | * (coveredBy is the converse of covers ) |
||||||
503 | * | ||||||
504 | * If either geometry is empty, the value of this predicate | ||||||
505 | * is false. | ||||||
506 | * | ||||||
507 | * This predicate is similar to {@link #within}, | ||||||
508 | * but is more inclusive (i.e. returns true for more cases). | ||||||
509 | * | ||||||
510 | * @param g the Geometry with which to compare |
||||||
511 | * this Geometry |
||||||
512 | * @return true if this Geometry |
||||||
513 | * is covered by g |
||||||
514 | * | ||||||
515 | * @see Geometry#within | ||||||
516 | * @see Geometry#covers | ||||||
517 | */ | ||||||
518 | bool coveredBy(const Geometry* g) const { | ||||||
519 | return g->covers(this); | ||||||
520 | } | ||||||
521 | |||||||
522 | |||||||
523 | /// Returns the Well-known Text representation of this Geometry. | ||||||
524 | virtual std::string toString() const; | ||||||
525 | |||||||
526 | virtual std::string toText() const; | ||||||
527 | |||||||
528 | /// Returns a buffer region around this Geometry having the given width. | ||||||
529 | // | ||||||
530 | /// @throws util::TopologyException if a robustness error occurs | ||||||
531 | /// | ||||||
532 | virtual Geometry* buffer(double distance) const; | ||||||
533 | |||||||
534 | /// \brief | ||||||
535 | /// Returns a buffer region around this Geometry having the | ||||||
536 | /// given width and with a specified number of segments used | ||||||
537 | /// to approximate curves. | ||||||
538 | // | ||||||
539 | /// @throws util::TopologyException if a robustness error occurs | ||||||
540 | /// | ||||||
541 | virtual Geometry* buffer(double distance,int quadrantSegments) const; | ||||||
542 | |||||||
543 | /** \brief | ||||||
544 | * Computes a buffer area around this geometry having the given | ||||||
545 | * width and with a specified accuracy of approximation for circular | ||||||
546 | * arcs, and using a specified end cap style. | ||||||
547 | * | ||||||
548 | * Buffer area boundaries can contain circular arcs. | ||||||
549 | * To represent these arcs using linear geometry they must be | ||||||
550 | * approximated with line segments. | ||||||
551 | * | ||||||
552 | * The quadrantSegments argument allows controlling the |
||||||
553 | * accuracy of the approximation by specifying the number of line | ||||||
554 | * segments used to represent a quadrant of a circle | ||||||
555 | * | ||||||
556 | * The end cap style specifies the buffer geometry that will be | ||||||
557 | * created at the ends of linestrings. The styles provided are: | ||||||
558 | * | ||||||
559 | * - BufferOp::CAP_ROUND - (default) a semi-circle | ||||||
560 | * - BufferOp::CAP_BUTT - a straight line perpendicular to the | ||||||
561 | * end segment | ||||||
562 | * - BufferOp::CAP_SQUARE - a half-square | ||||||
563 | * | ||||||
564 | * | ||||||
565 | * @param distance the width of the buffer | ||||||
566 | * (may be positive, negative or 0) | ||||||
567 | * | ||||||
568 | * @param quadrantSegments the number of line segments used | ||||||
569 | * to represent a quadrant of a circle | ||||||
570 | * | ||||||
571 | * @param endCapStyle the end cap style to use | ||||||
572 | * | ||||||
573 | * @return an area geometry representing the buffer region | ||||||
574 | * | ||||||
575 | * @throws util::TopologyException if a robustness error occurs | ||||||
576 | * | ||||||
577 | * @see BufferOp | ||||||
578 | */ | ||||||
579 | virtual Geometry* buffer(double distance, int quadrantSegments, | ||||||
580 | int endCapStyle) const; | ||||||
581 | |||||||
582 | /// \brief | ||||||
583 | /// Returns the smallest convex Polygon that contains | ||||||
584 | /// all the points in the Geometry. | ||||||
585 | virtual Geometry* convexHull() const; | ||||||
586 | |||||||
587 | /** | ||||||
588 | * Computes a new geometry which has all component coordinate sequences | ||||||
589 | * in reverse order (opposite orientation) to this one. | ||||||
590 | * | ||||||
591 | * @return a reversed geometry | ||||||
592 | */ | ||||||
593 | virtual Geometry* reverse() const=0; | ||||||
594 | |||||||
595 | /** \brief | ||||||
596 | * Returns a Geometry representing the points shared by | ||||||
597 | * this Geometry and other. | ||||||
598 | * | ||||||
599 | * @throws util::TopologyException if a robustness error occurs | ||||||
600 | * @throws util::IllegalArgumentException if either input is a | ||||||
601 | * non-empty GeometryCollection | ||||||
602 | * | ||||||
603 | */ | ||||||
604 | virtual Geometry* intersection(const Geometry *other) const; | ||||||
605 | |||||||
606 | /** \brief | ||||||
607 | * Returns a Geometry representing all the points in this Geometry | ||||||
608 | * and other. | ||||||
609 | * | ||||||
610 | * @throws util::TopologyException if a robustness error occurs | ||||||
611 | * @throws util::IllegalArgumentException if either input is a | ||||||
612 | * non-empty GeometryCollection | ||||||
613 | * | ||||||
614 | */ | ||||||
615 | Geometry* Union(const Geometry *other) const; | ||||||
616 | // throw(IllegalArgumentException *, TopologyException *); | ||||||
617 | |||||||
618 | /** | ||||||
619 | * Computes the union of all the elements of this geometry. Heterogeneous | ||||||
620 | * {@link GeometryCollection}s are fully supported. | ||||||
621 | * | ||||||
622 | * The result obeys the following contract: | ||||||
623 | * | ||||||
624 | * - Unioning a set of {@link LineString}s has the effect of fully noding | ||||||
625 | * and dissolving the linework. | ||||||
626 | * - Unioning a set of {@link Polygon}s will always | ||||||
627 | * return a {@link Polygonal} geometry (unlike {link #union(Geometry)}, | ||||||
628 | * which may return geometrys of lower dimension if a topology collapse | ||||||
629 | * occurred. | ||||||
630 | * | ||||||
631 | * @return the union geometry | ||||||
632 | * | ||||||
633 | * @see UnaryUnionOp | ||||||
634 | */ | ||||||
635 | Ptr Union() const; | ||||||
636 | // throw(IllegalArgumentException *, TopologyException *); | ||||||
637 | |||||||
638 | /** | ||||||
639 | * \brief | ||||||
640 | * Returns a Geometry representing the points making up this | ||||||
641 | * Geometry that do not make up other. | ||||||
642 | * | ||||||
643 | * @throws util::TopologyException if a robustness error occurs | ||||||
644 | * @throws util::IllegalArgumentException if either input is a | ||||||
645 | * non-empty GeometryCollection | ||||||
646 | * | ||||||
647 | */ | ||||||
648 | virtual Geometry* difference(const Geometry *other) const; | ||||||
649 | |||||||
650 | /** \brief | ||||||
651 | * Returns a set combining the points in this Geometry not in other, | ||||||
652 | * and the points in other not in this Geometry. | ||||||
653 | * | ||||||
654 | * @throws util::TopologyException if a robustness error occurs | ||||||
655 | * @throws util::IllegalArgumentException if either input is a | ||||||
656 | * non-empty GeometryCollection | ||||||
657 | * | ||||||
658 | */ | ||||||
659 | virtual Geometry* symDifference(const Geometry *other) const; | ||||||
660 | |||||||
661 | /** \brief | ||||||
662 | * Returns true iff the two Geometrys are of the same type and their | ||||||
663 | * vertices corresponding by index are equal up to a specified tolerance. | ||||||
664 | */ | ||||||
665 | virtual bool equalsExact(const Geometry *other, double tolerance=0) | ||||||
666 | const=0; //Abstract | ||||||
667 | |||||||
668 | virtual void apply_rw(const CoordinateFilter *filter)=0; //Abstract | ||||||
669 | virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract | ||||||
670 | virtual void apply_rw(GeometryFilter *filter); | ||||||
671 | virtual void apply_ro(GeometryFilter *filter) const; | ||||||
672 | virtual void apply_rw(GeometryComponentFilter *filter); | ||||||
673 | virtual void apply_ro(GeometryComponentFilter *filter) const; | ||||||
674 | |||||||
675 | /** | ||||||
676 | * Performs an operation on the coordinates in this Geometry's | ||||||
677 | * CoordinateSequences. | ||||||
678 | * If the filter reports that a coordinate value has been changed, | ||||||
679 | * {@link #geometryChanged} will be called automatically. | ||||||
680 | * | ||||||
681 | * @param filter the filter to apply | ||||||
682 | */ | ||||||
683 | virtual void apply_rw(CoordinateSequenceFilter& filter)=0; | ||||||
684 | |||||||
685 | /** | ||||||
686 | * Performs a read-only operation on the coordinates in this | ||||||
687 | * Geometry's CoordinateSequences. | ||||||
688 | * | ||||||
689 | * @param filter the filter to apply | ||||||
690 | */ | ||||||
691 | virtual void apply_ro(CoordinateSequenceFilter& filter) const=0; | ||||||
692 | |||||||
693 | /** \brief | ||||||
694 | * Apply a fiter to each component of this geometry. | ||||||
695 | * The filter is expected to provide a .filter(const Geometry*) | ||||||
696 | * method. | ||||||
697 | * | ||||||
698 | * I intend similar templated methods to replace | ||||||
699 | * all the virtual apply_rw and apply_ro functions... | ||||||
700 | * --strk(2005-02-06); | ||||||
701 | */ | ||||||
702 | template |
||||||
703 | void applyComponentFilter(T& f) const | ||||||
704 | { | ||||||
705 | for(std::size_t i=0, n=getNumGeometries(); i | ||||||
706 | f.filter(getGeometryN(i)); | ||||||
707 | } | ||||||
708 | |||||||
709 | /// Converts this Geometry to normal form (or canonical form). | ||||||
710 | virtual void normalize()=0; //Abstract | ||||||
711 | |||||||
712 | virtual int compareTo(const Geometry *geom) const; | ||||||
713 | |||||||
714 | /** \brief | ||||||
715 | * Returns the minimum distance between this Geometry | ||||||
716 | * and the Geometry g | ||||||
717 | */ | ||||||
718 | virtual double distance(const Geometry *g) const; | ||||||
719 | |||||||
720 | /// Returns the area of this Geometry. | ||||||
721 | virtual double getArea() const; | ||||||
722 | |||||||
723 | /// Returns the length of this Geometry. | ||||||
724 | virtual double getLength() const; | ||||||
725 | |||||||
726 | /** \brief | ||||||
727 | * Tests whether the distance from this Geometry to another | ||||||
728 | * is less than or equal to a specified value. | ||||||
729 | * | ||||||
730 | * @param geom the Geometry to check the distance to | ||||||
731 | * @param cDistance the distance value to compare | ||||||
732 | * @return true if the geometries are less than |
||||||
733 | * distance apart. |
||||||
734 | * | ||||||
735 | * @todo doesn't seem to need being virtual, make it concrete | ||||||
736 | */ | ||||||
737 | virtual bool isWithinDistance(const Geometry *geom, | ||||||
738 | double cDistance) const; | ||||||
739 | |||||||
740 | /** \brief | ||||||
741 | * Computes the centroid of this Geometry . |
||||||
742 | * | ||||||
743 | * The centroid is equal to the centroid of the set of component | ||||||
744 | * Geometries of highest dimension (since the lower-dimension geometries | ||||||
745 | * contribute zero "weight" to the centroid) | ||||||
746 | * | ||||||
747 | * @return a {@link Point} which is the centroid of this Geometry | ||||||
748 | */ | ||||||
749 | virtual Point* getCentroid() const; | ||||||
750 | |||||||
751 | /// Computes the centroid of this Geometry as a Coordinate | ||||||
752 | // | ||||||
753 | /// Returns false if centroid cannot be computed (EMPTY geometry) | ||||||
754 | /// | ||||||
755 | virtual bool getCentroid(Coordinate& ret) const; | ||||||
756 | |||||||
757 | /** \brief | ||||||
758 | * Computes an interior point of this Geometry . |
||||||
759 | * | ||||||
760 | * An interior point is guaranteed to lie in the interior of the Geometry, | ||||||
761 | * if it possible to calculate such a point exactly. Otherwise, | ||||||
762 | * the point may lie on the boundary of the geometry. | ||||||
763 | * | ||||||
764 | * @return a Point which is in the interior of this Geometry, or | ||||||
765 | * null if the geometry doesn't have an interior (empty) | ||||||
766 | */ | ||||||
767 | virtual Point* getInteriorPoint() const; | ||||||
768 | |||||||
769 | /* | ||||||
770 | * \brief | ||||||
771 | * Notifies this Geometry that its Coordinates have been changed | ||||||
772 | * by an external party (using a CoordinateFilter, for example). | ||||||
773 | */ | ||||||
774 | virtual void geometryChanged(); | ||||||
775 | |||||||
776 | /** | ||||||
777 | * \brief | ||||||
778 | * Notifies this Geometry that its Coordinates have been changed | ||||||
779 | * by an external party. | ||||||
780 | */ | ||||||
781 | void geometryChangedAction(); | ||||||
782 | |||||||
783 | protected: | ||||||
784 | |||||||
785 | /// The bounding box of this Geometry | ||||||
786 | mutable std::unique_ptr |
||||||
787 | |||||||
788 | /// Returns true if the array contains any non-empty Geometrys. | ||||||
789 | static bool hasNonEmptyElements(const std::vector |
||||||
790 | |||||||
791 | /// Returns true if the CoordinateSequence contains any null elements. | ||||||
792 | static bool hasNullElements(const CoordinateSequence* list); | ||||||
793 | |||||||
794 | /// Returns true if the vector contains any null elements. | ||||||
795 | static bool hasNullElements(const std::vector |
||||||
796 | |||||||
797 | // static void reversePointOrder(CoordinateSequence* coordinates); | ||||||
798 | // static Coordinate& minCoordinate(CoordinateSequence* coordinates); | ||||||
799 | // static void scroll(CoordinateSequence* coordinates,Coordinate* firstCoordinate); | ||||||
800 | // static int indexOf(Coordinate* coordinate,CoordinateSequence* coordinates); | ||||||
801 | // | ||||||
802 | /** \brief | ||||||
803 | * Returns whether the two Geometrys are equal, from the point | ||||||
804 | * of view of the equalsExact method. | ||||||
805 | */ | ||||||
806 | virtual bool isEquivalentClass(const Geometry *other) const; | ||||||
807 | |||||||
808 | static void checkNotGeometryCollection(const Geometry *g); | ||||||
809 | // throw(IllegalArgumentException *); | ||||||
810 | |||||||
811 | //virtual void checkEqualSRID(Geometry *other); | ||||||
812 | |||||||
813 | //virtual void checkEqualPrecisionModel(Geometry *other); | ||||||
814 | |||||||
815 | virtual Envelope::Ptr computeEnvelopeInternal() const=0; //Abstract | ||||||
816 | |||||||
817 | virtual int compareToSameClass(const Geometry *geom) const=0; //Abstract | ||||||
818 | |||||||
819 | int compare(std::vector |
||||||
820 | |||||||
821 | int compare(std::vector |
||||||
822 | |||||||
823 | bool equal(const Coordinate& a, const Coordinate& b, | ||||||
824 | double tolerance) const; | ||||||
825 | int SRID; | ||||||
826 | |||||||
827 | /// @deprecated | ||||||
828 | //Geometry* toInternalGeometry(const Geometry *g) const; | ||||||
829 | |||||||
830 | /// @deprecated | ||||||
831 | //Geometry* fromInternalGeometry(const Geometry *g) const; | ||||||
832 | |||||||
833 | /// Polygon overrides to check for actual rectangle | ||||||
834 | //virtual bool isRectangle() const { return false; } -- moved to public | ||||||
835 | |||||||
836 | Geometry(const Geometry &geom); | ||||||
837 | |||||||
838 | /** \brief | ||||||
839 | * Construct a geometry with the given GeometryFactory. | ||||||
840 | * | ||||||
841 | * Will keep a reference to the factory, so don't | ||||||
842 | * delete it until al Geometry objects referring to | ||||||
843 | * it are deleted. | ||||||
844 | * | ||||||
845 | * @param factory | ||||||
846 | */ | ||||||
847 | Geometry(const GeometryFactory *factory); | ||||||
848 | |||||||
849 | private: | ||||||
850 | |||||||
851 | int getClassSortIndex() const; | ||||||
852 | |||||||
853 | class GEOS_DLL GeometryChangedFilter : public GeometryComponentFilter | ||||||
854 | { | ||||||
855 | public: | ||||||
856 | void filter_rw(Geometry* geom) override; | ||||||
857 | }; | ||||||
858 | |||||||
859 | static GeometryChangedFilter geometryChangedFilter; | ||||||
860 | |||||||
861 | /// The GeometryFactory used to create this Geometry | ||||||
862 | // | ||||||
863 | /// Externally owned | ||||||
864 | /// | ||||||
865 | const GeometryFactory* _factory; | ||||||
866 | |||||||
867 | void* _userData; | ||||||
868 | }; | ||||||
869 | |||||||
870 | /// \brief | ||||||
871 | /// Write the Well-known Binary representation of this Geometry | ||||||
872 | /// as an HEX string to the given output stream | ||||||
873 | /// | ||||||
874 | GEOS_DLL std::ostream& operator<< (std::ostream& os, const Geometry& geom); | ||||||
875 | |||||||
876 | struct GEOS_DLL GeometryGreaterThen { | ||||||
877 | bool operator()(const Geometry *first, const Geometry *second); | ||||||
878 | }; | ||||||
879 | |||||||
880 | |||||||
881 | /// Return current GEOS version | ||||||
882 | std::string geosversion(); | ||||||
883 | |||||||
884 | /** | ||||||
885 | * \brief | ||||||
886 | * Return the version of JTS this GEOS | ||||||
887 | * release has been ported from. | ||||||
888 | */ | ||||||
889 | std::string jtsport(); | ||||||
890 | |||||||
891 | // We use this instead of std::pair |
||||||
892 | // forbids that construct: | ||||||
893 | // http://lwg.github.com/issues/lwg-closed.html#2068 | ||||||
894 | struct GeomPtrPair { | ||||||
895 | typedef std::unique_ptr |
||||||
896 | GeomPtr first; | ||||||
897 | GeomPtr second; | ||||||
898 | }; | ||||||
899 | |||||||
900 | } // namespace geos::geom | ||||||
901 | } // namespace geos | ||||||
902 | |||||||
903 | #ifdef _MSC_VER | ||||||
904 | #pragma warning(pop) | ||||||
905 | #endif | ||||||
906 | |||||||
907 | #endif // ndef GEOS_GEOM_GEOMETRY_H |