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