From 957de75c4011994055176f1c977f66246933e623 Mon Sep 17 00:00:00 2001 From: timlinux Date: Thu, 30 Dec 2004 17:32:28 +0000 Subject: [PATCH] Refactored DataProvider to push some vector specific methods down to qgsvectordataprovider. Doing this will allow me to use the dataprovider ABC for the soon to be implemented raster providers - which will in turn provide a cleaner based for projection support. Also added getProjectionWKT virtual method to maplayer and did (concrete) implementation for raster and (placeholder) implementation for vector. Next step will be to implement a getProjectionWKT method in the dataprovider interface with maplayer will delegate to, allowing the retrival of projection info to be handled on a case by case basis in each provider... git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2544 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/qgsdataprovider.h | 22 +++------------------- src/qgsmaplayer.h | 8 +++++++- src/qgsrasterlayer.h | 2 ++ src/qgsvectordataprovider.h | 20 +++++++++++++++++++- src/qgsvectorlayer.h | 9 +++++++-- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/qgsdataprovider.h b/src/qgsdataprovider.h index 95b50adf30e..719168fcb1d 100644 --- a/src/qgsdataprovider.h +++ b/src/qgsdataprovider.h @@ -36,17 +36,8 @@ public: */ virtual ~QgsDataProvider() {}; - /** - * 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. - * - */ - virtual void select(QgsRect *mbr, bool useIntersect=false)=0; + + /** * Set the data source specification. This may be a path or database * connection string @@ -94,14 +85,7 @@ public: { // NOP by default } - /** - * Update the feature count based on current spatial filter. If not - * overridden in the data provider this function returns -1 - */ - virtual long updateFeatureCount() - { - return -1; - } + /** * Update the extents of the layer. Not implemented by default */ diff --git a/src/qgsmaplayer.h b/src/qgsmaplayer.h index 528f7eb1b98..805a9e6ce36 100644 --- a/src/qgsmaplayer.h +++ b/src/qgsmaplayer.h @@ -38,6 +38,7 @@ class QgsLegendItem; class QDomNode; class QDomDocument; class QEvent; +class QgsCoordinateTransform; /** \class QgsMapLayer * \brief Base class for all map layer types. @@ -347,12 +348,14 @@ signals: protected: + /** Used to ask the layer for its projection as a WKT string. Must be reimplemented by each provider. */ + virtual QString getProjectionWKT() = 0 ; + /** called by readXML(), used by children to read state specific to them from project files. */ virtual bool readXML_( QDomNode & layer_node ); - /** called by writeXML(), used by children to write state specific to them to project files. */ @@ -428,6 +431,9 @@ private: // Private attributes //! Tag for embedding additional information QString tag; + //! A QgsCoordinateTransform is used for on the fly reprojection of map layers + QgsCoordinateTransform * gCoordinateTransfrom; + /** true if visible ? */ bool m_visible; diff --git a/src/qgsrasterlayer.h b/src/qgsrasterlayer.h index 174524285f4..47f8373358d 100644 --- a/src/qgsrasterlayer.h +++ b/src/qgsrasterlayer.h @@ -353,6 +353,8 @@ public: /** \brief The destuctor. */ ~QgsRasterLayer(); + /** \brief Query gdal to find out the WKT projection string for this layer. This implements the virtual method of the same name defined in QgsMapLayer*/ + QString getProjectionWKT() { return QString (gdalDataset->GetProjectionRef());}; /** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */ void drawThumbnail(QPixmap * theQPixmap); diff --git a/src/qgsvectordataprovider.h b/src/qgsvectordataprovider.h index f5ab7cbb03b..af73e6364fe 100644 --- a/src/qgsvectordataprovider.h +++ b/src/qgsvectordataprovider.h @@ -26,7 +26,25 @@ class QgsVectorDataProvider: public QgsDataProvider QgsVectorDataProvider(); virtual ~QgsVectorDataProvider() {}; - + /** + * 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. + * + */ + virtual void select(QgsRect *mbr, bool useIntersect=false)=0; + /** + * Update the feature count based on current spatial filter. If not + * overridden in the data provider this function returns -1 + */ + virtual long updateFeatureCount() + { + return -1; + } /** * Get the first feature resulting from a select operation * @return QgsFeature diff --git a/src/qgsvectorlayer.h b/src/qgsvectorlayer.h index c56d4995df5..29a770993e9 100644 --- a/src/qgsvectorlayer.h +++ b/src/qgsvectorlayer.h @@ -25,7 +25,7 @@ class QLibrary; class QgsMapToPixel; class OGRLayer; class OGRDataSource; -class QgsDataProvider; +class QgsData; class QgsRenderer; class QgsLegendItem; class QgsDlgVectorLayerProperties; @@ -93,7 +93,12 @@ class QgsVectorLayer : public QgsMapLayer QgsVectorDataProvider * getDataProvider(); - + /** \brief Query gdal to find out the WKT projection string for this layer. This implements the virtual method of the same name defined in QgsMapLayer*/ + QString getProjectionWKT() + { + //delegate to data provider... + }; + QgsLabel *label(); QgsAttributeAction* actions() { return &mActions; }