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") 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;
201 using Ptr = std::unique_ptr<Geometry> ;
204 virtual std::unique_ptr<Geometry> clone()
const = 0;
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();
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;
487 const std::string& intersectionPattern)
const;
492 return relate(&g, intersectionPattern);
496 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 virtual std::unique_ptr<Geometry> reverse()
const = 0;
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();
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; });
883 virtual bool isEquivalentClass(
const Geometry* other)
const;
885 static void checkNotGeometryCollection(
const Geometry* g);
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;
938 void filter_rw(
Geometry* geom)
override;
989 #endif // ndef GEOS_GEOM_GEOMETRY_H const GeometryFactory * _factory
Geometry classes support the concept of applying a Geometry filter to the Geometry.
virtual int getSRID() const
Returns the ID of the Spatial Reference System used by the Geometry.
An Envelope defines a rectangulare region of the 2D coordinate plane.
a collection of heterogeneus geometries
bool relate(const Geometry &g, const std::string &intersectionPattern) const
a collection of linestrings
Coordinate is the lightweight class used to store coordinates.
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) ...
static GeometryChangedFilter geometryChangedFilter
virtual bool isRectangle() const
Polygon overrides to check for actual rectangle.
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Specifies the precision model of the Coordinate in a Geometry.
virtual std::size_t getNumGeometries() const
std::string geosversion()
Return current GEOS version.
GeometryTypeId
Geometry types.
bool covers(const Geometry *g) const
Returns true if this geometry covers the specified geometry.
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
static std::vector< std::unique_ptr< Geometry > > toGeometryArray(std::vector< std::unique_ptr< T >> &&v)
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
std::string jtsport()
Return the version of JTS this GEOS release has been ported from.
void setUserData(void *newUserData)
A simple scheme for applications to add their own custom data to a Geometry. An example use might be ...
Dimension value of a curve (1).
Dimension value of a surface (2).
void * getUserData() const
Gets the user data object for this geometry, if any.
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
virtual bool isEmpty() const =0
Returns whether or not the set of points in this Geometry is empty.
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
std::vector< Geometry * > NonConstVect
A vector of non-const Geometry pointers.
virtual bool isDimensionStrict(Dimension::DimensionType d) const
Checks whether this Geometry consists only of components having dimension d.
Basic namespace for all GEOS functionalities.
virtual void setSRID(int newSRID)
Sets the ID of the Spatial Reference System used by the Geometry.
std::unique_ptr< Geometry > GeomPtr
bool isCollection() const
a linear ring (linestring with 1st point == last point)
static bool hasNullElements(const std::vector< T > *geometries)
Returns true if the vector contains any null elements.
Dimension value of a point (0).
The internal representation of a list of coordinates inside a Geometry.
std::unique_ptr< Envelope > Ptr
static bool hasNonEmptyElements(const std::vector< T > *geometries)
Returns true if the array contains any non-empty Geometrys.
std::unique_ptr< Geometry > Ptr
An unique_ptr of Geometry.
std::unique_ptr< Envelope > envelope
The bounding box of this Geometry.
std::vector< const Geometry * > ConstVect
A vector of const Geometry pointers.
void applyComponentFilter(T &f) const
Apply a filter to each component of this geometry. The filter is expected to provide a ...
std::unique_ptr< IntersectionMatrix > relate(const Geometry &g) const
bool coveredBy(const Geometry *g) const
Tests whether this geometry is covered by the specified geometry.