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 std::unique_ptr<Geometry>
clone()
const {
return std::unique_ptr<Geometry>(cloneImpl()); }
239 _userData = newUserData;
286 virtual const Coordinate* getCoordinate()
const = 0;
293 virtual std::unique_ptr<CoordinateSequence> getCoordinates()
const = 0;
296 virtual std::size_t getNumPoints()
const = 0;
299 virtual bool isSimple()
const;
302 virtual std::string getGeometryType()
const = 0;
332 virtual bool isValid()
const;
335 virtual bool isEmpty()
const = 0;
349 return d == getDimension();
352 bool isPuntal()
const {
356 bool isLineal()
const {
360 bool isPolygonal()
const {
364 bool isCollection()
const {
365 int t = getGeometryTypeId();
373 virtual uint8_t getCoordinateDimension()
const = 0;
391 virtual std::unique_ptr<Geometry> getBoundary()
const = 0;
394 virtual int getBoundaryDimension()
const = 0;
397 virtual std::unique_ptr<Geometry> getEnvelope()
const;
403 virtual const Envelope* getEnvelopeInternal()
const;
421 virtual bool disjoint(
const Geometry* other)
const;
427 virtual bool touches(
const Geometry* other)
const;
430 virtual bool intersects(
const Geometry* g)
const;
454 virtual bool crosses(
const Geometry* g)
const;
460 virtual bool within(
const Geometry* g)
const;
463 virtual bool contains(
const Geometry* g)
const;
470 virtual bool overlaps(
const Geometry* g)
const;
486 bool relate(
const Geometry* g,
487 const std::string& intersectionPattern)
const;
490 relate(
const Geometry& g,
const std::string& intersectionPattern)
const 492 return relate(&g, intersectionPattern);
496 std::unique_ptr<IntersectionMatrix> relate(
const Geometry* g)
const;
498 std::unique_ptr<IntersectionMatrix> relate(
const Geometry& g)
const 508 virtual bool equals(
const Geometry* g)
const;
548 bool covers(
const Geometry* g)
const;
588 virtual std::string toString()
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;
649 virtual std::unique_ptr<Geometry> convexHull()
const;
657 std::unique_ptr<Geometry>
reverse()
const {
return std::unique_ptr<Geometry>(reverseImpl()); }
668 std::unique_ptr<Geometry> intersection(
const Geometry* other)
const;
679 std::unique_ptr<Geometry> Union(
const Geometry* other)
const;
712 std::unique_ptr<Geometry> difference(
const Geometry* other)
const;
723 std::unique_ptr<Geometry> symDifference(
const Geometry* other)
const;
729 virtual bool equalsExact(
const Geometry* other,
double tolerance = 0)
770 for(std::size_t i = 0, n = getNumGeometries(); i < n; ++i) {
771 f.filter(getGeometryN(i));
780 virtual void normalize() = 0;
783 virtual int compareTo(
const Geometry* geom)
const;
789 virtual double distance(
const Geometry* g)
const;
792 virtual double getArea()
const;
795 virtual double getLength()
const;
808 virtual bool isWithinDistance(
const Geometry* geom,
809 double cDistance)
const;
820 virtual std::unique_ptr<Point> getCentroid()
const;
826 virtual bool getCentroid(
Coordinate& ret)
const;
838 std::unique_ptr<Point> getInteriorPoint()
const;
845 virtual void geometryChanged();
852 void geometryChangedAction();
860 virtual Geometry* cloneImpl()
const = 0;
863 virtual Geometry* reverseImpl()
const = 0;
868 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) {
return !g->isEmpty(); });
877 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) {
return g ==
nullptr; });
889 virtual bool isEquivalentClass(
const Geometry* other)
const;
891 static void checkNotGeometryCollection(
const Geometry* g);
898 virtual Envelope::Ptr computeEnvelopeInternal()
const = 0;
900 virtual int compareToSameClass(
const Geometry* geom)
const = 0;
902 int compare(std::vector<Coordinate> a, std::vector<Coordinate> b)
const;
904 int compare(std::vector<Geometry*> a, std::vector<Geometry*> b)
const;
906 int compare(
const std::vector<std::unique_ptr<Geometry>> & a,
const std::vector<std::unique_ptr<Geometry>> & b)
const;
909 double tolerance)
const;
926 static std::vector<std::unique_ptr<Geometry>> toGeometryArray(std::vector<std::unique_ptr<T>> && v) {
927 static_assert(std::is_base_of<Geometry, T>::value,
"");
928 std::vector<std::unique_ptr<Geometry>> gv(v.size());
929 for (std::size_t i = 0; i < v.size(); i++) {
930 gv[i] = std::move(v[i]);
937 virtual int getSortIndex()
const = 0;
942 class GEOS_DLL GeometryChangedFilter :
public GeometryComponentFilter {
944 void filter_rw(Geometry* geom)
override;
947 static GeometryChangedFilter geometryChangedFilter;
953 const GeometryFactory* _factory;
962 GEOS_DLL std::ostream&
operator<< (std::ostream& os,
const Geometry& geom);
964 struct GEOS_DLL GeometryGreaterThen {
965 bool operator()(
const Geometry* first,
const Geometry* second);
977 GEOS_DLL std::string
jtsport();
983 typedef std::unique_ptr<Geometry> GeomPtr;
995 #endif // ndef GEOS_GEOM_GEOMETRY_H Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
void * getUserData() const
Gets the user data object for this geometry, if any.
Definition: Geometry.h:249
a linestring
Definition: Geometry.h:79
a collection of heterogeneus geometries
Definition: Geometry.h:91
a collection of linestrings
Definition: Geometry.h:87
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
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
std::unique_ptr< Geometry > clone() const
Make a deep-copy of this Geometry.
Definition: Geometry.h:204
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition: Geometry.h:218
std::string geosversion()
Return current GEOS version.
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
virtual bool isDimensionStrict(Dimension::DimensionType d) const
Checks whether this Geometry consists only of components having dimension d.
Definition: Geometry.h:348
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
a collection of points
Definition: Geometry.h:85
std::string jtsport()
Return the version of JTS this GEOS release has been ported from.
virtual int getSRID() const
Returns the ID of the Spatial Reference System used by the Geometry.
Definition: Geometry.h:265
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
Dimension value of a curve (1).
Definition: Dimension.h:45
Dimension value of a surface (2).
Definition: Dimension.h:48
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
virtual bool isRectangle() const
Polygon overrides to check for actual rectangle.
Definition: Geometry.h:339
std::unique_ptr< Geometry > reverse() const
Computes a new geometry which has all component coordinate sequences in reverse order (opposite orien...
Definition: Geometry.h:657
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
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
std::vector< Geometry * > NonConstVect
A vector of non-const Geometry pointers.
Definition: Geometry.h:198
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26
bool coveredBy(const Geometry *g) const
Tests whether this geometry is covered by the specified geometry.
Definition: Geometry.h:581
virtual void setSRID(int newSRID)
Sets the ID of the Spatial Reference System used by the Geometry.
Definition: Geometry.h:274
a polygon
Definition: Geometry.h:83
a linear ring (linestring with 1st point == last point)
Definition: Geometry.h:81
static bool hasNullElements(const std::vector< T > *geometries)
Returns true if the vector contains any null elements.
Definition: Geometry.h:876
a point
Definition: Geometry.h:77
Dimension value of a point (0).
Definition: Dimension.h:42
virtual std::size_t getNumGeometries() const
Definition: Geometry.h:310
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
static bool hasNonEmptyElements(const std::vector< T > *geometries)
Returns true if the array contains any non-empty Geometrys.
Definition: Geometry.h:867
bool covers(const Geometry *g) const
Returns true if this geometry covers the specified geometry.
std::unique_ptr< Geometry > Ptr
An unique_ptr of Geometry.
Definition: Geometry.h:201
a collection of polygons
Definition: Geometry.h:89
std::unique_ptr< Envelope > envelope
The bounding box of this Geometry.
Definition: Geometry.h:857
std::vector< const Geometry * > ConstVect
A vector of const Geometry pointers.
Definition: Geometry.h:195
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43