Skip to content
Permalink
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: http://svn.osgeo.org/qgis/trunk/qgis@5588 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 13, 2006
1 parent 7db2c8f commit cdbd98fa9952324cecf2629078415079afe58608
Showing with 22 additions and 1 deletion.
  1. +6 −0 src/gui/qgisapp.cpp
  2. +16 −1 src/providers/ogr/qgsogrprovider.cpp
@@ -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).
QFile::remove(filename);

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;
break;
case QGis::WKBLineString:
OGRvectortype = wkbLineString;
break;
case QGis::WKBPolygon:
OGRvectortype = wkbPolygon;
break;
}

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.