Skip to content
Permalink
Browse files
Merged provider0_9-branch (r6844:6878) back to trunk.
git-svn-id: http://svn.osgeo.org/qgis/trunk@6879 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 11, 2007
1 parent 52978f8 commit 1ac580270ffa29001be1e6f58f763af827809616
Showing with 2,072 additions and 2,672 deletions.
  1. +1 −0 python/core/core.sip
  2. +0 −9 python/core/qgsdataprovider.sip
  3. +5 −1 python/core/qgsfeature.sip
  4. +28 −21 python/core/qgsgeometry.sip
  5. +1 −1 python/core/qgsspatialrefsys.sip
  6. +34 −41 python/core/qgsvectordataprovider.sip
  7. +50 −0 python/core/qgsvectorfilewriter.sip
  8. +11 −26 python/core/qgsvectorlayer.sip
  9. +16 −0 src/app/legend/qgslegendlayer.cpp
  10. +2 −0 src/app/legend/qgslegendlayer.h
  11. +23 −21 src/app/legend/qgslegendlayerfile.cpp
  12. +23 −10 src/app/qgisapp.cpp
  13. +40 −16 src/app/qgsattributetable.cpp
  14. +6 −0 src/app/qgsattributetable.h
  15. +4 −3 src/app/qgsattributetabledisplay.cpp
  16. +2 −2 src/app/qgsclipboard.cpp
  17. +2 −2 src/app/qgsgraduatedsymboldialog.cpp
  18. +38 −1 src/app/qgsidentifyresults.cpp
  19. +9 −1 src/app/qgsidentifyresults.h
  20. +89 −15 src/app/qgsmaptoolidentify.cpp
  21. +8 −0 src/app/qgsmaptoolidentify.h
  22. +9 −7 src/app/qgssearchquerybuilder.cpp
  23. +2 −2 src/app/qgsuniquevaluedialog.cpp
  24. +0 −1 src/app/qgsvectorlayerproperties.cpp
  25. +1 −9 src/core/qgsdataprovider.h
  26. +12 −33 src/core/qgsfeature.cpp
  27. +4 −0 src/core/qgsfeature.h
  28. +312 −295 src/core/qgsgeometry.cpp
  29. +53 −53 src/core/qgsgeometry.h
  30. +21 −31 src/core/qgslabel.cpp
  31. +1 −1 src/core/qgsspatialrefsys.cpp
  32. +1 −1 src/core/qgsspatialrefsys.h
  33. +106 −9 src/core/qgsvectordataprovider.cpp
  34. +41 −43 src/core/qgsvectordataprovider.h
  35. +200 −488 src/core/qgsvectorfilewriter.cpp
  36. +58 −52 src/core/qgsvectorfilewriter.h
  37. +25 −124 src/core/qgsvectorlayer.cpp
  38. +0 −17 src/core/qgsvectorlayer.h
  39. +1 −1 src/gui/qgsmapcanvas.cpp
  40. +16 −12 src/plugins/grass/qgsgrassmodule.cpp
  41. +18 −105 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  42. +12 −41 src/providers/delimitedtext/qgsdelimitedtextprovider.h
  43. +225 −269 src/providers/gpx/qgsgpxprovider.cpp
  44. +17 −42 src/providers/gpx/qgsgpxprovider.h
  45. +74 −62 src/providers/grass/qgsgrassprovider.cpp
  46. +30 −24 src/providers/grass/qgsgrassprovider.h
  47. +114 −276 src/providers/ogr/qgsogrprovider.cpp
  48. +19 −53 src/providers/ogr/qgsogrprovider.h
  49. +215 −286 src/providers/postgres/qgspostgresprovider.cpp
  50. +41 −45 src/providers/postgres/qgspostgresprovider.h
  51. +0 −1 src/providers/wfs/qgswfsdata.cpp
  52. +34 −90 src/providers/wfs/qgswfsprovider.cpp
  53. +18 −15 src/providers/wfs/qgswfsprovider.h
  54. +0 −5 src/providers/wms/qgswmsprovider.cpp
  55. +0 −9 src/providers/wms/qgswmsprovider.h
@@ -49,5 +49,6 @@
%Include qgssymbologyutils.sip
%Include qgsuniquevaluerenderer.sip
%Include qgsvectordataprovider.sip
%Include qgsvectorfilewriter.sip
%Include qgsvectorlayer.sip

@@ -15,15 +15,6 @@ class QgsDataProvider : QObject
*/
virtual ~QgsDataProvider();

/**
* Set the QgsSpatialReferenceSystem for this layer.
* @note Must be reimplemented by each provider.
*
* @param theSRS QgsSpatialRefSys to be assigned to this layer
* A complete copy of the passed in SRS will be made.
*/
virtual void setSRS(const QgsSpatialRefSys& theSRS) = 0;

