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) // warning C4251: needs to have dll-interface to be used by clients of class 48 #pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list 55 class CoordinateFilter;
56 class CoordinateSequence;
57 class CoordinateSequenceFilter;
58 class GeometryComponentFilter;
59 class GeometryFactory;
63 class IntersectionMatrix;
98 enum 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;
295 virtual const CoordinateXY* getCoordinate()
const = 0;
302 virtual std::unique_ptr<CoordinateSequence> getCoordinates()
const = 0;
305 virtual std::size_t getNumPoints()
const = 0;
308 virtual bool isSimple()
const;
311 virtual std::string getGeometryType()
const = 0;
314 virtual bool hasCurvedComponents()
const;
349 virtual bool isValid()
const;
352 virtual bool isEmpty()
const = 0;
366 return getDimension() == d;
371 return d == getDimension();
374 bool isPuntal()
const {
378 bool isLineal()
const {
382 bool isPolygonal()
const {
386 bool isMixedDimension()
const;
389 bool isCollection()
const {
390 int t = getGeometryTypeId();
402 default:
return typeId;
407 virtual uint8_t getCoordinateDimension()
const = 0;
409 virtual bool hasZ()
const = 0;
411 virtual bool hasM()
const = 0;
429 virtual std::unique_ptr<Geometry> getBoundary()
const = 0;
432 virtual int getBoundaryDimension()
const = 0;
435 virtual std::unique_ptr<Geometry> getEnvelope()
const;
441 virtual const Envelope* getEnvelopeInternal()
const = 0;
459 virtual bool disjoint(
const Geometry* other)
const;
465 virtual bool touches(
const Geometry* other)
const;
468 virtual bool intersects(
const Geometry* g)
const;
492 virtual bool crosses(
const Geometry* g)
const;
498 virtual bool within(
const Geometry* g)
const;
501 virtual bool contains(
const Geometry* g)
const;
508 virtual bool overlaps(
const Geometry* g)
const;
524 bool relate(
const Geometry* g,
525 const std::string& intersectionPattern)
const;
528 relate(
const Geometry& g,
const std::string& intersectionPattern)
const 530 return relate(&g, intersectionPattern);
534 std::unique_ptr<IntersectionMatrix> relate(
const Geometry* g)
const;
536 std::unique_ptr<IntersectionMatrix> relate(
const Geometry& g)
const;
543 virtual bool equals(
const Geometry* g)
const;
583 bool covers(
const Geometry* g)
const;
615 bool coveredBy(
const Geometry* g)
const;
619 virtual std::string toString()
const;
621 virtual std::string toText()
const;
627 std::unique_ptr<Geometry> buffer(
double distance)
const;
636 std::unique_ptr<Geometry> buffer(
double distance,
int quadrantSegments)
const;
674 std::unique_ptr<Geometry> buffer(
double distance,
int quadrantSegments,
675 int endCapStyle)
const;
680 virtual std::unique_ptr<Geometry> convexHull()
const;
688 std::unique_ptr<Geometry>
reverse()
const {
return std::unique_ptr<Geometry>(reverseImpl()); }
699 std::unique_ptr<Geometry> intersection(
const Geometry* other)
const;
710 std::unique_ptr<Geometry> Union(
const Geometry* other)
const;
743 std::unique_ptr<Geometry> difference(
const Geometry* other)
const;
754 std::unique_ptr<Geometry> symDifference(
const Geometry* other)
const;
762 virtual bool equalsExact(
const Geometry* other,
double tolerance = 0)
769 virtual bool equalsIdentical(
const Geometry* other)
const = 0;
809 for(std::size_t i = 0, n = getNumGeometries(); i < n; ++i) {
810 f.filter(getGeometryN(i));
819 virtual void normalize() = 0;
822 virtual int compareTo(
const Geometry* geom)
const;
825 virtual double getArea()
const;
828 virtual double getLength()
const;
835 virtual double distance(
const Geometry* g)
const;
849 virtual bool isWithinDistance(
const Geometry* geom,
850 double cDistance)
const;
861 virtual std::unique_ptr<Point> getCentroid()
const;
867 virtual bool getCentroid(CoordinateXY& ret)
const;
879 std::unique_ptr<Point> getInteriorPoint()
const;
886 virtual void geometryChanged();
893 virtual void geometryChangedAction() = 0;
897 virtual Geometry* cloneImpl()
const = 0;
900 virtual Geometry* reverseImpl()
const = 0;
905 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) {
return !g->isEmpty(); });
914 return std::any_of(geometries->begin(), geometries->end(), [](
const T& g) {
return g ==
nullptr; });
926 virtual bool isEquivalentClass(
const Geometry* other)
const;
928 static void checkNotGeometryCollection(
const Geometry* g);
930 virtual int compareToSameClass(
const Geometry* geom)
const = 0;
933 static int compare(
const T& a,
const T& b)
937 while(i < a.size() && j < b.size()) {
938 const auto& aGeom = *a[i];
939 const auto& bGeom = *b[j];
941 int comparison = aGeom.compareTo(&bGeom);
942 if(comparison != 0) {
961 bool equal(
const CoordinateXY& a,
const CoordinateXY& b,
962 double tolerance)
const;
965 Geometry(
const Geometry& geom);
976 Geometry(
const GeometryFactory* factory);
979 static std::vector<std::unique_ptr<Geometry>> toGeometryArray(std::vector<std::unique_ptr<T>> && v) {
980 static_assert(std::is_base_of<Geometry, T>::value,
"");
981 std::vector<std::unique_ptr<Geometry>> gv(v.size());
982 for (std::size_t i = 0; i < v.size(); i++) {
983 gv[i] = std::move(v[i]);
988 static std::vector<std::unique_ptr<Geometry>> toGeometryArray(std::vector<std::unique_ptr<Geometry>> && v) {
994 virtual int getSortIndex()
const = 0;
999 class GEOS_DLL GeometryChangedFilter :
public GeometryComponentFilter {
1001 void filter_rw(Geometry* geom)
override;
1004 static GeometryChangedFilter geometryChangedFilter;
1010 const GeometryFactory* _factory;
1019 GEOS_DLL std::ostream& operator<< (std::ostream& os,
const Geometry& geom);
1021 struct GEOS_DLL GeometryGreaterThen {
1022 bool operator()(
const Geometry* first,
const Geometry* second);
1034 GEOS_DLL std::string
jtsport();
1039 struct GeomPtrPair {
1040 typedef std::unique_ptr<Geometry> GeomPtr;
1049 #pragma warning(pop) Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:45
void * getUserData() const
Gets the user data object for this geometry, if any.
Definition: Geometry.h:258
void applyComponentFilter(T &f) const
Apply a filter to each component of this geometry. The filter is expected to provide a ...
Definition: Geometry.h:807
a linear ring (linestring with 1st point == last point)
Definition: Geometry.h:80
GeometryTypeId
Geometry types.
Definition: Geometry.h:74
std::unique_ptr< Geometry > clone() const
Make a deep-copy of this Geometry.
Definition: Geometry.h:213
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:55
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition: Geometry.h:227
std::string geosversion()
Return current GEOS version.
virtual bool isDimensionStrict(Dimension::DimensionType d) const
Checks whether this Geometry consists only of components having dimension d.
Definition: Geometry.h:370
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
a collection of linestrings
Definition: Geometry.h:86
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
a polygon
Definition: Geometry.h:82
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:274
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
Dimension value of a curve (1).
Definition: Dimension.h:43
Dimension value of a surface (2).
Definition: Dimension.h:46
virtual bool isRectangle() const
Polygon overrides to check for actual rectangle.
Definition: Geometry.h:356
std::unique_ptr< Geometry > reverse() const
Computes a new geometry which has all component coordinate sequences in reverse order (opposite orien...
Definition: Geometry.h:688
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:70
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:335
std::vector< Geometry * > NonConstVect
A vector of non-const Geometry pointers.
Definition: Geometry.h:207
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
virtual void setSRID(int newSRID)
Sets the ID of the Spatial Reference System used by the Geometry.
Definition: Geometry.h:283
a point
Definition: Geometry.h:76
virtual bool hasDimension(Dimension::DimensionType d) const
Checks whether any component of this geometry has dimension d.
Definition: Geometry.h:365
static bool hasNullElements(const std::vector< T > *geometries)
Returns true if the vector contains any null elements.
Definition: Geometry.h:913
Dimension value of a point (0).
Definition: Dimension.h:40
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:327
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
a collection of polygons
Definition: Geometry.h:88
static bool hasNonEmptyElements(const std::vector< T > *geometries)
Returns true if the array contains any non-empty Geometrys.
Definition: Geometry.h:904
a linestring
Definition: Geometry.h:78
std::unique_ptr< Geometry > Ptr
An unique_ptr of Geometry.
Definition: Geometry.h:210
std::vector< const Geometry * > ConstVect
A vector of const Geometry pointers.
Definition: Geometry.h:204
a collection of heterogeneus geometries
Definition: Geometry.h:90
DimensionType
Definition: Dimension.h:29
Definition: GeometryComponentFilter.h:41
a collection of points
Definition: Geometry.h:84