@@ -643,13 +643,27 @@ QStringList QgsGrass::elements ( QString mapsetPath, QString element )
643
643
return list;
644
644
}
645
645
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
+ }
646
658
647
659
bool QgsGrass::mapRegion ( int type, QString gisbase,
648
660
QString location, QString mapset, QString map,
649
661
struct Cell_head *window )
650
662
{
651
663
#ifdef QGISDEBUG
652
664
std::cerr << " QgsGrass::mapRegion()" << std::endl;
665
+ std::cerr << " map = " << map.toLocal8Bit ().data () << std::endl;
666
+ std::cerr << " mapset = " << mapset.toLocal8Bit ().data () << std::endl;
653
667
#endif
654
668
655
669
QgsGrass::setLocation ( gisbase, location );
@@ -667,7 +681,8 @@ bool QgsGrass::mapRegion( int type, QString gisbase,
667
681
}
668
682
else if ( type == Vector )
669
683
{
670
- G_get_window ( window ); // get current resolution
684
+ // Get current projection
685
+ region ( gisbase, location, mapset, window );
671
686
672
687
struct Map_info Map;
673
688
@@ -687,6 +702,22 @@ bool QgsGrass::mapRegion( int type, QString gisbase,
687
702
window->south = box.S ;
688
703
window->west = box.W ;
689
704
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 );
690
721
691
722
Vect_close (&Map);
692
723
}
0 commit comments