21 #include <QDomDocument>
27 #if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
28 #define GEOSGeometry struct GEOSGeom_t
29 #define GEOSCoordSequence struct GEOSCoordSeq_t
113 void fromGeos( GEOSGeometry* geos );
118 void fromWkb(
unsigned char * wkb,
size_t length );
124 const unsigned char* asWkb()
const;
129 size_t wkbSize()
const;
135 const GEOSGeometry* asGeos()
const;
177 QgsPoint closestVertex(
const QgsPoint& point,
int& atVertex,
int& beforeVertex,
int& afterVertex,
double& sqrDist );
191 void adjacentVertices(
int atVertex,
int& beforeVertex,
int& afterVertex );
204 bool insertVertex(
double x,
double y,
int beforeVertex );
212 bool moveVertex(
double x,
double y,
int atVertex );
224 bool deleteVertex(
int atVertex );
238 double sqrDistToVertexAt(
QgsPoint& point,
int atVertex );
246 double closestVertexWithContext(
const QgsPoint& point,
int& atVertex );
263 int addRing(
const QList<QgsPoint>& ring );
275 int addPart( GEOSGeometry *newPart );
286 int translate(
double dx,
double dy );
299 int splitGeometry(
const QList<QgsPoint>& splitLine,
300 QList<QgsGeometry*>&newGeometries,
302 QList<QgsPoint> &topologyTestPoints );
307 int reshapeGeometry(
const QList<QgsPoint>& reshapeWithLine );
321 bool intersects(
const QgsGeometry* geometry )
const;
324 bool contains(
const QgsPoint* p )
const;
328 bool contains(
const QgsGeometry* geometry )
const;
332 bool disjoint(
const QgsGeometry* geometry )
const;
344 bool overlaps(
const QgsGeometry* geometry )
const;
356 QgsGeometry* buffer(
double distance,
int segments );
367 QgsGeometry* buffer(
double distance,
int segments,
int endCapStyle,
int joinStyle,
double mitreLimit );
374 QgsGeometry* offsetCurve(
double distance,
int segments,
int joinStyle,
double mitreLimit );
412 QString exportToWkt()
const;
419 QString exportToGeoJSON()
const;
458 QList<QgsGeometry*> asGeometryCollection()
const;
464 bool deleteRing(
int ringNum,
int partNum = 0 );
469 bool deletePart(
int partNum );
474 bool convertToMultiType();
492 Error() : message(
"none" ), hasLocation( false ) {}
493 Error( QString m ) : message( m ), hasLocation( false ) {}
494 Error( QString m,
QgsPoint p ) : message( m ), location( p ), hasLocation( true ) {}
496 QString
what() {
return message; };
505 void validateGeometry( QList<Error> &errors );
511 static QgsGeometry *unaryUnion(
const QList<QgsGeometry*>& geometryList );
544 bool exportWkbToGeos()
const;
549 bool exportGeosToWkb()
const;
564 bool insertVertex(
double x,
double y,
566 const GEOSCoordSequence* old_sequence,
567 GEOSCoordSequence** new_sequence );
574 void translateVertex(
QgsWkbPtr &wkbPtr,
double dx,
double dy,
bool hasZValue );
588 int splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries );
591 int splitPolygonGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries );
593 GEOSGeometry* linePointDifference( GEOSGeometry* GEOSsplitPoint );
597 int topologicalTestPointsSplit(
const GEOSGeometry* splitLine, QList<QgsPoint>& testPoints )
const;
604 static GEOSGeometry* reshapeLine(
const GEOSGeometry* origLine,
const GEOSGeometry* reshapeLineGeos );
611 static GEOSGeometry* reshapePolygon(
const GEOSGeometry* polygon,
const GEOSGeometry* reshapeLineGeos );
615 static GEOSGeometry* nodeGeometries(
const GEOSGeometry *splitLine,
const GEOSGeometry *poly );
619 static int lineContainedInLine(
const GEOSGeometry* line1,
const GEOSGeometry* line2 );
625 static int pointContainedInLine(
const GEOSGeometry* point,
const GEOSGeometry* line );
628 static int geomDigits(
const GEOSGeometry* geom );
631 int numberOfGeometries( GEOSGeometry* g )
const;
633 int mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitResult );
644 static bool geosRelOp(
char( *op )(
const GEOSGeometry*,
const GEOSGeometry * ),
648 double leftOf(
double x,
double y,
double& x1,
double& y1,
double& x2,
double& y2 );
650 static inline bool moveVertex(
QgsWkbPtr &wkbPtr,
const double &x,
const double &y,
int atVertex,
bool hasZValue,
int &pointIndex,
bool isRing );
651 static inline int deleteVertex(
QgsConstWkbPtr &srcPtr,
QgsWkbPtr &dstPtr,
int atVertex,
bool hasZValue,
int &pointIndex,
bool isRing,
bool lastItem );
652 static inline bool insertVertex(
QgsConstWkbPtr &srcPtr,
QgsWkbPtr &dstPtr,
int beforeVertex,
const double &x,
const double &y,
bool hasZValue,
int &pointIndex,
bool isRing );
659 QgsGeometry* convertToPolygon(
bool destMultipart );
666 mutable unsigned char *
mP;
671 inline const QgsWkbPtr &
operator>>(
double &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
672 inline const QgsWkbPtr &
operator>>(
int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
673 inline const QgsWkbPtr &
operator>>(
unsigned int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
674 inline const QgsWkbPtr &
operator>>(
char &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
677 inline QgsWkbPtr &
operator<<(
const double &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
678 inline QgsWkbPtr &
operator<<(
const int &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
679 inline QgsWkbPtr &
operator<<(
const unsigned int &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
680 inline QgsWkbPtr &
operator<<(
const char &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
685 inline operator unsigned char *()
const {
return mP; }
690 mutable unsigned char *
mP;
697 inline const QgsConstWkbPtr &
operator>>(
unsigned int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
703 inline operator const unsigned char *()
const {
return mP; }
A rectangle specified with double values.
QgsWkbPtr(unsigned char *p)
bool mDirtyWkb
If the geometry has been set since the last conversion to WKB.
const QgsConstWkbPtr & operator>>(char &v) const
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
const QgsConstWkbPtr & operator>>(double &v) const
const QgsWkbPtr & operator>>(int &v) const
WkbType
Used for symbology operations.
size_t mGeometrySize
size of geometry
const QgsConstWkbPtr & operator>>(unsigned int &v) const
QgsWkbPtr & operator<<(const int &v)
const double DEFAULT_SEGMENT_EPSILON
default snapping tolerance for segments (
const QgsConstWkbPtr & operator>>(QGis::WkbType &v) const
QgsWkbPtr & operator<<(const double &v)
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
QVector< QgsPoint > QgsMultiPoint
a collection of QgsPoints that share a common collection of attributes
QgsWkbPtr & operator<<(const QGis::WkbType &v)
const QgsWkbPtr & operator>>(double &v) const
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
A class to represent a point geometry.
const QgsWkbPtr & operator>>(char &v) const
bool mDirtyGeos
If the geometry has been set since the last conversion to GEOS.
QVector< QgsPolyline > QgsMultiPolyline
a collection of QgsPolylines that share a common collection of attributes
const QgsWkbPtr & operator>>(QGis::WkbType &v) const
const QgsConstWkbPtr & operator>>(int &v) const
unsigned char * mGeometry
pointer to geometry in binary WKB format This is the class' native implementation ...
QgsWkbPtr & operator<<(const unsigned int &v)
const QgsWkbPtr & operator>>(unsigned int &v) const
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
Represents a vector layer which manages a vector based data sets.
Q_DECLARE_METATYPE(QgsGeometry)
QgsWkbPtr & operator<<(const char &v)
QgsConstWkbPtr(const unsigned char *p)
Error(QString m, QgsPoint p)
GEOSGeometry * mGeos
cached GEOS version of this geometry