Skip to content

Commit

Permalink
read current region
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@5079 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 23, 2006
1 parent 25e5d0e commit 75709b9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/providers/grass/qgsgrass.cpp
Expand Up @@ -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 );
Expand All @@ -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;

Expand All @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions src/providers/grass/qgsgrass.h
Expand Up @@ -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:
Expand Down

0 comments on commit 75709b9

Please sign in to comment.