[QGIS Commit] r15354 - trunk/qgis/src/providers/ogr
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Mar 5 21:20:51 EST 2011
Author: jef
Date: 2011-03-05 18:20:51 -0800 (Sat, 05 Mar 2011)
New Revision: 15354
Modified:
trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
Log:
ogr provider: use utf8 also for SQL statements with GDAL 1.8
Modified: trunk/qgis/src/providers/ogr/qgsogrprovider.cpp
===================================================================
--- trunk/qgis/src/providers/ogr/qgsogrprovider.cpp 2011-03-06 02:19:47 UTC (rev 15353)
+++ trunk/qgis/src/providers/ogr/qgsogrprovider.cpp 2011-03-06 02:20:51 UTC (rev 15354)
@@ -246,7 +246,7 @@
.arg( quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ) ) )
.arg( mSubsetString );
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
- ogrLayer = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).constData(), NULL, NULL );
+ ogrLayer = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, NULL );
if ( !ogrLayer )
{
@@ -921,7 +921,7 @@
continue;
}
- OGRFieldDefnH fielddefn = OGR_Fld_Create( mEncoding->fromUnicode( iter->name() ).data(), type );
+ OGRFieldDefnH fielddefn = OGR_Fld_Create( TO8( iter->name() ), type );
OGR_Fld_SetWidth( fielddefn, iter->length() );
OGR_Fld_SetPrecision( fielddefn, iter->precision() );
@@ -1074,7 +1074,7 @@
QString sql = QString( "CREATE SPATIAL INDEX ON %1" ).arg( quotedIdentifier( layerName ) ); // quote the layer name so spaces are handled
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
- OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" );
+ OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" );
QFileInfo fi( mFilePath ); // to get the base name
//find out, if the .qix file is there
@@ -1087,8 +1087,8 @@
QString layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) );
QString dropSql = QString( "DROP INDEX ON %1" ).arg( quotedIdentifier( layerName ) );
QString createSql = QString( "CREATE INDEX ON %1 USING %2" ).arg( quotedIdentifier( layerName ) ).arg( fields()[field].name() );
- OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( dropSql ).data(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
- OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( createSql ).data(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
+ OGR_DS_ExecuteSQL( ogrDataSource, TO8( dropSql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
+ OGR_DS_ExecuteSQL( ogrDataSource, TO8( createSql ), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
QFileInfo fi( mFilePath ); // to get the base name
//find out, if the .idm file is there
@@ -1118,7 +1118,7 @@
QString sql = QString( "REPACK %1" ).arg( layerName ); // don't quote the layer name as it works with spaces in the name and won't work if the name is quoted
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
- OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, NULL );
+ OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, NULL );
recalculateFeatureCount();
@@ -1747,7 +1747,7 @@
if ( precision < 0 )
precision = 3;
- field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTReal );
+ field = OGR_Fld_Create( TO8( it->first ), OFTReal );
OGR_Fld_SetWidth( field, width );
OGR_Fld_SetPrecision( field, precision );
}
@@ -1756,7 +1756,7 @@
if ( width < 0 || width > 10 )
width = 10;
- field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTInteger );
+ field = OGR_Fld_Create( TO8( it->first ), OFTInteger );
// limit to 10. otherwise OGR sets it to 11 and recognizes as OFTDouble later
OGR_Fld_SetWidth( field, width );
}
@@ -1765,7 +1765,7 @@
if ( width < 0 || width > 255 )
width = 255;
- field = OGR_Fld_Create( codec->fromUnicode( it->first ).data(), OFTString );
+ field = OGR_Fld_Create( TO8( it->first ), OFTString );
OGR_Fld_SetWidth( field, width );
}
else
@@ -1880,10 +1880,10 @@
sql += QString( " WHERE %1" ).arg( mSubsetString );
}
- sql += QString( " ORDER BY %1" ).arg( fld.name() );
+ sql += QString( " ORDER BY %1" ).arg( quotedIdentifier( fld.name() ) );
QgsDebugMsg( QString( "SQL: %1" ).arg( sql ) );
- OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" );
+ OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
if ( l == 0 )
return QgsVectorDataProvider::uniqueValues( index, uniqueValues, limit );
@@ -1914,7 +1914,7 @@
sql += QString( " WHERE %1" ).arg( mSubsetString );
}
- OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" );
+ OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
if ( l == 0 )
return QgsVectorDataProvider::minimumValue( index );
@@ -1948,7 +1948,7 @@
sql += QString( " WHERE %1" ).arg( mSubsetString );
}
- OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, mEncoding->fromUnicode( sql ).data(), NULL, "SQL" );
+ OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, TO8( sql ), NULL, "SQL" );
if ( l == 0 )
return QgsVectorDataProvider::maximumValue( index );
More information about the QGIS-commit
mailing list