mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
minor update -- point layers displayed (no repaint)
git-svn-id: http://svn.osgeo.org/qgis/trunk@20 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d374346cb2
commit
91036becad
@ -33,6 +33,7 @@
|
||||
#include <iomanip>
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsdbsourceselect.h"
|
||||
#include "qgsdatabaselayer.h"
|
||||
#include "qgisapp.h"
|
||||
#include "qgisicons.h"
|
||||
|
||||
@ -74,11 +75,15 @@ void QgisApp::addLayer(){
|
||||
QString connInfo = dbs->connInfo();
|
||||
// for each selected table, connect to the datbase, parse the WKT geometry,
|
||||
// and build a cavnasitem for it
|
||||
readWKB(connInfo);
|
||||
// readWKB(connInfo,tables);
|
||||
QStringList::Iterator it = tables.begin();
|
||||
while( it != tables.end() ) {
|
||||
|
||||
|
||||
|
||||
// create the layer
|
||||
QgsDatabaseLayer *lyr = new QgsDatabaseLayer(connInfo, *it);
|
||||
// add it to the mapcanvas collection
|
||||
mapCanvas->addLayer(lyr);
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
@ -114,7 +119,7 @@ void QgisApp::zoomOut()
|
||||
|
||||
|
||||
}
|
||||
void QgisApp::readWKB(const char *connInfo){
|
||||
void QgisApp::readWKB(const char *connInfo, QStringList tables){
|
||||
PgCursor pgc(connInfo, "testcursor");
|
||||
// get "endianness"
|
||||
char *chkEndian = new char[4];
|
||||
@ -127,8 +132,11 @@ void QgisApp::readWKB(const char *connInfo){
|
||||
else
|
||||
cout << "Little endian" << endl;
|
||||
*/
|
||||
QStringList::Iterator it = tables.begin();
|
||||
while( it != tables.end() ) {
|
||||
|
||||
// get the extent of the layer
|
||||
QString esql = "select extent(the_geom) from towns";
|
||||
QString esql = "select extent(the_geom) from " + *it;
|
||||
PgDatabase *pd = new PgDatabase(connInfo);
|
||||
int result = pd->ExecTuplesOk((const char *)esql);
|
||||
QString extent = pd->GetValue(0,0);
|
||||
@ -163,7 +171,8 @@ void QgisApp::readWKB(const char *connInfo){
|
||||
sql += "'NDR'";
|
||||
else
|
||||
sql += "'XDR'";
|
||||
sql += ") as features from towns";
|
||||
sql += ") as features from ";
|
||||
sql += *it++;
|
||||
cout << sql.c_str() << endl;
|
||||
pgc.Declare(sql.c_str(), true);
|
||||
int res = pgc.Fetch();
|
||||
@ -188,11 +197,7 @@ void QgisApp::readWKB(const char *connInfo){
|
||||
char *feature = new char[pgc.GetLength(idx,0) +1];
|
||||
memset(feature,'\0',pgc.GetLength(idx,0) +1);
|
||||
memcpy(feature,pgc.GetValue(idx,0),pgc.GetLength(idx,0) );
|
||||
char endian;
|
||||
endian = *feature;
|
||||
int *geotype;
|
||||
geotype =(int *) (feature + 1);
|
||||
|
||||
|
||||
|
||||
cout << "Endian is: " << (int)feature[0] << endl;
|
||||
cout << "Geometry type is: " << (int)feature[1] << endl;
|
||||
@ -207,6 +212,7 @@ void QgisApp::readWKB(const char *connInfo){
|
||||
delete[] feature;
|
||||
}
|
||||
paint.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
class QCanvas;
|
||||
class QRect;
|
||||
class QCanvasView;
|
||||
class QStringList;
|
||||
#include "qgisappbase.h"
|
||||
/**
|
||||
*@author Gary E.Sherman
|
||||
@ -36,7 +37,7 @@ public:
|
||||
void fileExit();
|
||||
void zoomOut();
|
||||
void zoomIn();
|
||||
void readWKB(const char *);
|
||||
void readWKB(const char *, QStringList tables);
|
||||
void drawPoint(double x, double y);
|
||||
private:
|
||||
//QCanvasView *cv;
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include <qstring.h>
|
||||
#include "qgsdatabaselayer.h"
|
||||
|
||||
QgsDatabaseLayer::QgsDatabaseLayer(){
|
||||
dataSource = "foo";
|
||||
QgsDatabaseLayer::QgsDatabaseLayer(const char *conninfo, QString table) :
|
||||
QgsMapLayer(QgsMapLayer::DATABASE, table), tableName(table){
|
||||
dataSource = conninfo;
|
||||
}
|
||||
QgsDatabaseLayer::~QgsDatabaseLayer(){
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#ifndef QGSDATABASELAYER_H
|
||||
#define QGSDATABASELAYER_H
|
||||
|
||||
class QString;
|
||||
#include "qgsmaplayer.h"
|
||||
|
||||
/**
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
class QgsDatabaseLayer : public QgsMapLayer {
|
||||
public:
|
||||
QgsDatabaseLayer();
|
||||
QgsDatabaseLayer(const char *conninfo=0, QString table=QString::null);
|
||||
~QgsDatabaseLayer();
|
||||
private:
|
||||
|
||||
|
@ -76,6 +76,7 @@ void QgsDbSourceSelect::dbConnect(){
|
||||
// get the list of tables
|
||||
QString sql = "select * from geometry_columns where f_table_schema ='"
|
||||
+ settings.readEntry(key+"/database") + "'";
|
||||
sql += " order by f_table_name";
|
||||
qDebug("Fetching tables using: " + sql);
|
||||
int result = pd->ExecTuplesOk((const char *)sql);
|
||||
if(result){
|
||||
|
@ -22,3 +22,6 @@ QgsMapCanvas::QgsMapCanvas(QWidget *parent, const char *name ) : QWidget(parent,
|
||||
}
|
||||
QgsMapCanvas::~QgsMapCanvas(){
|
||||
}
|
||||
void QgsMapCanvas::addLayer(QgsMapLayer *lyr){
|
||||
layers[lyr->name()] = *lyr;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class QgsMapCanvas : public QWidget {
|
||||
public:
|
||||
QgsMapCanvas(QWidget *parent=0, const char *name=0);
|
||||
~QgsMapCanvas();
|
||||
void addLayer(QgsMapLayer *lyr);
|
||||
private:
|
||||
//! map containing the layers by name
|
||||
map<QString,QgsMapLayer> layers;
|
||||
|
@ -17,11 +17,13 @@
|
||||
|
||||
#include "qgsmaplayer.h"
|
||||
|
||||
QgsMapLayer::QgsMapLayer( ) : QgsDataSource() {
|
||||
QgsMapLayer::QgsMapLayer(int type, QString lyrname )
|
||||
: QgsDataSource(), layerType(type), layerName(lyrname)
|
||||
{
|
||||
}
|
||||
QgsMapLayer::~QgsMapLayer(){
|
||||
}
|
||||
const int QgsMapLayer::getlayerType(){
|
||||
const int QgsMapLayer::type(){
|
||||
return layerType;
|
||||
}
|
||||
/** Write property of QString layerName. */
|
||||
@ -29,7 +31,7 @@ void QgsMapLayer::setlayerName( const QString& _newVal){
|
||||
layerName = _newVal;
|
||||
}
|
||||
/** Read property of QString layerName. */
|
||||
const QString QgsMapLayer::getlayerName(){
|
||||
const QString QgsMapLayer::name(){
|
||||
return layerName;
|
||||
}
|
||||
|
||||
|
@ -27,20 +27,21 @@
|
||||
class QgsMapLayer : public QgsDataSource {
|
||||
|
||||
public:
|
||||
QgsMapLayer();
|
||||
QgsMapLayer(int type=0, QString lyrname=QString::null );
|
||||
virtual ~QgsMapLayer();
|
||||
/** Read property of int layerType. */
|
||||
const int getlayerType();
|
||||
const int type();
|
||||
/** Write property of QString layerName. */
|
||||
void setlayerName( const QString& _newVal);
|
||||
/** Read property of QString layerName. */
|
||||
const QString getlayerName();
|
||||
const QString name();
|
||||
|
||||
|
||||
public: // Public attributes
|
||||
enum LAYERS {
|
||||
VECTOR,
|
||||
RASTER
|
||||
RASTER,
|
||||
DATABASE
|
||||
} ;
|
||||
|
||||
private: // Private attributes
|
||||
|
Loading…
x
Reference in New Issue
Block a user