diff -ruN qgis_0.11.0/python/core/qgsfeature.sip qgis_0.11.0-new/python/core/qgsfeature.sip --- qgis_0.11.0/python/core/qgsfeature.sip 2008-07-08 10:03:09.000000000 -0400 +++ qgis_0.11.0-new/python/core/qgsfeature.sip 2008-12-22 13:19:15.000000000 -0500 @@ -8,8 +8,6 @@ public: - typedef unsigned int size_t; - //! Constructor QgsFeature(int id = 0, QString typeName = "" ); diff -ruN qgis_0.11.0/python/core/qgsgeometry.sip qgis_0.11.0-new/python/core/qgsgeometry.sip --- qgis_0.11.0/python/core/qgsgeometry.sip 2008-06-03 10:15:34.000000000 -0400 +++ qgis_0.11.0-new/python/core/qgsgeometry.sip 2008-12-22 13:19:15.000000000 -0500 @@ -14,6 +14,7 @@ /** a collection of QgsPolygons that share a common collection of attributes */ typedef QVector< QVector< QVector > > QgsMultiPolygon; +typedef unsigned int size_t; class QgsGeometry { @@ -52,7 +53,6 @@ /** construct geometry from a rectangle */ static QgsGeometry* fromRect(const QgsRect& rect) /Factory/; - typedef unsigned int size_t; /** diff -ruN qgis_0.11.0/python/core/qgsgeometry.sip.orig qgis_0.11.0-new/python/core/qgsgeometry.sip.orig --- qgis_0.11.0/python/core/qgsgeometry.sip.orig 1969-12-31 19:00:00.000000000 -0500 +++ qgis_0.11.0-new/python/core/qgsgeometry.sip.orig 2008-06-03 10:15:34.000000000 -0400 @@ -0,0 +1,276 @@ + +/** polyline is just a list of points */ +typedef QVector QgsPolyline; + +/** polygon: first item of the list is outer ring, inner rings (if any) start from second item */ +typedef QVector< QVector > QgsPolygon; + +/** a collection of QgsPoints that share a common collection of attributes */ +typedef QVector QgsMultiPoint; + +/** a collection of QgsPolylines that share a common collection of attributes */ +typedef QVector< QVector > QgsMultiPolyline; + +/** a collection of QgsPolygons that share a common collection of attributes */ +typedef QVector< QVector< QVector > > QgsMultiPolygon; + + +class QgsGeometry +{ +%TypeHeaderCode +#include +%End + + public: + + //! Constructor + QgsGeometry(); + + /** copy constructor will prompt a deep copy of the object */ + QgsGeometry( const QgsGeometry & ); + + + //! Destructor + ~QgsGeometry(); + + + /** static method that creates geometry from WKT */ + static QgsGeometry* fromWkt(QString wkt) /Factory/; + + /** construct geometry from a point */ + static QgsGeometry* fromPoint(const QgsPoint& point) /Factory/; + /** construct geometry from a multipoint */ + static QgsGeometry* fromMultiPoint(const QgsMultiPoint& multipoint) /Factory/; + /** construct geometry from a polyline */ + static QgsGeometry* fromPolyline(const QgsPolyline& polyline) /Factory/; + /** construct geometry from a multipolyline*/ + static QgsGeometry* fromMultiPolyline(const QgsMultiPolyline& multiline) /Factory/; + /** construct geometry from a polygon */ + static QgsGeometry* fromPolygon(const QgsPolygon& polygon) /Factory/; + /** construct geometry from a multipolygon */ + static QgsGeometry* fromMultiPolygon(const QgsMultiPolygon& multipoly) /Factory/; + /** construct geometry from a rectangle */ + static QgsGeometry* fromRect(const QgsRect& rect) /Factory/; + + typedef unsigned int size_t; + + + /** + Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length. + This class will take ownership of the buffer. + */ + void setWkbAndOwnership(unsigned char * wkb /Array/, size_t length /ArraySize/); +%MethodCode + // create copy of Python's string and pass it to setWkbAndOwnership() + unsigned char * copy = new unsigned char[a1]; + memcpy(copy, a0, a1); + sipCpp->setWkbAndOwnership(copy, a1); +%End + + /** + Returns the buffer containing this geometry in WKB format. + You may wish to use in conjunction with wkbSize(). + */ + unsigned char * wkbBuffer(); + + /** + Returns the size of the WKB in wkbBuffer(). + */ + size_t wkbSize(); + + /** Returns type of wkb (point / linestring / polygon etc.) */ + QGis::WKBTYPE wkbType(); + + /** Returns type of the vector */ + QGis::VectorType vectorType(); + + /** Returns true if wkb of the geometry is of WKBMulti* type */ + bool isMultipart(); + + /** + Set the geometry, feeding in a geometry in GEOS format. + */ + // TODO: unsupported class... would be possible to use PyGEOS? + //void setGeos(geos::Geometry* geos); + + double distance(QgsGeometry& geom); + + /** + Returns the vertex closest to the given point + (and also vertex index, squared distance and indexes of the vertices before/after) + */ + QgsPoint closestVertex(const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/); + + /** + Returns the indexes of the vertices before and after the given vertex index. + + This function takes into account the following factors: + + 1. If the given vertex index is at the end of a linestring, + the adjacent index will be -1 (for "no adjacent vertex") + 2. If the given vertex index is at the end of a linear ring + (such as in a polygon), the adjacent index will take into + account the first vertex is equal to the last vertex (and will + skip equal vertex positions). + */ + void adjacentVerticies(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/); + + /** Insert a new vertex before the given vertex index, + * ring and item (first number is index 0) + * If the requested vertex number (beforeVertex.back()) is greater + * than the last actual vertex on the requested ring and item, + * it is assumed that the vertex is to be appended instead of inserted. + * Returns FALSE if atVertex does not correspond to a valid vertex + * on this geometry (including if this geometry is a Point). + * It is up to the caller to distinguish between + * these error conditions. (Or maybe we add another method to this + * object to help make the distinction?) + */ + bool insertVertexBefore(double x, double y, int beforeVertex); + + /** Moves the vertex at the given position number, + * ring and item (first number is index 0) + * to the given coordinates. + * Returns FALSE if atVertex does not correspond to a valid vertex + * on this geometry + */ + bool moveVertexAt(double x, double y, int atVertex); + + /** Deletes the vertex at the given position number, + * ring and item (first number is index 0) + * Returns FALSE if atVertex does not correspond to a valid vertex + * on this geometry (including if this geometry is a Point), + * or if the number of remaining verticies in the linestring + * would be less than two. + * It is up to the caller to distinguish between + * these error conditions. (Or maybe we add another method to this + * object to help make the distinction?) + */ + bool deleteVertexAt(int atVertex); + + /** + * Returns coordinates of a vertex. + * @param atVertex index of the vertex + * @return Coordinates of the vertex or QgsPoint(0,0) on error + */ + QgsPoint vertexAt(int atVertex); + + /** + Returns the squared cartesian distance between the given point + to the given vertex index*/ + double sqrDistToVertexAt(QgsPoint& point /In/, int atVertex); + + + /** + * Searches for the the closest vertex in this geometry to the given point. + * @param point Specifiest the point for search + * @param atVertex Receives index of the closest vertex + * @return The squared cartesian distance is also returned in sqrDist, negative number on error + */ + double closestVertexWithContext(const QgsPoint& point, int& atVertex /Out/); + + /** + * Searches for the closest segment of geometry to the given point + * @param point Specifies the point for search + * @param minDistPoint Receives the nearest point on the segment + * @param beforeVertex Receives index of the vertex before the closest segment + * @return The squared cartesian distance is also returned in sqrDist, negative number on error + */ + double closestSegmentWithContext(const QgsPoint& point, QgsPoint& minDistPoint /Out/, int& beforeVertex /Out/); + + /**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons. + @return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed, \ + 3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/ + int addRing(const QList& ring); + + /**Adds a new island polygon to a multipolygon feature + @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring \ +not disjoint with existing polygons of the feature*/ + int addIsland(const QList& ring); + + /**Translate this geometry by dx, dy + @return 0 in case of success*/ + int translate(double dx, double dy); + + /**Splits this geometry according to a given line. Note that the geometry is only splitted once. If there are several intersections + between geometry and splitLine, only the first one is considered. + @param splitLine the line that splits the geometry + @param newGeometrys OUT: list of new geometries that have been created with the split + @return 0 in case of success, which means the geometry has been split in two parts, \ + 1 if line intersects multiple times but only one split could be done, \ + 2 if intersection too complicated to proceed (several polygon intersections), \ \ + else other error*/ + int splitGeometry(const QList& splitLine, QList& newGeometries); + + /**Changes this geometry such that it does not intersect the other geometry + @param other geometry that should not be intersect + @return 0 in case of success*/ + int makeDifference(QgsGeometry* other); + + /**Returns the bounding box of this feature*/ + QgsRect boundingBox(); + + /** Test for intersection with a rectangle (uses GEOS) */ + bool intersects(const QgsRect& r); + /** Test for intersection with a geoemetry (uses GEOS) */ + bool intersects(QgsGeometry* geometry); + + /** Test for containment of a point (uses GEOS) */ + bool contains(QgsPoint* p); + + /** Returns a buffer region around this geometry having the given width and with a specified number + of segments used to approximate curves */ + QgsGeometry* buffer(double distance, int segments) /Factory/; + + /** Returns the smallest convex polygon that contains all the points in the geometry. */ + QgsGeometry* convexHull() /Factory/; + + /** Returns a geometry representing the points shared by this geometry and other. */ + QgsGeometry* intersection(QgsGeometry* geometry) /Factory/; + + /** Returns a geometry representing all the points in this geometry and other. */ + QgsGeometry* Union(QgsGeometry* geometry) /Factory/; + + /** Returns a geometry representing the points making up this geometry that do not make up other. */ + QgsGeometry* difference(QgsGeometry* geometry) /Factory/; + + /** Returns a Geometry representing the points making up this Geometry that do not make up other. */ + QgsGeometry* symDifference(QgsGeometry* geometry) /Factory/; + + /**Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted*/ + // TODO: unsupported class... would be possible to use PyGEOS? + //geos::Geometry* geosGeometry() const; + + /** Exports the geometry to mWkt + @return true in case of success and false else + */ + QString exportToWkt(); + + /* Accessor functions for getting geometry data */ + + /** return contents of the geometry as a point + if wkbType is WKBPoint, otherwise returns [0,0] */ + QgsPoint asPoint(); + + /** return contents of the geometry as a polyline + if wkbType is WKBLineString, otherwise an empty list */ + QgsPolyline asPolyline(); + + /** return contents of the geometry as a polygon + if wkbType is WKBPolygon, otherwise an empty list */ + QgsPolygon asPolygon(); + + /** return contents of the geometry as a polygon + if wkbType is WKBPolygon, otherwise an empty list */ + QgsMultiPoint asMultiPoint(); + + /** return contents of the geometry as a polygon + if wkbType is WKBPolygon, otherwise an empty list */ + QgsMultiPolyline asMultiPolyline(); + + /** return contents of the geometry as a polygon + if wkbType is WKBPolygon, otherwise an empty list */ + QgsMultiPolygon asMultiPolygon(); + +}; // class QgsGeometry +