Skip to content
Permalink
Browse files

build topology if not available -usually after crash in edit

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5090 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 24, 2006
1 parent 0f2f171 commit 3f239c9cbd74268b665c71fea846200efccbed8d
Showing with 40 additions and 1 deletion.
  1. +40 −1 src/providers/grass/qgsgrassprovider.cpp
@@ -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

0 comments on commit 3f239c9

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