/*! Get the QgsSpatialRefSys for this layer
* @note Must be reimplemented by each provider.
* If the provider isn't capable of returning
@@ -112,12 +112,16 @@ class QgsFeature
*/
void setGeometry(QgsGeometry& geom);

/** Set this feature's geometry (takes geometry ownership)
*/
void setGeometry(QgsGeometry* geom);

/**
* Set this feature's geometry from WKB
*
* This feature assumes responsibility for destroying geom.
*/
void setGeometryAndOwnership(unsigned char * geom, size_t length);
void setGeometryAndOwnership(unsigned char * geom /Transfer/, size_t length);


}; // class QgsFeature
@@ -188,6 +188,15 @@ class 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 polyline */
static QgsGeometry* fromPolyline(const QgsPolyline& polyline) /Factory/;
/** construct geometry from a polygon */
static QgsGeometry* fromPolygon(const QgsPolygon& polygon) /Factory/;
/** construct geometry from a rectangle */
static QgsGeometry* fromRect(const QgsRect& rect) /Factory/;

typedef unsigned int size_t;


@@ -203,26 +212,21 @@ class QgsGeometry
Returns the buffer containing this geometry in WKB format.
You may wish to use in conjunction with wkbSize().
*/
unsigned char * wkbBuffer() const;
unsigned char * wkbBuffer();

/**
Returns the size of the WKB in wkbBuffer().
*/
size_t wkbSize() const;
size_t wkbSize();

/**
Returns the QString containing this geometry in WKT format.
*/
const QString & wkt() const;

/** Returns type of wkb (point / linestring / polygon etc.) */
QGis::WKBTYPE wkbType() const;
QGis::WKBTYPE wkbType();

/** Returns type of the vector */
QGis::VectorType vectorType() const;
QGis::VectorType vectorType();

/** Returns true if wkb of the geometry is of WKBMulti* type */
bool isMultipart() const;
bool isMultipart();

/**
Set the geometry, feeding in a geometry in GEOS format.
@@ -236,7 +240,7 @@ class QgsGeometry
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, QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist) const;
QgsPoint closestVertex(const QgsPoint& point, QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist);


/**
@@ -251,7 +255,7 @@ class QgsGeometry
account the first vertex is equal to the last vertex (and will
skip equal vertex positions).
*/
void adjacentVerticies(const QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex) const;
void adjacentVerticies(const QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex);


/** Insert a new vertex before the given vertex index,
@@ -294,7 +298,7 @@ class QgsGeometry

*/
double sqrDistToVertexAt(QgsPoint& point,
QgsGeometryVertexIndex& atVertex) const;
QgsGeometryVertexIndex& atVertex);

/**
* Modifies x and y to indicate the location of
@@ -307,7 +311,7 @@ class QgsGeometry
*
* If FALSE, x and y are not modified.
*/
bool vertexAt(double &x, double &y, QgsGeometryVertexIndex atVertex) const;
bool vertexAt(double &x, double &y, QgsGeometryVertexIndex atVertex);

/**
Returns, in atVertex, the closest vertex in this geometry to the given point.
@@ -326,21 +330,24 @@ class QgsGeometry
double& sqrDist);

/**Returns the bounding box of this feature*/
QgsRect boundingBox() const;
QgsRect boundingBox();

/**Test for intersection with a rectangle (uses GEOS)*/
bool intersects(const QgsRect& r) const;

/**Also tests for intersection, but uses direct geos export of QgsGeometry instead wkb export and geos wkb import. Therefore this method is faster and could replace QgsGeometry::intersects in the future*/
bool fast_intersects(const QgsRect& r) const;
/** 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) const;
bool contains(QgsPoint* p);

/**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 */

@@ -172,7 +172,7 @@ class QgsSpatialRefSys
/*! A helper to get an wkt representation of this srs
* @return string containing Wkt of the srs
*/
QString toWkt();
QString toWkt() const;

/*! Restores state from the given DOM node.
* @param theNode The node from which state will be restored
@@ -48,6 +48,7 @@

};


template<TYPE>
%MappedType QMap<int, QMap<int, TYPE> >
{
@@ -208,17 +209,17 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual QString storageType() const;

/**
* Select features based on a bounding rectangle. Features can be retrieved
* with calls to getFirstFeature and getNextFeature. Request for features
* for use in drawing the map canvas should set useIntersect to false.
* @param mbr QgsRect containing the extent to use in selecting features
* @param useIntersect If true, use the intersects function to select features
* rather than the PostGIS && operator that selects based on bounding box
* overlap.
*
/** Select features based on a bounding rectangle. Features can be retrieved with calls to getNextFeature.
* @param fetchAttributes list of attributes which should be fetched
* @param rect spatial filter
* @param fetchGeometry true if the feature geometry should be fetched
* @param useIntersect true if an accurate intersection test should be used,
* false if a test based on bounding box is sufficient
*/
virtual void select(QgsRect mbr, bool useIntersect = false) = 0;
virtual void select(QList<int> fetchAttributes = QList<int>(),
QgsRect rect = QgsRect(),
bool fetchGeometry = true,
bool useIntersect = false) = 0;

