21 #include <QDomDocument>
90 static GEOSContextHandle_t getGEOSHandler();
114 void fromGeos( GEOSGeometry* geos );
119 void fromWkb(
unsigned char * wkb,
size_t length );
125 const unsigned char* asWkb()
const;
130 size_t wkbSize()
const;
135 const GEOSGeometry* asGeos()
const;
167 QgsPoint closestVertex(
const QgsPoint& point,
int& atVertex,
int& beforeVertex,
int& afterVertex,
double& sqrDist );
181 void adjacentVertices(
int atVertex,
int& beforeVertex,
int& afterVertex );
194 bool insertVertex(
double x,
double y,
int beforeVertex );
202 bool moveVertex(
double x,
double y,
int atVertex );
214 bool deleteVertex(
int atVertex );
228 double sqrDistToVertexAt(
QgsPoint& point,
int atVertex );
236 double closestVertexWithContext(
const QgsPoint& point,
int& atVertex );
253 int addRing(
const QList<QgsPoint>& ring );
265 int addPart( GEOSGeometry *newPart );
276 int translate(
double dx,
double dy );
289 int splitGeometry(
const QList<QgsPoint>& splitLine,
290 QList<QgsGeometry*>&newGeometries,
292 QList<QgsPoint> &topologyTestPoints );
296 int reshapeGeometry(
const QList<QgsPoint>& reshapeWithLine );
310 bool intersects(
const QgsGeometry* geometry )
const;
313 bool contains(
const QgsPoint* p )
const;
316 bool contains(
const QgsGeometry* geometry )
const;
319 bool disjoint(
const QgsGeometry* geometry )
const;
328 bool overlaps(
const QgsGeometry* geometry )
const;
338 QgsGeometry* buffer(
double distance,
int segments );
349 QgsGeometry* buffer(
double distance,
int segments,
int endCapStyle,
int joinStyle,
double mitreLimit );
356 QgsGeometry* offsetCurve(
double distance,
int segments,
int joinStyle,
double mitreLimit );
393 QString exportToWkt(
const int &precision = 17 )
const;
399 QString exportToGeoJSON(
const int &precision = 17 )
const;
437 QList<QgsGeometry*> asGeometryCollection()
const;
443 bool deleteRing(
int ringNum,
int partNum = 0 );
448 bool deletePart(
int partNum );
453 bool convertToMultiType();
470 Error() : message(
"none" ), hasLocation( false ) {}
471 Error( QString m ) : message( m ), hasLocation( false ) {}
472 Error( QString m,
QgsPoint p ) : message( m ), location( p ), hasLocation( true ) {}
474 QString
what() {
return message; };
480 void validateGeometry( QList<Error> &errors );
486 static QgsGeometry *unaryUnion(
const QList<QgsGeometry*>& geometryList );
499 mutable unsigned char * mGeometry;
502 mutable size_t mGeometrySize;
505 mutable GEOSGeometry* mGeos;
508 mutable bool mDirtyWkb;
511 mutable bool mDirtyGeos;
519 bool exportWkbToGeos()
const;
524 bool exportGeosToWkb()
const;
539 bool insertVertex(
double x,
double y,
541 const GEOSCoordSequence* old_sequence,
542 GEOSCoordSequence** new_sequence );
549 void translateVertex(
QgsWkbPtr &wkbPtr,
double dx,
double dy,
bool hasZValue );
563 int splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries );
566 int splitPolygonGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries );
568 GEOSGeometry* linePointDifference( GEOSGeometry* GEOSsplitPoint );
572 int topologicalTestPointsSplit(
const GEOSGeometry* splitLine, QList<QgsPoint>& testPoints )
const;
579 static GEOSGeometry* reshapeLine(
const GEOSGeometry* origLine,
const GEOSGeometry* reshapeLineGeos );
586 static GEOSGeometry* reshapePolygon(
const GEOSGeometry* polygon,
const GEOSGeometry* reshapeLineGeos );
590 static GEOSGeometry* nodeGeometries(
const GEOSGeometry *splitLine,
const GEOSGeometry *poly );
594 static int lineContainedInLine(
const GEOSGeometry* line1,
const GEOSGeometry* line2 );
600 static int pointContainedInLine(
const GEOSGeometry* point,
const GEOSGeometry* line );
603 static int geomDigits(
const GEOSGeometry* geom );
606 int numberOfGeometries( GEOSGeometry* g )
const;
608 int mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitResult );
619 static bool geosRelOp(
char( *op )( GEOSContextHandle_t handle,
const GEOSGeometry*,
const GEOSGeometry * ),
623 double leftOf(
double x,
double y,
double& x1,
double& y1,
double& x2,
double& y2 );
625 static inline bool moveVertex(
QgsWkbPtr &wkbPtr,
const double &x,
const double &y,
int atVertex,
bool hasZValue,
int &pointIndex,
bool isRing );
626 static inline int deleteVertex(
QgsConstWkbPtr &srcPtr,
QgsWkbPtr &dstPtr,
int atVertex,
bool hasZValue,
int &pointIndex,
bool isRing,
bool lastItem );
627 static inline bool insertVertex(
QgsConstWkbPtr &srcPtr,
QgsWkbPtr &dstPtr,
int beforeVertex,
const double &x,
const double &y,
bool hasZValue,
int &pointIndex,
bool isRing );
634 QgsGeometry* convertToPolygon(
bool destMultipart );
641 mutable unsigned char *mP;
646 inline const QgsWkbPtr &
operator>>(
double &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
647 inline const QgsWkbPtr &
operator>>(
int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
648 inline const QgsWkbPtr &
operator>>(
unsigned int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
649 inline const QgsWkbPtr &
operator>>(
char &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
652 inline QgsWkbPtr &
operator<<(
const double &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
653 inline QgsWkbPtr &
operator<<(
const int &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
654 inline QgsWkbPtr &
operator<<(
const unsigned int &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
655 inline QgsWkbPtr &
operator<<(
const char &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
660 inline operator unsigned char *()
const {
return mP; }
665 mutable unsigned char *mP;
672 inline const QgsConstWkbPtr &
operator>>(
unsigned int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
678 inline operator const unsigned char *()
const {
return mP; }