Skip to content
Permalink
Browse files
pepare for G_is_gisbase, G_is_location, G_is_mapset, G_list
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5487 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed May 24, 2006
1 parent de1fb26 commit d6ac833c194cf580a76eb13fd599291eaf17d20e
Showing with 92 additions and 7 deletions.
  1. +89 −7 src/providers/grass/qgsgrass.cpp
  2. +3 −0 src/providers/grass/qgsgrass.h
@@ -188,17 +188,26 @@ void QgsGrass::init( void )
*/
bool QgsGrass::isValidGrassBaseDir(QString const gisBase)
{
std::cerr << "isValidGrassBaseDir()" << std::endl;
if ( gisBase.isEmpty() )
{
return FALSE;
}

QFileInfo gbi ( gisBase + "/etc/element_list" );
if ( gbi.exists() ) {
return TRUE;
} else {
return FALSE;
}

/* TODO: G_is_gisbase() was added to GRASS 6.1 06-05-24,
enable its use after some period (others do update) */
/*
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
{
if ( G_is_gisbase( gisBase.toLocal8Bit().constData() ) ) return TRUE;
}
else
{
*/
QFileInfo gbi ( gisBase + "/etc/element_list" );
if ( gbi.exists() ) return TRUE;
//}
return FALSE;
}

bool QgsGrass::activeMode( void )
@@ -566,9 +575,37 @@ QStringList QgsGrass::mapsets ( QString locationPath )
QStringList QgsGrass::vectors ( QString gisbase, QString locationName,
QString mapsetName)
{
std::cerr << "QgsGrass::vectors()" << std::endl;

if ( gisbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() )
return QStringList();

/* TODO: G_list() was added to GRASS 6.1 06-05-24,
enable its use after some period (others do update) */
/*
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
{
QStringList list;
char **glist = G_list( G_ELEMENT_VECTOR,
gisbase.toLocal8Bit().constData(),
locationName.toLocal8Bit().constData(),
mapsetName.toLocal8Bit().constData() );
int i = 0;
while ( glist[i] )
{
list.append( QString(glist[i]) );
i++;
}
G_free_list ( glist );
return list;
}
*/

return QgsGrass::vectors ( gisbase + "/" + locationName + "/" + mapsetName );
}

@@ -602,9 +639,38 @@ QStringList QgsGrass::vectors ( QString mapsetPath )
QStringList QgsGrass::rasters ( QString gisbase, QString locationName,
QString mapsetName)
{
std::cerr << "QgsGrass::rasters()" << std::endl;

if ( gisbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() )
return QStringList();


/* TODO: G_list() was added to GRASS 6.1 06-05-24,
enable its use after some period (others do update) */
/*
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
{
QStringList list;
char **glist = G_list( G_ELEMENT_RASTER,
gisbase.toLocal8Bit().constData(),
locationName.toLocal8Bit().constData(),
mapsetName.toLocal8Bit().constData() );
int i = 0;
while ( glist[i] )
{
list.append( QString(glist[i]) );
i++;
}
G_free_list ( glist );
return list;
}
*/

return QgsGrass::rasters ( gisbase + "/" + locationName + "/" + mapsetName );
}

@@ -858,4 +924,20 @@ int QgsGrass::versionMinor()
return QString(GRASS_VERSION_MINOR).toInt();
}

bool QgsGrass::isMapset ( QString path )
{
/* TODO: G_is_mapset() was added to GRASS 6.1 06-05-24,
enable its use after some period (others do update) */
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
{
if ( G_is_mapset( path.toLocal8Bit().constData() ) ) return true;
}
else
{
QString windf = path + "/WIND";
if ( QFile::exists ( windf ) ) return true;
}

return false;
}

@@ -145,6 +145,9 @@ class QgsGrass {

static void init (void);

// ! test if the directory is mapset
static bool isMapset ( QString path );

//! Library version
static int QgsGrass::versionMajor();
static int QgsGrass::versionMinor();

0 comments on commit d6ac833

Please sign in to comment.