/**
* Update the feature count based on current spatial filter. If not
@@ -242,15 +243,9 @@ class QgsVectorDataProvider : QgsDataProvider
/**
* Get the next feature resulting from a select operation.
* @param feature feature which will receive data from the provider
* @param fetchGeoemtry if true, geometry will be fetched from the provider
* @param fetchAttributes a list containing the indexes of the attribute fields to copy
* @param featureQueueSize a hint to the provider as to how many features are likely to be retrieved in a batch
* @return true when there was a feature to fetch, false when end was hit
*/
virtual bool getNextFeature(QgsFeature& feature,
bool fetchGeometry = true,
QList<int> fetchAttributes = QList<int>(),
uint featureQueueSize = 1) = 0;
virtual bool getNextFeature(QgsFeature& feature) = 0;

/**
* Get feature type.
@@ -265,20 +260,6 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual long featureCount() const = 0;

/**
* Get the attributes associated with a feature
* TODO: Get rid of "row" and set up provider-internal caching instead
*/
virtual void getFeatureAttributes(int key, int& row, QgsFeature *f);

/**
* Fetch geometry for a particular feature with id "key",
* modifies "f" in-place.
*
* This function is enabled if capabilities() returns "SelectGeometryAtId".
*/
virtual void getFeatureGeometry(int key, QgsFeature *f);

/**
* Number of attribute fields for a feature in the layer
*/
@@ -290,26 +271,34 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual const QMap<int, QgsField> & fields() const = 0;

/**
* Reset the layer to clear any spatial filtering or other contstraints that
* would prevent the entire record set from being traversed by call to
* getNextFeature(). Some data stores may not require any special action to
* reset the layer. In this case, the provider should simply implement an empty
* function body.
/**
* Return a short comment for the data that this provider is
* providing access to (e.g. the comment for postgres table).
*/
virtual QString dataComment() const;

/** Restart reading features from previous select operation */
virtual void reset() = 0;

/**
* Returns the minimum value of an attributs
* @param position the number of the attribute
* @param index the index of the attribute
*
* Default implementation walks all numeric attributes and caches minimal
* and maximal values. If provider has facilities to retreive minimal
* value directly, override this function.
*/
virtual QString minValue(uint position) = 0;
virtual QVariant minValue(int index);

/**
* Returns the maximum value of an attributs
* @param position the number of the attribute
* @param index the index of the attribute
*
* Default implementation walks all numeric attributes and caches minimal
* and maximal values. If provider has facilities to retreive maximal
* value directly, override this function.
*/
virtual QString maxValue(uint position) = 0;
virtual QVariant maxValue(int index);

/**
* Adds a list of features
@@ -396,6 +385,10 @@ class QgsVectorDataProvider : QgsDataProvider
*/
QList<int> allAttributesList();

/**Returns the names of the numerical types*/
// TODO: wrap, must wrap QSet<TYPE> first
//const QSet<QString>& supportedNativeTypes() const;

/**
* Set whether provider should return also features that don't have
* associated geometry. FALSE by default
@@ -0,0 +1,50 @@

/**
There are two possibilities how to use this class:
1. static call to QgsVectorFileWriter::writeAsShapefile(...) which saves the whole vector layer
2. create an instance of the class and issue calls to addFeature(...)

Currently supports only writing to shapefiles, but shouldn't be a problem to add capability
to support other OGR-writable formats.
*/
class QgsVectorFileWriter
{
%TypeHeaderCode
#include <qgsvectorfilewriter.h>
#include <qgsfield.h>
%End

public:

enum WriterError
{
NoError = 0,
ErrDriverNotFound,
ErrCreateDataSource,
ErrCreateLayer
};

/** Write contents of vector layer to a shapefile */
static WriterError writeAsShapefile(QgsVectorLayer* layer,
const QString& shapefileName,
const QString& fileEncoding);


/** create shapefile and initialize it */
QgsVectorFileWriter(const QString& shapefileName,
const QString& fileEncoding,
const QMap<int, QgsField>& fields,
QGis::WKBTYPE geometryType,
const QgsSpatialRefSys* srs);

/** checks whether there were any errors in constructor */
WriterError hasError();

/** add feature to the currently opened shapefile */
bool addFeature(QgsFeature& feature);

/** close opened shapefile for writing */
~QgsVectorFileWriter();

};

0 comments on commit 1ac5802

Please sign in to comment.