-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.osgeo.org/qgis/trunk@5021 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
rblazek
committed
Mar 15, 2006
1 parent
d0ee6c4
commit 6a5562e
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/******************************************************************* | ||
qgsgrassutils.cpp | ||
------------------- | ||
begin : March, 2006 | ||
copyright : (C) 2006 by Radim Blazek | ||
email : radim.blazek@gmail.com | ||
********************************************************************/ | ||
/******************************************************************** | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
*******************************************************************/ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <QApplication> | ||
|
||
//#include "qgis.h" | ||
//#include "qgsapplication.h" | ||
|
||
extern "C" { | ||
#include <grass/gis.h> | ||
#include <grass/Vect.h> | ||
} | ||
|
||
#include "../../src/providers/grass/qgsgrass.h" | ||
#include "qgsgrassutils.h" | ||
#include "qgsgrassselect.h" | ||
|
||
QgsGrassUtils::QgsGrassUtils() {} | ||
QgsGrassUtils::~QgsGrassUtils() {} | ||
|
||
QString QgsGrassUtils::vectorLayerName( QString map, QString layer, | ||
int nLayers ) | ||
{ | ||
QString name = map; | ||
if ( nLayers > 1 ) name += " " + layer; | ||
return name; | ||
} | ||
|
||
void QgsGrassUtils::addVectorLayers ( QgisIface *iface, | ||
QString gisbase, QString location, QString mapset, QString map) | ||
{ | ||
QStringList layers = QgsGrassSelect::vectorLayers( | ||
gisbase, location, mapset, map ); | ||
|
||
|
||
for ( int i = 0; i < layers.count(); i++ ) | ||
{ | ||
QString name = QgsGrassUtils::vectorLayerName ( | ||
map, layers[i], layers.size() ); | ||
|
||
QString uri = gisbase + "/" + location + "/" | ||
+ mapset + "/" + map + "/" + layers[i]; | ||
|
||
#ifdef QGISDEBUG | ||
std::cerr << "layer = " << layers[i].local8Bit().data() << std::endl; | ||
std::cerr << "uri = " << uri.local8Bit().data() << std::endl; | ||
std::cerr << "name = " << name.local8Bit().data() << std::endl; | ||
#endif | ||
|
||
iface->addVectorLayer( uri, name, "grass"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*************************************************************************** | ||
qgsgrassutils.h | ||
------------------- | ||
begin : March, 2006 | ||
copyright : (C) 2006 by Radim Blazek | ||
email : radim.blazek@gmail.com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSGRASSUTILS_H | ||
#define QGSGRASSUTILS_H | ||
|
||
#include "qgisiface.h" | ||
|
||
/*! \class QgsGrassUtils | ||
* \brief Various utilities. | ||
*/ | ||
class QgsGrassUtils | ||
{ | ||
|
||
public: | ||
//! Constructor | ||
QgsGrassUtils(); | ||
|
||
//! Destructor | ||
~QgsGrassUtils(); | ||
|
||
public: | ||
// Create vector name from map name, layer name and number of layers | ||
static QString vectorLayerName( QString map, QString layer, int nLayers ); | ||
|
||
// Add all vector layers to QGIS view | ||
static void QgsGrassUtils::addVectorLayers ( QgisIface *iface, | ||
QString gisbase, QString location, QString mapset, QString map); | ||
}; | ||
|
||
#endif // QGSGRASSUTILS_H |