Browse Source

Add Rast_get_window(), Rast_get_{input,output}_window()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40773 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 15 years ago
parent
commit
635b3d4627
2 changed files with 50 additions and 4 deletions
  1. 7 4
      include/rasterdefs.h
  2. 43 0
      lib/raster/window.c

+ 7 - 4
include/rasterdefs.h

@@ -524,16 +524,19 @@ void Rast_set_output_window(struct Cell_head *);
 void Rast_set_input_window(struct Cell_head *);
 
 /* window.c */
-double Rast_northing_to_row(double, const struct Cell_head *);
-double Rast_easting_to_col(double, const struct Cell_head *);
-double Rast_row_to_northing(double, const struct Cell_head *);
-double Rast_col_to_easting(double, const struct Cell_head *);
+void Rast_get_window(struct Cell_head *);
+void Rast_get_input_window(struct Cell_head *);
+void Rast_get_output_window(struct Cell_head *);
 int Rast_window_rows(void);
 int Rast_window_cols(void);
 int Rast_input_window_rows(void);
 int Rast_input_window_cols(void);
 int Rast_output_window_rows(void);
 int Rast_output_window_cols(void);
+double Rast_northing_to_row(double, const struct Cell_head *);
+double Rast_easting_to_col(double, const struct Cell_head *);
+double Rast_row_to_northing(double, const struct Cell_head *);
+double Rast_col_to_easting(double, const struct Cell_head *);
 
 /* window_map.c */
 void Rast__create_window_mapping(int);

+ 43 - 0
lib/raster/window.c

@@ -5,6 +5,49 @@
 #include "R.h"
 
 /*!
+ * \brief Read the current window
+ *
+ * \param window pointer to Cell_head
+ */
+
+void Rast_get_window(struct Cell_head *window)
+{
+    Rast__init_window();
+
+    if (R__.split_window)
+	G_fatal_error(_("Internal error: Rast_get_window() called with split window."
+			"Use Rast_get_input_window() or Rast_get_output_window() instead."));
+
+    *window = R__.wr_window;
+}
+
+/*!
+ * \brief Read the current input window
+ *
+ * \param window pointer to Cell_head
+ */
+
+void Rast_get_input_window(struct Cell_head *window)
+{
+    Rast__init_window();
+
+    *window = R__.rd_window;
+}
+
+/*!
+ * \brief Read the current output window
+ *
+ * \param window pointer to Cell_head
+ */
+
+void Rast_get_output_window(struct Cell_head *window)
+{
+    Rast__init_window();
+
+    *window = R__.wr_window;
+}
+
+/*!
  * \brief Number of rows in active window.
  *
  * This routine returns the number of rows in the active module window.