21 #include <QDomDocument>
90 static GEOSContextHandle_t getGEOSHandler();
113 static QgsGeometry* fromQPointF(
const QPointF& point );
121 static QgsGeometry* fromQPolygonF(
const QPolygonF& polygon );
128 void fromGeos( GEOSGeometry* geos );
133 void fromWkb(
unsigned char * wkb,
size_t length );
139 const unsigned char* asWkb()
const;
144 size_t wkbSize()
const;
149 const GEOSGeometry* asGeos()
const;
158 bool isMultipart()
const;
181 QgsPoint closestVertex(
const QgsPoint& point,
int& atVertex,
int& beforeVertex,
int& afterVertex,
double& sqrDist );
195 void adjacentVertices(
int atVertex,
int& beforeVertex,
int& afterVertex );
208 bool insertVertex(
double x,
double y,
int beforeVertex );
216 bool moveVertex(
double x,
double y,
int atVertex );
228 bool deleteVertex(
int atVertex );
242 double sqrDistToVertexAt(
QgsPoint& point,
int atVertex );
250 double closestVertexWithContext(
const QgsPoint& point,
int& atVertex );
267 int addRing(
const QList<QgsPoint>& ring );
279 int addPart( GEOSGeometry *newPart );
290 int translate(
double dx,
double dy );
299 int transform(
const QTransform& ct );
306 int rotate(
double rotation,
const QgsPoint& center );
315 int splitGeometry(
const QList<QgsPoint>& splitLine,
316 QList<QgsGeometry*>&newGeometries,
318 QList<QgsPoint> &topologyTestPoints );
322 int reshapeGeometry(
const QList<QgsPoint>& reshapeWithLine );
336 bool intersects(
const QgsGeometry* geometry )
const;
339 bool contains(
const QgsPoint* p )
const;
342 bool contains(
const QgsGeometry* geometry )
const;
345 bool disjoint(
const QgsGeometry* geometry )
const;
354 bool overlaps(
const QgsGeometry* geometry )
const;
364 QgsGeometry* buffer(
double distance,
int segments );
375 QgsGeometry* buffer(
double distance,
int segments,
int endCapStyle,
int joinStyle,
double mitreLimit );
382 QgsGeometry* offsetCurve(
double distance,
int segments,
int joinStyle,
double mitreLimit );
419 QString exportToWkt(
const int &precision = 17 )
const;
425 QString exportToGeoJSON(
const int &precision = 17 )
const;
462 QList<QgsGeometry*> asGeometryCollection()
const;
468 QPointF asQPointF()
const;
475 QPolygonF asQPolygonF()
const;
480 bool deleteRing(
int ringNum,
int partNum = 0 );
484 bool deletePart(
int partNum );
489 bool convertToMultiType();
506 Error() : message(
"none" ), hasLocation( false ) {}
507 Error( QString m ) : message( m ), hasLocation( false ) {}
508 Error( QString m,
QgsPoint p ) : message( m ), location( p ), hasLocation( true ) {}
510 QString
what() {
return message; };
516 void validateGeometry( QList<Error> &errors );
522 static QgsGeometry *unaryUnion(
const QList<QgsGeometry*>& geometryList );
535 mutable unsigned char * mGeometry;
538 mutable size_t mGeometrySize;
541 mutable GEOSGeometry* mGeos;
544 mutable bool mDirtyWkb;
547 mutable bool mDirtyGeos;
555 bool exportWkbToGeos()
const;
560 bool exportGeosToWkb()
const;
575 bool insertVertex(
double x,
double y,
577 const GEOSCoordSequence* old_sequence,
578 GEOSCoordSequence** new_sequence );
584 void transformVertex(
QgsWkbPtr &wkbPtr,
const QTransform& trans,
bool hasZValue );
598 int splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries );
601 int splitPolygonGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries );
603 GEOSGeometry* linePointDifference( GEOSGeometry* GEOSsplitPoint );
607 int topologicalTestPointsSplit(
const GEOSGeometry* splitLine, QList<QgsPoint>& testPoints )
const;
614 static GEOSGeometry* reshapeLine(
const GEOSGeometry* origLine,
const GEOSGeometry* reshapeLineGeos );
621 static GEOSGeometry* reshapePolygon(
const GEOSGeometry* polygon,
const GEOSGeometry* reshapeLineGeos );
625 static GEOSGeometry* nodeGeometries(
const GEOSGeometry *splitLine,
const GEOSGeometry *poly );
629 static int lineContainedInLine(
const GEOSGeometry* line1,
const GEOSGeometry* line2 );
635 static int pointContainedInLine(
const GEOSGeometry* point,
const GEOSGeometry* line );
638 static int geomDigits(
const GEOSGeometry* geom );
641 int numberOfGeometries( GEOSGeometry* g )
const;
643 int mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitResult );
654 static bool geosRelOp(
char( *op )( GEOSContextHandle_t handle,
const GEOSGeometry*,
const GEOSGeometry * ),
658 double leftOf(
double x,
double y,
double& x1,
double& y1,
double& x2,
double& y2 );
660 static inline bool moveVertex(
QgsWkbPtr &wkbPtr,
const double &x,
const double &y,
int atVertex,
bool hasZValue,
int &pointIndex,
bool isRing );
661 static inline int deleteVertex(
QgsConstWkbPtr &srcPtr,
QgsWkbPtr &dstPtr,
int atVertex,
bool hasZValue,
int &pointIndex,
bool isRing,
bool lastItem );
662 static inline bool insertVertex(
QgsConstWkbPtr &srcPtr,
QgsWkbPtr &dstPtr,
int beforeVertex,
const double &x,
const double &y,
bool hasZValue,
int &pointIndex,
bool isRing );
669 QgsGeometry* convertToPolygon(
bool destMultipart );
671 static QgsPolyline createPolylineFromQPolygonF(
const QPolygonF &polygon );
672 static QgsPolygon createPolygonFromQPolygonF(
const QPolygonF &polygon );
679 mutable unsigned char *mP;
684 inline const QgsWkbPtr &
operator>>(
double &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
685 inline const QgsWkbPtr &
operator>>(
int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
686 inline const QgsWkbPtr &
operator>>(
unsigned int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
687 inline const QgsWkbPtr &
operator>>(
char &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
690 inline QgsWkbPtr &
operator<<(
const double &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
691 inline QgsWkbPtr &
operator<<(
const int &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
692 inline QgsWkbPtr &
operator<<(
const unsigned int &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
693 inline QgsWkbPtr &
operator<<(
const char &v ) { memcpy( mP, &v,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
698 inline operator unsigned char *()
const {
return mP; }
703 mutable unsigned char *mP;
710 inline const QgsConstWkbPtr &
operator>>(
unsigned int &v )
const { memcpy( &v, mP,
sizeof( v ) ); mP +=
sizeof( v );
return *
this; }
716 inline operator const unsigned char *()
const {
return mP; }