Skip to content

Commit

Permalink
Bug fixes:
Browse files Browse the repository at this point in the history
- 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@5588 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 13, 2006
1 parent 53bd594 commit afff4af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/gui/qgisapp.cpp
Expand Up @@ -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());
Expand Down
17 changes: 16 additions & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit afff4af

Please sign in to comment.