mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
get map region moved to grass lib
git-svn-id: http://svn.osgeo.org/qgis/trunk@5077 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
a4b8dfa04c
commit
9be967c944
@ -25,13 +25,14 @@
|
||||
#include "qdir.h"
|
||||
#include "qtextstream.h"
|
||||
#include "qsettings.h"
|
||||
|
||||
//#include "qgsapplication.h"
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include "qgsgrass.h"
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
#include <grass/gis.h>
|
||||
#include <grass/Vect.h>
|
||||
}
|
||||
|
||||
void QgsGrass::init( void )
|
||||
@ -641,3 +642,65 @@ QStringList QgsGrass::elements ( QString mapsetPath, QString element )
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
bool QgsGrass::mapRegion( int type, QString gisbase,
|
||||
QString location, QString mapset, QString map,
|
||||
struct Cell_head *window )
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "QgsGrass::mapRegion()" << std::endl;
|
||||
#endif
|
||||
|
||||
QgsGrass::setLocation( gisbase, location );
|
||||
|
||||
if ( type == Raster )
|
||||
{
|
||||
|
||||
if ( G_get_cellhd ( map.toLocal8Bit().data(),
|
||||
mapset.toLocal8Bit().data(), window) < 0 )
|
||||
{
|
||||
QMessageBox::warning( 0, "Warning",
|
||||
"Cannot read raster map region" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( type == Vector )
|
||||
{
|
||||
G_get_window ( window ); // get current resolution
|
||||
|
||||
struct Map_info Map;
|
||||
|
||||
int level = Vect_open_old_head ( &Map,
|
||||
map.toLocal8Bit().data(), mapset.toLocal8Bit().data());
|
||||
|
||||
if ( level < 2 )
|
||||
{
|
||||
QMessageBox::warning( 0, "Warning",
|
||||
"Cannot read vector map region" );
|
||||
return false;
|
||||
}
|
||||
|
||||
BOUND_BOX box;
|
||||
Vect_get_map_box (&Map, &box );
|
||||
window->north = box.N;
|
||||
window->south = box.S;
|
||||
window->west = box.W;
|
||||
window->east = box.E;
|
||||
|
||||
Vect_close (&Map);
|
||||
}
|
||||
else if ( type == Region )
|
||||
{
|
||||
if ( G__get_window (window, "windows",
|
||||
map.toLocal8Bit().data(),
|
||||
mapset.toLocal8Bit().data() ) != NULL )
|
||||
{
|
||||
QMessageBox::warning( 0, "Warning",
|
||||
"Cannot read region" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,9 @@ public:
|
||||
FATAL /*!< Fatal error. Function faild. */
|
||||
};
|
||||
|
||||
//! Map type
|
||||
enum MapType { Raster, Vector, Region };
|
||||
|
||||
//! Reset error code (to OK). Call this before a piece of code where an error is expected
|
||||
static void resetError ( void ); // reset error status
|
||||
|
||||
@ -110,6 +113,10 @@ public:
|
||||
QString mapsetName, QString element);
|
||||
static QStringList elements(QString mapsetPath, QString element);
|
||||
|
||||
// ! Get map region
|
||||
static bool QgsGrass::mapRegion( int type, QString gisbase,
|
||||
QString location, QString mapset, QString map,
|
||||
struct Cell_head *window );
|
||||
|
||||
static void init (void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user