Skip to content

Commit 05af397

Browse files
author
rblazek
committed
read current region
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5079 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8c698ef commit 05af397

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/providers/grass/qgsgrass.cpp

+32-1
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,27 @@ QStringList QgsGrass::elements ( QString mapsetPath, QString element )
643643
return list;
644644
}
645645

646+
bool QgsGrass::region( QString gisbase,
647+
QString location, QString mapset,
648+
struct Cell_head *window )
649+
{
650+
QgsGrass::setLocation( gisbase, location );
651+
652+
if ( G__get_window ( window, "", "WIND", mapset.toLocal8Bit().data() ) )
653+
{
654+
return false;
655+
}
656+
return true;
657+
}
646658

647659
bool QgsGrass::mapRegion( int type, QString gisbase,
648660
QString location, QString mapset, QString map,
649661
struct Cell_head *window )
650662
{
651663
#ifdef QGISDEBUG
652664
std::cerr << "QgsGrass::mapRegion()" << std::endl;
665+
std::cerr << "map = " << map.toLocal8Bit().data() << std::endl;
666+
std::cerr << "mapset = " << mapset.toLocal8Bit().data() << std::endl;
653667
#endif
654668

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

672687
struct Map_info Map;
673688

@@ -687,6 +702,22 @@ bool QgsGrass::mapRegion( int type, QString gisbase,
687702
window->south = box.S;
688703
window->west = box.W;
689704
window->east = box.E;
705+
window->top = box.T;
706+
window->bottom = box.B;
707+
708+
// Is this optimal ?
709+
window->ns_res = (window->north-window->south)/1000;
710+
window->ew_res = window->ns_res;
711+
if ( window->top > window->bottom )
712+
{
713+
window->tb_res = (window->top-window->bottom)/10;
714+
}
715+
else
716+
{
717+
window->top = window->bottom + 1;
718+
window->tb_res = 1;
719+
}
720+
G_adjust_Cell_head3 ( window, 0, 0, 0 );
690721

691722
Vect_close (&Map);
692723
}

src/providers/grass/qgsgrass.h

+5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ class QgsGrass {
118118
QString location, QString mapset, QString map,
119119
struct Cell_head *window );
120120

121+
// ! Read current mapset region
122+
static bool QgsGrass::region( QString gisbase,
123+
QString location, QString mapset,
124+
struct Cell_head *window );
125+
121126
static void init (void);
122127

123128
private:

0 commit comments

Comments
 (0)