Skip to content

Commit

Permalink
fix #2761
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13589 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 29, 2010
1 parent 6af5b09 commit 497e345
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@
#include <cpl_error.h>


QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
const QString& fileEncoding,
const QgsFieldMap& fields,
QGis::WkbType geometryType,
const QgsCoordinateReferenceSystem* srs,
const QString& driverName )
: mDS( NULL ), mLayer( NULL ), mGeom( NULL ), mError( NoError )
QgsVectorFileWriter::QgsVectorFileWriter(
const QString &theVectorFileName,
const QString& fileEncoding,
const QgsFieldMap& fields,
QGis::WkbType geometryType,
const QgsCoordinateReferenceSystem* srs,
const QString& driverName )
: mDS( NULL )
, mLayer( NULL )
, mGeom( NULL )
, mError( NoError )
{
// save the layer as a shapefile
QString vectorFileName = theVectorFileName;

// find driver in OGR
OGRSFDriverH poDriver;
Expand All @@ -67,6 +71,11 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,

if ( driverName == "ESRI Shapefile" )
{
if ( !vectorFileName.endsWith( ".shp", Qt::CaseInsensitive ) )
{
vectorFileName += ".shp";
}

// check for unique fieldnames
QSet<QString> fieldNames;
QgsFieldMap::const_iterator fldIt;
Expand Down Expand Up @@ -129,6 +138,7 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
{
if ( driverName == "ESRI Shapefile" )
{
QString layerName = vectorFileName.left( vectorFileName.indexOf( ".shp", Qt::CaseInsensitive ) );
QFile prjFile( layerName + ".qpj" );
if ( prjFile.open( QIODevice::WriteOnly ) )
{
Expand Down

0 comments on commit 497e345

Please sign in to comment.