Skip to content
Browse files
Bug fixes:
- Put in an explicit conversion from Qgis layer type enum to
  OGR layer type enum when creating a new layer

- When creating a new vector layer, and the user selected an existing
 file, delete that file. This was causing a problem when the new layer
 type was different to the selected layer type because the selected
 layer type was being used.

git-svn-id: c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 13, 2006
1 parent 7db2c8f commit cdbd98fa9952324cecf2629078415079afe58608
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
@@ -2430,6 +2430,12 @@ void QgisApp::newVectorLayer()
filename = openFileDialog->selectedFile();
enc = openFileDialog->encoding();

// If the file exists, delete it otherwise we'll end up loading that
// 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).

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

settings.writeEntry("/UI/lastVectorFileFilterDir", openFileDialog->directory().absolutePath());
@@ -1535,8 +1535,23 @@ const std::list<std::pair<QString, QString> >& attributes)
reference = new OGRSpatialReference(myWKT.toLocal8Bit().data());

// Map the qgis geometry type to the OGR geometry type
OGRwkbGeometryType OGRvectortype = wkbUnknown;
switch (vectortype)
case QGis::WKBPoint:
OGRvectortype = wkbPoint;
case QGis::WKBLineString:
OGRvectortype = wkbLineString;
case QGis::WKBPolygon:
OGRvectortype = wkbPolygon;

OGRLayer* layer;
layer = dataSource->CreateLayer(QFileInfo(uri).baseName(), reference, (OGRwkbGeometryType)vectortype, NULL);
layer = dataSource->CreateLayer(QFileInfo(uri).baseName(), reference, OGRvectortype, NULL);
if(layer == NULL)
return false;

0 comments on commit cdbd98f

Please sign in to comment.