[GRASS-SVN] r44522 -
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 2 09:22:50 EST 2010
Author: mmetz
Date: 2010-12-02 06:22:50 -0800 (Thu, 02 Dec 2010)
New Revision: 44522
Modified:
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/README
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/exec.c
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/local_proto.h
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/main.c
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/readcell.c
grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/rectify.c
Log:
fix memory handling and update README
Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/README
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/README 2010-12-02 14:20:26 UTC (rev 44521)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/README 2010-12-02 14:22:50 UTC (rev 44522)
@@ -4,14 +4,10 @@
- have changed elev reading from CELL to raster_type to support
also FP elevations
-
-Bugs:
- - somewhere the map_type is undefined in an underlying function (can't
- identify), so I added G_suppress_warnings(1) at top of rectify.c
- -> the module works well
+12/2010: Markus Metz
- - when DEBUG3 is activated, the module silently stops in exec.c at
- select_current_env() (line 87). Why???
- However, not a real bug. Seems to be a problem of exit status or
- whatever.
+ - sync'ed to i.rectify as far as possible
+ - the module is now non-interactive and stand-alone:
+ typing i.photo.rectify on the commandline pops up a gui if GRASS is started with a gui
+ - i.ortho.photo has a new interactive part to set the options for i.photo.rectify
Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/exec.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/exec.c 2010-12-02 14:20:26 UTC (rev 44521)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/exec.c 2010-12-02 14:22:50 UTC (rev 44522)
@@ -112,7 +112,7 @@
G_free(result);
}
close(ebuffer->fd);
- G_free(ebuffer);
+ release_cache(ebuffer);
G_done_msg(" ");
Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/local_proto.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/local_proto.h 2010-12-02 14:20:26 UTC (rev 44521)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/local_proto.h 2010-12-02 14:22:50 UTC (rev 44522)
@@ -30,6 +30,7 @@
/* readcell.c */
struct cache *readcell(int, int, int);
block *get_block(struct cache *, int);
+void release_cache(struct cache *);
/* report.c */
int report(long, int);
Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/main.c 2010-12-02 14:20:26 UTC (rev 44521)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/main.c 2010-12-02 14:22:50 UTC (rev 44522)
@@ -108,7 +108,7 @@
mem->type = TYPE_DOUBLE;
mem->key_desc = "memory in MB";
mem->required = NO;
- mem->answer = "300";
+ mem->answer = "100";
mem->description = _("Amount of memory to use in MB");
ipolname = make_ipol_list();
@@ -238,7 +238,7 @@
get_target(group.name);
/* Check the GRASS_OVERWRITE environment variable */
- if ((overstr = getenv("GRASS_OVERWRITE")))
+ if ((overstr = getenv("GRASS_OVERWRITE"))) /* OK ? */
target_overwrite = atoi(overstr);
if (!target_overwrite) {
@@ -302,7 +302,7 @@
/* determine memory for elevation and imagery */
seg_mb_img = seg_mb_elev = -1;
- if (!seg_mb) {
+ if (seg_mb) {
int max_rows, max_cols;
int nx, ny;
double max_mb_img, max_mb_elev;
@@ -310,7 +310,7 @@
max_rows = max_cols = 0;
for (i = 0; i < group.group_ref.nfiles; i++) {
- if (!ref_list[i]) {
+ if (ref_list[i]) {
G_get_cellhd(group.group_ref.file[i].name,
group.group_ref.file[i].mapset, &cellhd);
if (max_rows < cellhd.rows)
@@ -331,8 +331,8 @@
max_mb_elev = ((double)nx * ny * sizeof(block)) / (1<<20);
if ((seg_mb_total = atoi(seg_mb)) > 0) {
- seg_mb_elev = seg_mb_total * max_mb_elev / (max_mb_img + max_mb_elev);
- seg_mb_img = seg_mb_total * max_mb_img / (max_mb_img + max_mb_elev);
+ seg_mb_elev = max_mb_elev * (seg_mb_total / (max_mb_img + max_mb_elev)) + 0.5;
+ seg_mb_img = max_mb_img * (seg_mb_total / (max_mb_img + max_mb_elev)) + 0.5;
}
}
Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/readcell.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/readcell.c 2010-12-02 14:20:26 UTC (rev 44521)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/readcell.c 2010-12-02 14:22:50 UTC (rev 44522)
@@ -24,9 +24,19 @@
int nblocks;
int i;
+ if (target_env)
+ select_target_env();
+ else
+ select_current_env();
+
nrows = G_window_rows();
ncols = G_window_cols();
+ /* Temporary file must be created in the same location/mapset
+ * where the module was called */
+ if (target_env)
+ select_current_env();
+
ny = (nrows + BDIM - 1) / BDIM;
nx = (ncols + BDIM - 1) / BDIM;
@@ -46,11 +56,7 @@
c->refs = (int *)G_malloc(nblocks * sizeof(int));
if (nblocks < nx * ny) {
- /* Temporary file must be created in input location/mapset */
- select_current_env();
filename = G_tempfile();
- if (target_env)
- select_target_env();
c->fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
if (c->fd < 0)
G_fatal_error(_("Unable to open temporary file"));
@@ -58,6 +64,8 @@
}
else
c->fd = -1;
+
+ G_debug(1, "%d of %d blocks in memory", nblocks, nx * ny);
G_important_message(_("Allocating memory and reading input map..."));
G_percent(0, nrows, 5);
@@ -67,6 +75,8 @@
tmpbuf = (DCELL *) G_malloc(nx * sizeof(block));
+ if (target_env)
+ select_target_env();
for (row = 0; row < nrows; row += BDIM) {
int x, y;
@@ -127,7 +137,17 @@
G_fatal_error(_("Error seeking on segment file"));
if (read(c->fd, p, sizeof(block)) < 0)
- G_fatal_error(_("Error writing segment file"));
+ G_fatal_error(_("Error reading segment file"));
return p;
}
+
+void release_cache(struct cache *c)
+{
+ G_free(c->refs);
+ G_free(c->blocks);
+ G_free(c->grid);
+
+ G_free(c);
+ c = NULL;
+}
Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/rectify.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/rectify.c 2010-12-02 14:20:26 UTC (rev 44521)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/i.photo.rectify/rectify.c 2010-12-02 14:22:50 UTC (rev 44522)
@@ -116,7 +116,7 @@
G_free(trast);
close(ibuffer->fd);
- G_free(ibuffer);
+ release_cache(ibuffer);
if (G_get_cellhd(result, G_mapset(), &cellhd) < 0)
return 0;
More information about the grass-commit
mailing list