Skip to content

Commit a95aa6c

Browse files
author
jef
committedDec 6, 2009
fix #2201
git-svn-id: http://svn.osgeo.org/qgis/trunk@12341 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3e5d66d commit a95aa6c

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed
 

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ email : sherman at mrcc.com
1919
#include "qgsogrprovider.h"
2020
#include "qgslogger.h"
2121

22-
#include <iostream>
23-
#include <cassert>
24-
2522
#define CPL_SUPRESS_CPLUSPLUS
2623
#include <gdal.h> // to collect version information
2724
#include <ogr_api.h>
@@ -81,43 +78,41 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
8178
// If there is no & in the uri, then the uri is just the filename. The loaded
8279
// layer will be layer 0.
8380
//this is not true for geojson
84-
if ( ! uri.contains( '|', Qt::CaseSensitive ) )
81+
if ( !uri.contains( '|', Qt::CaseSensitive ) )
8582
{
8683
mFilePath = uri;
8784
mLayerIndex = 0;
8885
mLayerName = QString::null;
8986
}
9087
else
9188
{
92-
// If we get here, there are some options added to the filename. We must parse
93-
// the different parts separated by &, and among each option, the name and the
94-
// value around the =.
95-
// A valid uri is of the form: filename&option1=value1&option2=value2,...
96-
9789
QStringList theURIParts = uri.split( "|" );
9890
mFilePath = theURIParts.at( 0 );
9991

10092
for ( int i = 1 ; i < theURIParts.size(); i++ )
10193
{
102-
QStringList theInstruction = theURIParts.at( i ).split( "=" );
103-
if ( theInstruction.at( 0 ) == QString( "layerid" ) )
94+
QString part = theURIParts.at( i );
95+
int pos = part.indexOf( "=" );
96+
QString field = part.left( pos );
97+
QString value = part.mid( pos + 1 );
98+
99+
if ( field == "layerid" )
104100
{
105101
bool ok;
106-
mLayerIndex = theInstruction.at( 1 ).toInt( &ok );
102+
mLayerIndex = value.toInt( &ok );
107103
if ( ! ok )
108104
{
109105
mLayerIndex = -1;
110106
}
111107
}
112-
113-
if ( theInstruction.at( 0 ) == QString( "layername" ) )
108+
else if ( field == "layername" )
114109
{
115-
mLayerName = theInstruction.at( 1 );
110+
mLayerName = value;
116111
}
117112

118-
if ( theInstruction.at( 0 ) == QString( "subset" ) )
113+
if ( field == "subset" )
119114
{
120-
mSubsetString = theInstruction.at( 1 );
115+
mSubsetString = value;
121116
}
122117
}
123118
}
@@ -126,7 +121,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
126121
QgsDebugMsg( "mLayerIndex: " + QString::number( mLayerIndex ) );
127122
QgsDebugMsg( "mLayerName: " + mLayerName );
128123
QgsDebugMsg( "mSubsetString: " + mSubsetString );
129-
CPLSetConfigOption("OGR_ORGANIZE_POLYGONS", "SKIP");
124+
CPLSetConfigOption( "OGR_ORGANIZE_POLYGONS", "SKIP" );
130125
CPLPushErrorHandler( CPLQuietErrorHandler );
131126
ogrDataSource = OGROpen( QFile::encodeName( mFilePath ).constData(), TRUE, &ogrDriver );
132127
CPLPopErrorHandler();
@@ -245,6 +240,7 @@ bool QgsOgrProvider::setSubsetString( QString theSQL )
245240
{
246241
uri += QString( "|subset=%1" ).arg( mSubsetString );
247242
}
243+
248244
setDataSourceUri( uri );
249245

250246
OGR_L_ResetReading( ogrLayer );

0 commit comments

Comments
 (0)
Please sign in to comment.