23#ifndef USE_UNSTABLE_GEOS_CPP_API
25# warning "The GEOS C++ API is unstable, please use the C API instead"
26# warning "HINT: #include geos_c.h"
28#pragma message("The GEOS C++ API is unstable, please use the C API instead")
29#pragma message("HINT: #include geos_c.h")
33#include <geos/export.h>
34#include <geos/geom/Envelope.h>
35#include <geos/geom/Dimension.h>
36#include <geos/geom/GeometryComponentFilter.h>
37#include <geos/geom/CoordinateSequence.h>
47#pragma warning(disable: 4251)
48#pragma warning(disable: 4355)
55class CoordinateFilter;
56class CoordinateSequence;
57class CoordinateSequenceFilter;
58class GeometryComponentFilter;
63class IntersectionMatrix;
98enum GeometrySortIndex {
100 SORTINDEX_MULTIPOINT = 1,
101 SORTINDEX_LINESTRING = 2,
102 SORTINDEX_LINEARRING = 3,
103 SORTINDEX_MULTILINESTRING = 4,
104 SORTINDEX_POLYGON = 5,
105 SORTINDEX_MULTIPOLYGON = 6,
106 SORTINDEX_GEOMETRYCOLLECTION = 7,
107 SORTINDEX_CIRCULARSTRING = 8,
108 SORTINDEX_COMPOUNDCURVE = 9,
109 SORTINDEX_CURVEPOLYGON = 10,
110 SORTINDEX_MULTICURVE = 11,
111 SORTINDEX_MULTISURFACE = 12,
210 using Ptr = std::unique_ptr<Geometry> ;
213 std::unique_ptr<Geometry>
clone()
const {
return std::unique_ptr<Geometry>(cloneImpl()); }
248 _userData = newUserData;
365 return getDimension() == d;
370 return d == getDimension();
373 bool isPuntal()
const {
374 return isDimensionStrict(Dimension::P);
377 bool isLineal()
const {
378 return isDimensionStrict(Dimension::L);
381 bool isPolygonal()
const {
382 return isDimensionStrict(Dimension::A);
385 bool isMixedDimension()
const;
386 bool isMixedDimension(Dimension::DimensionType* baseDim)
const;
388 bool isCollection()
const {
389 int t = getGeometryTypeId();
401 default:
return typeId;
408 virtual bool hasZ()
const = 0;
410 virtual bool hasM()
const = 0;
524 const std::string& intersectionPattern)
const;
527 relate(
const Geometry& g,
const std::string& intersectionPattern)
const
529 return relate(&g, intersectionPattern);
535 std::unique_ptr<IntersectionMatrix> relate(
const Geometry& g)
const;
620 virtual std::string toText()
const;
626 std::unique_ptr<Geometry>
buffer(
double distance)
const;
635 std::unique_ptr<Geometry>
buffer(
double distance,
int quadrantSegments)
const;
673 std::unique_ptr<Geometry>
buffer(
double distance,
int quadrantSegments,
674 int endCapStyle)
const;
687 std::unique_ptr<Geometry>
reverse()
const {
return std::unique_ptr<Geometry>(reverseImpl()); }
808 for(std::size_t i = 0, n = getNumGeometries(); i < n; ++i) {
809 f.filter(getGeometryN(i));
849 double cDistance)
const;
904 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) { return !g->isEmpty(); });
913 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) { return g == nullptr; });
927 static void checkNotGeometryCollection(
const Geometry* g);
929 virtual int compareToSameClass(
const Geometry* geom)
const = 0;
932 static int compare(
const T& a,
const T& b)
936 while(i < a.size() && j < b.size()) {
937 const auto& aGeom = *a[i];
938 const auto& bGeom = *b[j];
940 int comparison = aGeom.compareTo(&bGeom);
941 if(comparison != 0) {
960 bool equal(
const CoordinateXY& a,
const CoordinateXY& b,
961 double tolerance)
const;
964 Geometry(
const Geometry& geom);
978 static std::vector<std::unique_ptr<Geometry>> toGeometryArray(std::vector<std::unique_ptr<T>> && v) {
979 static_assert(std::is_base_of<Geometry, T>::value,
"");
980 std::vector<std::unique_ptr<Geometry>> gv(v.size());
981 for (std::size_t i = 0; i < v.size(); i++) {
982 gv[i] = std::move(v[i]);
987 static std::vector<std::unique_ptr<Geometry>> toGeometryArray(std::vector<std::unique_ptr<Geometry>> && v) {
993 virtual int getSortIndex()
const = 0;
998 class GEOS_DLL GeometryChangedFilter :
public GeometryComponentFilter {
1000 void filter_rw(Geometry* geom)
override;
1003 static GeometryChangedFilter geometryChangedFilter;
1009 const GeometryFactory* _factory;
1018GEOS_DLL std::ostream& operator<< (std::ostream& os,
const Geometry& geom);
1020struct GEOS_DLL GeometryGreaterThen {
1039 typedef std::unique_ptr<Geometry> GeomPtr;
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition CoordinateFilter.h:43
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition CoordinateSequenceFilter.h:56
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
DimensionType
Definition Dimension.h:29
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Definition GeometryComponentFilter.h:41
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:45
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
virtual std::unique_ptr< Geometry > getBoundary() const =0
Returns the boundary, or an empty geometry of appropriate dimension if this Geometry is empty.
virtual int getBoundaryDimension() const =0
Returns the dimension of this Geometrys inherent boundary.
virtual bool equalsIdentical(const Geometry *other) const =0
Returns true if the two geometries are of the same type and their vertices corresponding by index are...
std::vector< Geometry * > NonConstVect
A vector of non-const Geometry pointers.
Definition Geometry.h:207
void applyComponentFilter(T &f) const
Apply a filter to each component of this geometry. The filter is expected to provide a ....
Definition Geometry.h:806
virtual const CoordinateXY * getCoordinate() const =0
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
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...
std::unique_ptr< Geometry > reverse() const
Computes a new geometry which has all component coordinate sequences in reverse order (opposite orien...
Definition Geometry.h:687
virtual ~Geometry()
Destroy Geometry and all components.
virtual void apply_rw(CoordinateSequenceFilter &filter)=0
const PrecisionModel * getPrecisionModel() const
Get the PrecisionModel used to create this Geometry.
std::unique_ptr< IntersectionMatrix > relate(const Geometry *g) const
Returns the DE-9IM intersection matrix for the two Geometrys.
virtual void geometryChangedAction()=0
Notifies this Geometry that its Coordinates have been changed by an external party.
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 isDimensionStrict(Dimension::DimensionType d) const
Checks whether this Geometry consists only of components having dimension d.
Definition Geometry.h:369
virtual void normalize()=0
virtual void apply_ro(CoordinateSequenceFilter &filter) const =0
virtual bool intersects(const Geometry *g) const
Returns true if disjoint returns false.
virtual bool crosses(const Geometry *g) const
virtual GeometryTypeId getGeometryTypeId() const =0
Return an integer representation of this Geometry type.
int compareTo(const Geometry *geom) const
Comparator for sorting geometry.
virtual std::unique_ptr< Geometry > convexHull() const
Returns the smallest convex Polygon that contains all the points in the Geometry.
virtual bool hasDimension(Dimension::DimensionType d) const
Checks whether any component of this geometry has dimension d.
Definition Geometry.h:364
virtual std::string getGeometryType() const =0
Return a string representation of this Geometry type.
virtual uint8_t getCoordinateDimension() const =0
Returns the coordinate dimension of this Geometry (2=XY, 3=XYZ or XYM, 4=XYZM).
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 double getLength() const
Returns the length of this Geometry.
virtual double distance(const Geometry *g) const
std::unique_ptr< Point > getInteriorPoint() const
Computes an interior point of this Geometry.
std::unique_ptr< Geometry > intersection(const Geometry *other) const
Returns a Geometry representing the points shared by this Geometry and other.
virtual bool getCentroid(CoordinateXY &ret) const
Computes the centroid of this Geometry as a Coordinate.
std::unique_ptr< Geometry > Ptr
An unique_ptr of Geometry.
Definition Geometry.h:210
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:334
virtual bool hasCurvedComponents() const
Returns whether the Geometry contains curved components.
virtual bool within(const Geometry *g) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is T*F**F***.
virtual std::size_t getNumPoints() const =0
Returns the count of this Geometrys vertices.
static bool hasNullElements(const CoordinateSequence *list)
Returns true if the CoordinateSequence contains any null elements.
virtual Geometry * reverseImpl() const =0
Make a geometry with coordinates in reverse order.
void geometryChanged()
Notifies this Geometry that its Coordinates have been changed by an external party (using a Coordinat...
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:246
virtual bool isEmpty() const =0
Returns whether or not the set of points in this Geometry is empty.
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...
Geometry(const GeometryFactory *factory)
Construct a geometry with the given GeometryFactory.
bool isValid() const
Tests the validity of this Geometry.
std::vector< const Geometry * > ConstVect
A vector of const Geometry pointers.
Definition Geometry.h:204
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition Geometry.h:227
virtual bool touches(const Geometry *other) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is FT*******,...
virtual std::unique_ptr< Geometry > getEnvelope() const
Returns this Geometrys bounding box.
virtual std::string toString() const
Returns the Well-known Text representation of this Geometry.
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...
virtual Geometry * cloneImpl() const =0
Make a deep-copy of this Geometry.
virtual bool isSimple() const
Returns false if the Geometry not simple.
static bool hasNonEmptyElements(const std::vector< T > *geometries)
Returns true if the array contains any non-empty Geometrys.
Definition Geometry.h:903
Ptr Union() const
Computes the union of all the elements of this geometry. Heterogeneous GeometryCollections are fully ...
void * getUserData() const
Gets the user data object for this geometry, if any.
Definition Geometry.h:258
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 bool disjoint(const Geometry *other) const
virtual bool contains(const Geometry *g) const
Returns true if other.within(this) returns true.
virtual bool isEquivalentClass(const Geometry *other) const
Returns whether the two Geometrys are equal, from the point of view of the equalsExact method.
std::unique_ptr< Geometry > buffer(double distance) const
virtual std::unique_ptr< Point > getCentroid() const
Computes the centroid of this Geometry.
bool coveredBy(const Geometry *g) const
Tests whether this geometry is covered by the specified geometry.
virtual std::unique_ptr< CoordinateSequence > getCoordinates() const =0
Returns this Geometry vertices. Caller takes ownership of the returned object.
std::unique_ptr< Geometry > Union(const Geometry *other) const
Returns a Geometry representing all the points in this Geometry and other.
virtual std::size_t getNumGeometries() const
Returns the number of geometries in this collection, or 1 if this is not a collection.
Definition Geometry.h:326
std::unique_ptr< Geometry > clone() const
Make a deep-copy of this Geometry.
Definition Geometry.h:213
virtual double getArea() const
Returns the area of this Geometry.
virtual bool isRectangle() const
Polygon overrides to check for actual rectangle.
Definition Geometry.h:355
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 ...
bool covers(const Geometry *g) const
Returns true if this geometry covers the specified geometry.
virtual Dimension::DimensionType getDimension() const =0
Returns the dimension of this Geometry (0=point, 1=line, 2=surface)
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...
virtual const Envelope * getEnvelopeInternal() const =0
Returns the minimum and maximum x and y values in this Geometry, or a null Envelope if this Geometry ...
int getSRID() const
Returns the ID of the Spatial Reference System used by the Geometry.
Definition Geometry.h:273
static bool hasNullElements(const std::vector< T > *geometries)
Returns true if the vector contains any null elements.
Definition Geometry.h:912
virtual void setSRID(int newSRID)
Sets the ID of the Spatial Reference System used by the Geometry.
Definition Geometry.h:282
bool equals(const Geometry *g) const
Returns true if the DE-9IM intersection matrix for the two Geometrys is T*F**FFF*.
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:88
@ GEOS_MULTILINESTRING
Definition geos_c.h:210
@ GEOS_GEOMETRYCOLLECTION
Definition geos_c.h:214
@ GEOS_POINT
Definition geos_c.h:200
@ GEOS_MULTIPOLYGON
Definition geos_c.h:212
@ GEOS_POLYGON
Definition geos_c.h:206
@ GEOS_MULTIPOINT
Definition geos_c.h:208
@ GEOS_LINESTRING
Definition geos_c.h:202
std::string jtsport()
Return the version of JTS this GEOS release has been ported from.
std::string geosversion()
Return current GEOS version.
GeometryTypeId
Geometry types.
Definition Geometry.h:74
@ GEOS_MULTILINESTRING
a collection of linestrings
Definition Geometry.h:86
@ GEOS_LINEARRING
a linear ring (linestring with 1st point == last point)
Definition Geometry.h:80
@ GEOS_GEOMETRYCOLLECTION
a collection of heterogeneus geometries
Definition Geometry.h:90
@ GEOS_POINT
a point
Definition Geometry.h:76
@ GEOS_LINESTRING
a linestring
Definition Geometry.h:78
@ GEOS_POLYGON
a polygon
Definition Geometry.h:82
@ GEOS_MULTIPOLYGON
a collection of polygons
Definition Geometry.h:88
@ GEOS_MULTIPOINT
a collection of points
Definition Geometry.h:84
Basic namespace for all GEOS functionalities.
Definition geos.h:39