@@ -33,6 +33,7 @@ extern "C" {
33
33
#include < unistd.h>
34
34
#include < grass/gis.h>
35
35
#include < grass/Vect.h>
36
+ #include < grass/version.h>
36
37
}
37
38
38
39
void QgsGrass::init ( void )
@@ -643,6 +644,43 @@ QStringList QgsGrass::elements ( QString mapsetPath, QString element )
643
644
return list;
644
645
}
645
646
647
+ QString QgsGrass::regionString ( struct Cell_head *window )
648
+ {
649
+ QString reg;
650
+ int fmt;
651
+ char buf[1024 ];
652
+
653
+ fmt = window->proj ;
654
+
655
+ // TODO 3D
656
+
657
+ reg = " proj:" + QString::number (window->proj ) + " ;" ;
658
+ reg += " zone:" + QString::number (window->zone ) + " ;" ;
659
+
660
+ G_format_northing (window->north ,buf,fmt);
661
+ reg += " north:" + QString (buf) + " ;" ;
662
+
663
+ G_format_northing (window->south ,buf,fmt);
664
+ reg += " south:" + QString (buf) + " ;" ;
665
+
666
+ G_format_easting (window->east ,buf,fmt);
667
+ reg += " east:" + QString (buf) + " ;" ;
668
+
669
+ G_format_easting (window->west ,buf,fmt);
670
+ reg += " west:" + QString (buf) + " ;" ;
671
+
672
+ reg += " cols:" + QString::number (window->cols ) + " ;" ;
673
+ reg += " rows:" + QString::number (window->rows ) + " ;" ;
674
+
675
+ G_format_resolution (window->ew_res ,buf,fmt);
676
+ reg += " e-w resol:" + QString (buf) + " ;" ;
677
+
678
+ G_format_resolution (window->ns_res ,buf,fmt);
679
+ reg += " n-s resol:" + QString (buf) + " ;" ;
680
+
681
+ return reg;
682
+ }
683
+
646
684
bool QgsGrass::region ( QString gisbase,
647
685
QString location, QString mapset,
648
686
struct Cell_head *window )
@@ -656,6 +694,66 @@ bool QgsGrass::region( QString gisbase,
656
694
return true ;
657
695
}
658
696
697
+ bool QgsGrass::writeRegion ( QString gisbase,
698
+ QString location, QString mapset,
699
+ struct Cell_head *window )
700
+ {
701
+ std::cerr << " QgsGrass::writeRegion()" << std::endl;
702
+ std::cerr << " n = " << window->north << " s = " << window->south << std::endl;
703
+ std::cerr << " e = " << window->east << " w = " << window->west << std::endl;
704
+
705
+ QgsGrass::setMapset ( gisbase, location, mapset );
706
+
707
+ if ( G_put_window (window) == -1 ) {
708
+ return false ;
709
+ }
710
+
711
+ return true ;
712
+ }
713
+
714
+ void QgsGrass::copyRegionExtent ( struct Cell_head *source,
715
+ struct Cell_head *target )
716
+ {
717
+ target->north = source->north ;
718
+ target->south = source->south ;
719
+ target->east = source->east ;
720
+ target->west = source->west ;
721
+ target->top = source->top ;
722
+ target->bottom = source->bottom ;
723
+ }
724
+
725
+ void QgsGrass::copyRegionResolution ( struct Cell_head *source,
726
+ struct Cell_head *target )
727
+ {
728
+ target->ns_res = source->ns_res ;
729
+ target->ew_res = source->ew_res ;
730
+ target->tb_res = source->tb_res ;
731
+ target->ns_res3 = source->ns_res3 ;
732
+ target->ew_res3 = source->ew_res3 ;
733
+ }
734
+
735
+ void QgsGrass::extendRegion ( struct Cell_head *source,
736
+ struct Cell_head *target )
737
+ {
738
+ if ( source->north > target->north )
739
+ target->north = source->north ;
740
+
741
+ if ( source->south < target->south )
742
+ target->south = source->south ;
743
+
744
+ if ( source->east > target->east )
745
+ target->east = source->east ;
746
+
747
+ if ( source->west < target->west )
748
+ target->west = source->west ;
749
+
750
+ if ( source->top > target->top )
751
+ target->top = source->top ;
752
+
753
+ if ( source->bottom < target->bottom )
754
+ target->bottom = source->bottom ;
755
+ }
756
+
659
757
bool QgsGrass::mapRegion ( int type, QString gisbase,
660
758
QString location, QString mapset, QString map,
661
759
struct Cell_head *window )
@@ -735,3 +833,13 @@ bool QgsGrass::mapRegion( int type, QString gisbase,
735
833
return true ;
736
834
}
737
835
836
+ int QgsGrass::versionMajor ()
837
+ {
838
+ return QString (GRASS_VERSION_MAJOR).toInt ();
839
+ }
840
+ int QgsGrass::versionMinor ()
841
+ {
842
+ return QString (GRASS_VERSION_MINOR).toInt ();
843
+ }
844
+
845
+
0 commit comments