21 #ifndef GEOS_GEOM_GEOMETRY_H
22 #define GEOS_GEOM_GEOMETRY_H
24 #ifndef USE_UNSTABLE_GEOS_CPP_API
26 # warning "The GEOS C++ API is unstable, please use the C API instead"
27 # warning "HINT: #include geos_c.h"
29 #pragma message("The GEOS C++ API is unstable, please use the C API instead")
30 #pragma message("HINT: #include geos_c.h")
34 #include <geos/export.h>
35 #include <geos/platform.h>
36 #include <geos/inline.h>
37 #include <geos/geom/Envelope.h>
38 #include <geos/geom/Dimension.h>
39 #include <geos/geom/GeometryComponentFilter.h>
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
56 class CoordinateFilter;
57 class CoordinateSequence;
58 class CoordinateSequenceFilter;
59 class GeometryComponentFilter;
60 class GeometryFactory;
62 class IntersectionMatrix;
190 using Ptr = std::unique_ptr<Geometry> ;
246 virtual int getSRID()
const {
return SRID; }
252 virtual void setSRID(
int newSRID) { SRID=newSRID; }
258 const PrecisionModel* getPrecisionModel()
const;
264 virtual const Coordinate* getCoordinate()
const=0;
271 virtual CoordinateSequence* getCoordinates()
const=0;
274 virtual std::size_t getNumPoints()
const=0;
277 virtual bool isSimple()
const;
280 virtual std::string getGeometryType()
const=0;
302 virtual bool isValid()
const;
305 virtual bool isEmpty()
const=0;
314 virtual int getCoordinateDimension()
const=0;
332 virtual Geometry* getBoundary()
const=0;
335 virtual int getBoundaryDimension()
const=0;
338 virtual Geometry* getEnvelope()
const;
344 virtual const Envelope* getEnvelopeInternal()
const;
362 virtual bool disjoint(
const Geometry *other)
const;
368 virtual bool touches(
const Geometry *other)
const;
371 virtual bool intersects(
const Geometry *g)
const;
395 virtual bool crosses(
const Geometry *g)
const;
401 virtual bool within(
const Geometry *g)
const;
404 virtual bool contains(
const Geometry *g)
const;
411 virtual bool overlaps(
const Geometry *g)
const;
427 virtual bool relate(
const Geometry *g,
428 const std::string& intersectionPattern)
const;
430 bool relate(
const Geometry& g,
const std::string& intersectionPattern)
const
432 return relate(&g, intersectionPattern);
436 virtual IntersectionMatrix* relate(
const Geometry *g)
const;
437 IntersectionMatrix* relate(
const Geometry &g)
const {
446 virtual bool equals(
const Geometry *g)
const;
486 bool covers(
const Geometry* g)
const;
524 virtual std::string toString()
const;
526 virtual std::string toText()
const;
532 virtual Geometry* buffer(
double distance)
const;
541 virtual Geometry* buffer(
double distance,
int quadrantSegments)
const;
579 virtual Geometry* buffer(
double distance,
int quadrantSegments,
580 int endCapStyle)
const;
585 virtual Geometry* convexHull()
const;
593 virtual Geometry* reverse()
const=0;
665 virtual bool equalsExact(
const Geometry *other,
double tolerance=0)
705 for(std::size_t i=0, n=getNumGeometries(); i<n; ++i)
706 f.filter(getGeometryN(i));
710 virtual void normalize()=0;
712 virtual int compareTo(
const Geometry *geom)
const;
718 virtual double distance(
const Geometry *g)
const;
721 virtual double getArea()
const;
724 virtual double getLength()
const;
737 virtual bool isWithinDistance(
const Geometry *geom,
738 double cDistance)
const;
749 virtual Point* getCentroid()
const;
755 virtual bool getCentroid(
Coordinate& ret)
const;
767 virtual Point* getInteriorPoint()
const;
774 virtual void geometryChanged();
781 void geometryChangedAction();
789 static bool hasNonEmptyElements(
const std::vector<Geometry *>* geometries);
795 static bool hasNullElements(
const std::vector<Geometry *>* lrs);
806 virtual bool isEquivalentClass(
const Geometry *other)
const;
808 static void checkNotGeometryCollection(
const Geometry *g);
815 virtual Envelope::Ptr computeEnvelopeInternal()
const=0;
817 virtual int compareToSameClass(
const Geometry *geom)
const=0;
819 int compare(std::vector<Coordinate> a, std::vector<Coordinate> b)
const;
821 int compare(std::vector<Geometry *> a, std::vector<Geometry *> b)
const;
824 double tolerance)
const;
851 int getClassSortIndex()
const;
856 void filter_rw(
Geometry* geom)
override;
859 static GeometryChangedFilter geometryChangedFilter;
874 GEOS_DLL std::ostream&
operator<< (std::ostream& os,
const Geometry& geom);
876 struct GEOS_DLL GeometryGreaterThen {
877 bool operator()(
const Geometry *first,
const Geometry *second);
895 typedef std::unique_ptr<Geometry> GeomPtr;
907 #endif // ndef GEOS_GEOM_GEOMETRY_H
std::vector< const Geometry * > ConstVect
A vector of const Geometry pointers.
Definition: Geometry.h:184
std::unique_ptr< Envelope > envelope
The bounding box of this Geometry.
Definition: Geometry.h:786
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Definition: GeometryComponentFilter.h:43
@ GEOS_POLYGON
a polygon
Definition: Geometry.h:83
@ GEOS_LINESTRING
a linestring
Definition: Geometry.h:79
std::unique_ptr< Geometry > Ptr
An unique_ptr of Geometry.
Definition: Geometry.h:190
virtual std::size_t getNumGeometries() const
Definition: Geometry.h:287
virtual const Geometry * getGeometryN(std::size_t) const
Definition: Geometry.h:291
@ GEOS_MULTIPOLYGON
a collection of polygons
Definition: Geometry.h:89
@ GEOS_LINEARRING
a linear ring (linestring with 1st point == last point)
Definition: Geometry.h:81
virtual bool isRectangle() const
Polygon overrides to check for actual rectangle.
Definition: Geometry.h:308
DimensionType
Definition: Dimension.h:67
@ GEOS_POINT
a point
Definition: Geometry.h:77
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:84
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:177
void applyComponentFilter(T &f) const
Apply a fiter to each component of this geometry. The filter is expected to provide a ....
Definition: Geometry.h:703
bool coveredBy(const Geometry *g) const
Tests whether this geometry is covered by the specified geometry.
Definition: Geometry.h:518
@ GEOS_GEOMETRYCOLLECTION
a collection of heterogeneus geometries
Definition: Geometry.h:91
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
Definition: CoordinateSequenceFilter.h:58
@ GEOS_MULTILINESTRING
a collection of linestrings
Definition: Geometry.h:87
std::vector< Geometry * > NonConstVect
A vector of non-const Geometry pointers.
Definition: Geometry.h:187
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition: Geometry.h:206
GEOS_DLL std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:91
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
Definition: CoordinateFilter.h:67
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
void * getUserData() const
Gets the user data object for this geometry, if any.
Definition: Geometry.h:229
void setUserData(void *newUserData)
A simple scheme for applications to add their own custom data to a Geometry. An example use might be ...
Definition: Geometry.h:221
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:48
bool covers(const Geometry *g) const
Returns true if this geometry covers the specified geometry.
@ GEOS_MULTIPOINT
a collection of points
Definition: Geometry.h:85
std::string geosversion()
Return current GEOS version.
std::string jtsport()
Return the version of JTS this GEOS release has been ported from.