Skip to content
Permalink
Browse files

fix #2154 again:

- ogr provider doesn't create shapefiles without .shp extension anymore (OGR
  used to create a subdirectory in that case)
- automatically add .shp extension when using the new vector layer dialog



git-svn-id: http://svn.osgeo.org/qgis/trunk@12290 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 29, 2009
1 parent b8e86e2 commit acde244399ccc5980bd5b840a78febd01a689fc6
Showing with 22 additions and 4 deletions.
  1. +13 −1 src/app/qgisapp.cpp
  2. +9 −3 src/providers/ogr/qgsogrprovider.cpp
@@ -138,6 +138,8 @@
#include "qgsvectorlayer.h"
#include "ogr/qgsopenvectorlayerdialog.h"
#include "qgsattributetabledialog.h"
#include "qgsvectorfilewriter.h"

//
// Gdal/Ogr includes
//
@@ -3272,7 +3274,17 @@ void QgisApp::newVectorLayer()
// file, which can cause problems (e.g., if the file contains
// linestrings, but we're wanting to create points, we'll end up
// with a linestring file).
QFile::remove( fileName );
if ( fileformat == "ESRI Shapefile" )
{
if ( !fileName.endsWith( ".shp", Qt::CaseInsensitive ) )
fileName += ".shp";

QgsVectorFileWriter::deleteShapeFile( fileName );
}
else
{
QFile::remove( fileName );
}

settings.setValue( "/UI/lastVectorFileFilter", openFileDialog->selectedFilter() );

@@ -1445,14 +1445,15 @@ QGISEXTERN bool isProvider()
@param vectortype point/line/polygon or multitypes
@param attributes a list of name/type pairs for the initial attributes
@return true in case of success*/
QGISEXTERN bool createEmptyDataSource( const QString& uri,
const QString& format,
const QString& encoding,
QGISEXTERN bool createEmptyDataSource( const QString &uri,
const QString &format,
const QString &encoding,
QGis::WkbType vectortype,
const std::list<std::pair<QString, QString> > &attributes,
const QgsCoordinateReferenceSystem *srs = NULL )
{
QgsDebugMsg( QString( "Creating empty vector layer with format: %1" ).arg( format ) );

OGRSFDriverH driver;
QgsApplication::registerOgrDrivers();
driver = OGRGetDriverByName( format.toAscii() );
@@ -1465,6 +1466,11 @@ QGISEXTERN bool createEmptyDataSource( const QString& uri,

if ( driverName == "ESRI Shapefile" )
{
if ( !uri.endsWith( ".shp", Qt::CaseInsensitive ) )
{
return false;
}

// check for duplicate fieldnames
QSet<QString> fieldNames;
std::list<std::pair<QString, QString> >::const_iterator fldIt;

0 comments on commit acde244

Please sign in to comment.
You can’t perform that action at this time.