Skip to content

Commit

Permalink
build topology if not available -usually after crash in edit
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@5090 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 24, 2006
1 parent 7ad0663 commit 12528c5
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/providers/grass/qgsgrassprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,15 +1041,54 @@ int QgsGrassProvider::openMap(QString gisdbase, QString location, QString mapset
di.setFile ( gisdbase + "/" + location + "/" + mapset + "/vector/" + mapName + "/dbln" );
map.lastAttributesModified = di.lastModified();

// Do we have topology and cidx (level2)
int level = 2;
QgsGrass::resetError();
Vect_set_open_level (2);
Vect_open_old_head ( map.map, (char *) mapName.ascii(), (char *) mapset.ascii());
if ( QgsGrass::getError() == QgsGrass::FATAL ) {
std::cerr << "Cannot open GRASS vector head on level2: "
<< QgsGrass::getErrorMessage().toLocal8Bit().data() << std::endl;
level = 1;
}
else
{
Vect_close ( map.map );
}

if ( level == 1 )
{
int ret = QMessageBox::question ( 0, "Warning",
"GRASS vector map " + mapName +
+ " does not have topology. Build topology?",
QMessageBox::Yes, QMessageBox::No );

if ( ret == QMessageBox::No ) return -1;
}

// Open vector
QgsGrass::resetError(); // to "catch" error after Vect_open_old()
Vect_set_open_level (2);
Vect_set_open_level (level);
Vect_open_old ( map.map, (char *) mapName.ascii(), (char *) mapset.ascii());

if ( QgsGrass::getError() == QgsGrass::FATAL ) {
std::cerr << "Cannot open GRASS vector: " << QgsGrass::getErrorMessage().toLocal8Bit().data() << std::endl;
return -1;
}

if ( level == 1 )
{
QgsGrass::resetError();
Vect_build ( map.map, stderr );

if ( QgsGrass::getError() == QgsGrass::FATAL ) {
std::cerr << "Cannot build topology: "
<< QgsGrass::getErrorMessage().toLocal8Bit().data()
<< std::endl;
return -1;
}
}

#ifdef QGISDEBUG
std::cerr << "GRASS map successfully opened" << std::endl;
#endif
Expand Down

0 comments on commit 12528c5

Please sign in to comment.