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/inline.h>
36 #include <geos/geom/Envelope.h>
37 #include <geos/geom/Dimension.h>
38 #include <geos/geom/GeometryComponentFilter.h>
39 #include <geos/geom/IntersectionMatrix.h>
49 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
50 #pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list
57 class CoordinateFilter;
58 class CoordinateSequence;
59 class CoordinateSequenceFilter;
60 class GeometryComponentFilter;
61 class GeometryFactory;
94 enum GeometrySortIndex {
96 SORTINDEX_MULTIPOINT = 1,
97 SORTINDEX_LINESTRING = 2,
98 SORTINDEX_LINEARRING = 3,
99 SORTINDEX_MULTILINESTRING = 4,
100 SORTINDEX_POLYGON = 5,
101 SORTINDEX_MULTIPOLYGON = 6,
102 SORTINDEX_GEOMETRYCOLLECTION = 7
201 using Ptr = std::unique_ptr<Geometry> ;
204 virtual std::unique_ptr<Geometry>
clone()
const = 0;
239 _userData = newUserData;
349 return d == getDimension();
352 bool isPuntal()
const {
356 bool isLineal()
const {
360 bool isPolygonal()
const {
364 bool isCollection()
const {
365 int t = getGeometryTypeId();
487 const std::string& intersectionPattern)
const;
490 relate(
const Geometry& g,
const std::string& intersectionPattern)
const
492 return relate(&g, intersectionPattern);
498 std::unique_ptr<IntersectionMatrix> relate(
const Geometry& g)
const
590 virtual std::string toText()
const;
596 std::unique_ptr<Geometry>
buffer(
double distance)
const;
605 std::unique_ptr<Geometry>
buffer(
double distance,
int quadrantSegments)
const;
643 std::unique_ptr<Geometry>
buffer(
double distance,
int quadrantSegments,
644 int endCapStyle)
const;
657 virtual std::unique_ptr<Geometry>
reverse()
const = 0;
770 for(std::size_t i = 0, n = getNumGeometries(); i < n; ++i) {
771 f.filter(getGeometryN(i));
809 double cDistance)
const;
862 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) { return !g->isEmpty(); });
871 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) { return g == nullptr; });
885 static void checkNotGeometryCollection(
const Geometry* g);
892 virtual Envelope::Ptr computeEnvelopeInternal()
const = 0;
894 virtual int compareToSameClass(
const Geometry* geom)
const = 0;
896 int compare(std::vector<Coordinate> a, std::vector<Coordinate> b)
const;
898 int compare(std::vector<Geometry*> a, std::vector<Geometry*> b)
const;
900 int compare(
const std::vector<std::unique_ptr<Geometry>> & a,
const std::vector<std::unique_ptr<Geometry>> & b)
const;
903 double tolerance)
const;
920 static std::vector<std::unique_ptr<Geometry>> toGeometryArray(std::vector<std::unique_ptr<T>> && v) {
921 static_assert(std::is_base_of<Geometry, T>::value,
"");
922 std::vector<std::unique_ptr<Geometry>> gv(v.size());
923 for (
size_t i = 0; i < v.size(); i++) {
924 gv[i] = std::move(v[i]);
931 virtual int getSortIndex()
const = 0;
936 class GEOS_DLL GeometryChangedFilter :
public GeometryComponentFilter {
938 void filter_rw(Geometry* geom)
override;
941 static GeometryChangedFilter geometryChangedFilter;
947 const GeometryFactory* _factory;
958 struct GEOS_DLL GeometryGreaterThen {
977 typedef std::unique_ptr<Geometry> GeomPtr;
989 #endif // ndef GEOS_GEOM_GEOMETRY_H
std::vector< const Geometry * > ConstVect
A vector of const Geometry pointers.
Definition: Geometry.h:195
virtual void apply_rw(CoordinateSequenceFilter &filter)=0
virtual bool isSimple() const
Returns false if the Geometry not simple.
std::unique_ptr< Geometry > buffer(double distance) const
virtual bool contains(const Geometry *g) const
Returns true if other.within(this) returns true.
std::unique_ptr< Envelope > envelope
The bounding box of this Geometry.
Definition: Geometry.h:857
std::unique_ptr< Point > getInteriorPoint() const
Computes an interior point of this Geometry.
virtual const Envelope * getEnvelopeInternal() const
Returns the minimum and maximum x and y values in this Geometry, or a null Envelope if this Geometry ...
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
static bool hasNullElements(const std::vector< T > *geometries)
Returns true if the vector contains any null elements.
Definition: Geometry.h:870
virtual Dimension::DimensionType getDimension() const =0
Returns the dimension of this Geometry (0=point, 1=line, 2=surface)
@ A
Dimension value of a surface (2).
Definition: Dimension.h:48
virtual bool isEquivalentClass(const Geometry *other) const
Returns whether the two Geometrys are equal, from the point of view of the equalsExact method.
virtual double getLength() const
Returns the length of this Geometry.
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
std::unique_ptr< Geometry > buffer(double distance, int quadrantSegments, int endCapStyle) const
Computes a buffer area around this geometry having the given width and with a specified accuracy of a...
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
virtual const Coordinate * getCoordinate() const =0
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
Definition: GeometryComponentFilter.h:43
virtual bool isEmpty() const =0
Returns whether or not the set of points in this Geometry is empty.
virtual bool intersects(const Geometry *g) const
Returns true if disjoint returns false.
static bool hasNullElements(const CoordinateSequence *list)
Returns true if the CoordinateSequence contains any null elements.
@ 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:201
virtual std::size_t getNumGeometries() const
Definition: Geometry.h:310
virtual bool isDimensionStrict(Dimension::DimensionType d) const
Checks whether this Geometry consists only of components having dimension d.
Definition: Geometry.h:348
std::unique_ptr< IntersectionMatrix > relate(const Geometry *g) const
Returns the DE-9IM intersection matrix for the two Geometrys.
virtual const Geometry * getGeometryN(std::size_t) const
Returns a pointer to the nth Geometry in this collection (or self if this is not a collection)
Definition: Geometry.h:318
@ GEOS_MULTIPOLYGON
a collection of polygons
Definition: Geometry.h:89
virtual bool isWithinDistance(const Geometry *geom, double cDistance) const
Tests whether the distance from this Geometry to another is less than or equal to a specified value.
virtual void setSRID(int newSRID)
Sets the ID of the Spatial Reference System used by the Geometry.
Definition: Geometry.h:274
std::unique_ptr< Geometry > intersection(const Geometry *other) const
Returns a Geometry representing the points shared by this Geometry and other.
virtual std::unique_ptr< Geometry > getBoundary() const =0
Returns the boundary, or an empty geometry of appropriate dimension if this Geometry is empty.
@ 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:339
virtual bool touches(const Geometry *other) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is FT*******,...
DimensionType
Definition: Dimension.h:31
virtual bool getCentroid(Coordinate &ret) const
Computes the centroid of this Geometry as a Coordinate.
virtual double getArea() const
Returns the area of this Geometry.
virtual std::string toString() const
Returns the Well-known Text representation of this Geometry.
virtual bool within(const Geometry *g) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is T*F**F***.
virtual bool crosses(const Geometry *g) const
@ GEOS_POINT
a point
Definition: Geometry.h:77
static bool hasNonEmptyElements(const std::vector< T > *geometries)
Returns true if the array contains any non-empty Geometrys.
Definition: Geometry.h:861
virtual bool equals(const Geometry *g) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is T*F**FFF*.
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
void applyComponentFilter(T &f) const
Apply a filter to each component of this geometry. The filter is expected to provide a ....
Definition: Geometry.h:768
Geometry(const GeometryFactory *factory)
Construct a geometry with the given GeometryFactory.
void geometryChangedAction()
Notifies this Geometry that its Coordinates have been changed by an external party.
bool coveredBy(const Geometry *g) const
Tests whether this geometry is covered by the specified geometry.
Definition: Geometry.h:581
@ L
Dimension value of a curve (1).
Definition: Dimension.h:45
const PrecisionModel * getPrecisionModel() const
Get the PrecisionModel used to create this Geometry.
@ GEOS_GEOMETRYCOLLECTION
a collection of heterogeneus geometries
Definition: Geometry.h:91
virtual uint8_t getCoordinateDimension() const =0
Returns the coordinate dimension of this Geometry (2=XY, 3=XYZ, 4=XYZM in future).
std::unique_ptr< Geometry > buffer(double distance, int quadrantSegments) const
Returns a buffer region around this Geometry having the given width and with a specified number of se...
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
virtual void normalize()=0
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
virtual bool disjoint(const Geometry *other) const
virtual std::unique_ptr< CoordinateSequence > getCoordinates() const =0
Returns this Geometry vertices. Caller takes ownership of the returned object.
@ GEOS_MULTILINESTRING
a collection of linestrings
Definition: Geometry.h:87
virtual GeometryTypeId getGeometryTypeId() const =0
Return an integer representation of this Geometry type.
std::unique_ptr< Geometry > difference(const Geometry *other) const
Returns a Geometry representing the points making up this Geometry that do not make up other.
virtual std::unique_ptr< Geometry > convexHull() const
Returns the smallest convex Polygon that contains all the points in the Geometry.
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition: Geometry.h:218
virtual std::unique_ptr< Geometry > getEnvelope() const
Returns this Geometrys bounding box.
virtual double distance(const Geometry *g) const
Returns the minimum distance between this Geometry and the Geometry g.
virtual int getBoundaryDimension() const =0
Returns the dimension of this Geometrys inherent boundary.
virtual int compareTo(const Geometry *geom) const
Comparator for sorting geometry.
virtual bool equalsExact(const Geometry *other, double tolerance=0) const =0
Returns true iff the two Geometrys are of the same type and their vertices corresponding by index are...
virtual bool overlaps(const Geometry *g) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is T*T***T** (for two points or ...
@ P
Dimension value of a point (0).
Definition: Dimension.h:42
virtual std::unique_ptr< Geometry > reverse() const =0
Computes a new geometry which has all component coordinate sequences in reverse order (opposite orien...
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
std::unique_ptr< Geometry > symDifference(const Geometry *other) const
Returns a set combining the points in this Geometry not in other, and the points in other not in this...
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
virtual std::size_t getNumPoints() const =0
Returns the count of this Geometrys vertices.
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
virtual int getSRID() const
Returns the ID of the Spatial Reference System used by the Geometry.
Definition: Geometry.h:265
void * getUserData() const
Gets the user data object for this geometry, if any.
Definition: Geometry.h:249
virtual std::unique_ptr< Point > getCentroid() const
Computes the centroid of this Geometry.
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:237
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
virtual void apply_ro(CoordinateSequenceFilter &filter) const =0
bool covers(const Geometry *g) const
Returns true if this geometry covers the specified geometry.
std::unique_ptr< Geometry > Union(const Geometry *other) const
Returns a Geometry representing all the points in this Geometry and other.
@ GEOS_MULTIPOINT
a collection of points
Definition: Geometry.h:85
std::string geosversion()
Return current GEOS version.
std::vector< Geometry * > NonConstVect
A vector of non-const Geometry pointers.
Definition: Geometry.h:198
virtual std::unique_ptr< Geometry > clone() const =0
Make a deep-copy of this Geometry.
Ptr Union() const
Computes the union of all the elements of this geometry. Heterogeneous GeometryCollections are fully ...
virtual void geometryChanged()
Notifies this Geometry that its Coordinates have been changed by an external party (using a Coordinat...
virtual ~Geometry()
Destroy Geometry and all components.
virtual bool isValid() const
Tests the validity of this Geometry.
virtual std::string getGeometryType() const =0
Return a string representation of this Geometry type.
std::string jtsport()
Return the version of JTS this GEOS release has been ported from.
bool relate(const Geometry *g, const std::string &intersectionPattern) const
Returns true if the elements in the DE-9IM intersection matrix for the two Geometrys match the elemen...