Skip to content
Permalink
Browse files
fix #2761
git-svn-id: http://svn.osgeo.org/qgis/trunk@13589 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 29, 2010
1 parent c410f69 commit 731c5b591ac0d3c2446e76a34c363ace7e47abd5
Showing with 18 additions and 8 deletions.
  1. +18 −8 src/core/qgsvectorfilewriter.cpp
@@ -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;
@@ -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;
@@ -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 ) )
{

0 comments on commit 731c5b5

Please sign in to comment.