Skip to content
Permalink
Browse files
locations,mapsets,vectors and rasters lists
git-svn-id: http://svn.osgeo.org/qgis/trunk@4913 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 28, 2006
1 parent e9aec77 commit a7f6e7ae814648718639c1380d8bef6ceb944bfd
Showing with 142 additions and 0 deletions.
  1. +125 −0 src/providers/grass/qgsgrass.cpp
  2. +17 −0 src/providers/grass/qgsgrass.h
@@ -476,3 +476,128 @@ QString QgsGrass::closeMapset ( )

return NULL;
}

QStringList QgsGrass::locations ( QString gisbase )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrass::locations gisbase = "
<< gisbase.ascii() << std::endl;
#endif

QStringList list;

if ( gisbase.isEmpty() ) return list;

QDir d = QDir( gisbase );
d.setFilter(QDir::NoDotAndDotDot|QDir::Dirs);

for ( int i = 0; i < d.count(); i++ )
{
if ( QFile::exists ( gisbase + "/" + d[i]
+ "/PERMANENT/DEFAULT_WIND" ) )
{
list.append(QString(d[i]));
}
}
return list;
}

QStringList QgsGrass::mapsets ( QString gisbase, QString locationName )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrass::mapsets gisbase = " << gisbase.ascii()
<< " locationName = " << locationName.ascii() << std::endl;
#endif

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

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

QStringList QgsGrass::mapsets ( QString locationPath )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrass::mapsets locationPath = "
<< locationPath.ascii() << std::endl;
#endif

QStringList list;

if ( locationPath.isEmpty() ) return list;

QDir d = QDir( locationPath );
d.setFilter(QDir::NoDotAndDotDot|QDir::Dirs);

for ( int i = 0; i < d.count(); i++ )
{
if ( QFile::exists ( locationPath + "/" + d[i] + "/WIND" ) )
{
list.append(d[i]);
}
}
return list;
}

QStringList QgsGrass::vectors ( QString gisbase, QString locationName,
QString mapsetName)
{
if ( gisbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() )
return QStringList();

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

QStringList QgsGrass::vectors ( QString mapsetPath )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrass::vectors mapsetPath = "
<< mapsetPath.ascii() << std::endl;
#endif

QStringList list;

if ( mapsetPath.isEmpty() ) return list;

QDir d = QDir( mapsetPath + "/vector" );
d.setFilter(QDir::NoDotAndDotDot|QDir::Dirs);

for ( int i = 0; i < d.count(); i++ )
{
if ( QFile::exists ( mapsetPath + "/vector/" + d[i] + "/head" ) )
{
list.append(d[i]);
}
}
return list;
}

QStringList QgsGrass::rasters ( QString gisbase, QString locationName,
QString mapsetName)
{
if ( gisbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() )
return QStringList();

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

QStringList QgsGrass::rasters ( QString mapsetPath )
{
#ifdef QGISDEBUG
std::cerr << "QgsGrass::rasters mapsetPath = "
<< mapsetPath.ascii() << std::endl;
#endif

QStringList list;

if ( mapsetPath.isEmpty() ) return list;

QDir d = QDir( mapsetPath + "/cellhd" );
d.setFilter(QDir::Files);

for ( int i = 0; i < d.count(); i++ )
{
list.append(d[i]);
}
return list;
}
@@ -89,6 +89,23 @@ class QgsGrass {
//! Check if given directory contains a GRASS installation
static bool isValidGrassBaseDir(QString const gisBase);

//! Returns list of locations in given gisbase
static QStringList locations(QString gisbase);

//! Returns list of mapsets in location
static QStringList mapsets(QString gisbase, QString locationName);
static QStringList mapsets(QString locationPath);

//! List of vectors and rasters
static QStringList vectors(QString gisbase, QString locationName,
QString mapsetName);
static QStringList vectors(QString mapsetPath);

static QStringList rasters(QString gisbase, QString locationName,
QString mapsetName);
static QStringList rasters(QString mapsetPath);


static void init (void);

private:

0 comments on commit a7f6e7a

Please sign in to comment.