Skip to content
Permalink
Browse files

read current region

git-svn-id: http://svn.osgeo.org/qgis/trunk@5079 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Mar 23, 2006
1 parent 25e5d0e commit 75709b948c8e737147a3307fad89ab06bb39b27d
Showing with 37 additions and 1 deletion.
  1. +32 −1 src/providers/grass/qgsgrass.cpp
  2. +5 −0 src/providers/grass/qgsgrass.h
@@ -643,13 +643,27 @@ QStringList QgsGrass::elements ( QString mapsetPath, QString element )
return list;
}

bool QgsGrass::region( QString gisbase,
QString location, QString mapset,
struct Cell_head *window )
{
QgsGrass::setLocation( gisbase, location );

if ( G__get_window ( window, "", "WIND", mapset.toLocal8Bit().data() ) )
{
return false;
}
return true;
}

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;
std::cerr << "map = " << map.toLocal8Bit().data() << std::endl;
std::cerr << "mapset = " << mapset.toLocal8Bit().data() << std::endl;
#endif

QgsGrass::setLocation( gisbase, location );
@@ -667,7 +681,8 @@ bool QgsGrass::mapRegion( int type, QString gisbase,
}
else if ( type == Vector )
{
G_get_window ( window ); // get current resolution
// Get current projection
region( gisbase, location, mapset, window );

struct Map_info Map;

@@ -687,6 +702,22 @@ bool QgsGrass::mapRegion( int type, QString gisbase,
window->south = box.S;
window->west = box.W;
window->east = box.E;
window->top = box.T;
window->bottom = box.B;

// Is this optimal ?
window->ns_res = (window->north-window->south)/1000;
window->ew_res = window->ns_res;
if ( window->top > window->bottom )
{
window->tb_res = (window->top-window->bottom)/10;
}
else
{
window->top = window->bottom + 1;
window->tb_res = 1;
}
G_adjust_Cell_head3 ( window, 0, 0, 0 );

Vect_close (&Map);
}
@@ -118,6 +118,11 @@ class QgsGrass {
QString location, QString mapset, QString map,
struct Cell_head *window );

// ! Read current mapset region
static bool QgsGrass::region( QString gisbase,
QString location, QString mapset,
struct Cell_head *window );

static void init (void);

private:

0 comments on commit 75709b9

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