mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
add support for where option of v.in.ogr, fixes #836
git-svn-id: http://svn.osgeo.org/qgis/trunk@7705 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
4be22d583c
commit
569d12dba2
@ -2,8 +2,8 @@
|
||||
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
|
||||
|
||||
<qgisgrassmodule label=" v.in.ogr - Import OGR/PostGIS vector layer and create a fitted location" module="v.in.ogr">
|
||||
<ogr key="dsn" layeroption="layer" label="OGR vector layer" />
|
||||
<ogr key="dsn" layeroption="layer" whereoption="where" label="OGR vector layer" />
|
||||
<option key="output" />
|
||||
<option key="location" />
|
||||
<flag key="e" answer="on" hidden="yes" />
|
||||
</qgisgrassmodule>
|
||||
</qgisgrassmodule>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">
|
||||
|
||||
<qgisgrassmodule label="v.in.ogr - Import OGR/PostGIS vector layer" module="v.in.ogr">
|
||||
<ogr key="dsn" layeroption="layer" label="OGR vector layer" />
|
||||
<ogr key="dsn" layeroption="layer" whereoption="where" label="OGR vector layer" />
|
||||
<option key="output" />
|
||||
<flag key="o" answer="on" hidden="yes" />
|
||||
</qgisgrassmodule>
|
||||
|
@ -79,6 +79,7 @@
|
||||
extern "C" {
|
||||
#include <grass/gis.h>
|
||||
#include <grass/Vect.h>
|
||||
// #include <grass/version.h>
|
||||
}
|
||||
|
||||
|
||||
@ -2483,7 +2484,7 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput (
|
||||
QDomElement &gdesc, QDomNode &gnode, QWidget * parent)
|
||||
: Q3GroupBox ( 1, Qt::Vertical, parent ),
|
||||
QgsGrassModuleItem ( module, key, qdesc, gdesc, gnode ),
|
||||
mType(type), mOgrLayerOption(0)
|
||||
mType(type), mOgrLayerOption(0), mOgrWhereOption(0)
|
||||
{
|
||||
QString tit;
|
||||
if ( mDescription.isEmpty() )
|
||||
@ -2521,6 +2522,17 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput (
|
||||
}
|
||||
}
|
||||
|
||||
// Read "whereoption" if defined
|
||||
opt = qdesc.attribute("whereoption");
|
||||
if( !opt.isNull() ) {
|
||||
QDomNode optNode = QgsGrassModule::nodeByKey ( gdesc, opt );
|
||||
if( optNode.isNull() ) {
|
||||
QMessageBox::warning( 0, tr("Warning"), tr("Cannot find whereoption ") + opt );
|
||||
} else {
|
||||
mOgrWhereOption = opt;
|
||||
}
|
||||
}
|
||||
|
||||
mLayerComboBox = new QComboBox ( this );
|
||||
|
||||
// Of course, activated(int) is not enough, but there is no signal
|
||||
@ -2564,12 +2576,15 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
|
||||
|
||||
QString uri;
|
||||
QString ogrLayer;
|
||||
QString ogrWhere;
|
||||
if ( vector->providerType() == "postgres" )
|
||||
{
|
||||
// Construct OGR DSN
|
||||
QgsDataSourceURI dsUri(provider->dataSourceUri());
|
||||
uri = "PG:" + dsUri.connInfo();
|
||||
// which OGR/GRASS combo actually supports schemas?
|
||||
ogrLayer = dsUri.table();
|
||||
ogrWhere = dsUri.sql();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2586,6 +2601,7 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
|
||||
mUri.push_back ( uri );
|
||||
|
||||
mOgrLayers.push_back ( ogrLayer );
|
||||
mOgrWheres.push_back ( ogrWhere );
|
||||
}
|
||||
else if ( mType == Gdal && layer->type() == QgsMapLayer::RASTER )
|
||||
{
|
||||
@ -2617,7 +2633,8 @@ QStringList QgsGrassModuleGdalInput::options()
|
||||
if ( !mOgrLayerOption.isNull() && mOgrLayers[current].length() > 0 )
|
||||
{
|
||||
opt = mOgrLayerOption + "=";
|
||||
#if GDAL_VERSION_NUM >= 1400 //need to check for GRASS >= 6.2 here too...
|
||||
// which OGR/GRASS version actually supports schemas?
|
||||
#if 1 // GDAL_VERSION_NUM >= 1400 && (GRASS_VERSION_MAJOR>6 || (GRASS_VERSION_MAJOR==6 && GRASS_VERSION_MINOR>=2))
|
||||
opt += mOgrLayers[current];
|
||||
#else
|
||||
// Handle older versions of gdal gracefully
|
||||
@ -2640,6 +2657,10 @@ QStringList QgsGrassModuleGdalInput::options()
|
||||
}
|
||||
#endif //GDAL_VERSION_NUM
|
||||
list.push_back( opt );
|
||||
|
||||
if( !mOgrWhereOption.isNull() && mOgrWheres[current].length()>0 ) {
|
||||
list.push_back( mOgrWhereOption + "=" + mOgrWheres[current] );
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -620,6 +620,9 @@ private:
|
||||
|
||||
//! Ogr layer option associated with this input
|
||||
QString mOgrLayerOption;
|
||||
|
||||
//! Ogr sql option associated with this input
|
||||
QString mOgrWhereOption;
|
||||
|
||||
//! Combobox for QGIS layers
|
||||
QComboBox *mLayerComboBox;
|
||||
@ -629,6 +632,9 @@ private:
|
||||
|
||||
//! Ogr layer options
|
||||
std::vector<QString> mOgrLayers;
|
||||
|
||||
//! Ogr where clauses
|
||||
std::vector<QString> mOgrWheres;
|
||||
};
|
||||
|
||||
/*********************** QgsGrassModuleField **********************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user