[GRASS-SVN] r32804 - in grass/trunk: general/g.region imagery/i.fft
imagery/i.ifft imagery/i.zc include lib/db/dbmi_client
lib/db/dbmi_driver lib/db/stubs raster/r.flow raster/r.lake
raster/r.le/r.le.setup raster/r.out.mpeg raster/r.region
raster/r.sun raster/simwe/r.sim.sediment
raster/simwe/r.sim.water raster3d/base vector/v.in.ogr
vector/v.label.sa vector/v.surf.rst vector/v.vol.rst
visualization/xganim
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 16 02:02:01 EDT 2008
Author: glynn
Date: 2008-08-16 02:02:01 -0400 (Sat, 16 Aug 2008)
New Revision: 32804
Removed:
grass/trunk/lib/db/dbmi_client/c_begin_work.x
grass/trunk/lib/db/dbmi_driver/d_begin_work.x
grass/trunk/lib/db/stubs/begin_work.x
Modified:
grass/trunk/general/g.region/main.c
grass/trunk/imagery/i.fft/fftmain.c
grass/trunk/imagery/i.ifft/ifftmain.c
grass/trunk/imagery/i.zc/main.c
grass/trunk/include/G3d.h
grass/trunk/raster/r.flow/calc.c
grass/trunk/raster/r.lake/main.c
grass/trunk/raster/r.le/r.le.setup/main.c
grass/trunk/raster/r.out.mpeg/main.c
grass/trunk/raster/r.region/main.c
grass/trunk/raster/r.sun/main.c
grass/trunk/raster/simwe/r.sim.sediment/main.c
grass/trunk/raster/simwe/r.sim.water/main.c
grass/trunk/raster3d/base/r3.mask.main.c
grass/trunk/raster3d/base/r3.null.main.c
grass/trunk/vector/v.in.ogr/main.c
grass/trunk/vector/v.label.sa/main.c
grass/trunk/vector/v.surf.rst/main.c
grass/trunk/vector/v.vol.rst/main.c
grass/trunk/visualization/xganim/main.c
Log:
Keep option handling in main()
Don't query region, environment etc until G_parser() returns
Modified: grass/trunk/general/g.region/main.c
===================================================================
--- grass/trunk/general/g.region/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/general/g.region/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -24,7 +24,6 @@
static int nsew(char *, char *, char *, char *);
static void die(struct Option *);
-static char *llinfo(char *, char *, int);
int main(int argc, char *argv[])
{
@@ -39,7 +38,6 @@
char *name;
char *mapset;
char *err;
- int projection;
char **rast_ptr, **vect_ptr;
struct GModule *module;
@@ -63,12 +61,6 @@
G_gisinit(argv[0]);
- /* get current region.
- * if current region not valid, set it from default
- * note: G_get_default_window() dies upon error
- */
- G_get_default_window(&window);
-
module = G_define_module();
module->keywords = _("general");
module->description =
@@ -193,8 +185,7 @@
parm.north->required = NO;
parm.north->multiple = NO;
parm.north->type = TYPE_STRING;
- parm.north->description = llinfo(_("Value for the northern edge"),
- G_lat_format_string(), window.proj);
+ parm.north->description = _("Value for the northern edge");
parm.north->guisection = _("Bounds");
parm.south = G_define_option();
@@ -203,8 +194,7 @@
parm.south->required = NO;
parm.south->multiple = NO;
parm.south->type = TYPE_STRING;
- parm.south->description = llinfo(_("Value for the southern edge"),
- G_lat_format_string(), window.proj);
+ parm.south->description = _("Value for the southern edge");
parm.south->guisection = _("Bounds");
parm.east = G_define_option();
@@ -213,8 +203,7 @@
parm.east->required = NO;
parm.east->multiple = NO;
parm.east->type = TYPE_STRING;
- parm.east->description = llinfo(_("Value for the eastern edge"),
- G_lon_format_string(), window.proj);
+ parm.east->description = _("Value for the eastern edge");
parm.east->guisection = _("Bounds");
parm.west = G_define_option();
@@ -223,8 +212,7 @@
parm.west->required = NO;
parm.west->multiple = NO;
parm.west->type = TYPE_STRING;
- parm.west->description = llinfo(_("Value for the western edge"),
- G_lon_format_string(), window.proj);
+ parm.west->description = _("Value for the western edge");
parm.west->guisection = _("Bounds");
parm.top = G_define_option();
@@ -289,8 +277,7 @@
parm.nsres->required = NO;
parm.nsres->multiple = NO;
parm.nsres->type = TYPE_STRING;
- parm.nsres->description = llinfo(_("North-south grid resolution 2D"),
- G_llres_format_string(), window.proj);
+ parm.nsres->description = _("North-south grid resolution 2D");
parm.nsres->guisection = _("Resolution");
parm.ewres = G_define_option();
@@ -299,8 +286,7 @@
parm.ewres->required = NO;
parm.ewres->multiple = NO;
parm.ewres->type = TYPE_STRING;
- parm.ewres->description = llinfo(_("East-west grid resolution 2D"),
- G_llres_format_string(), window.proj);
+ parm.ewres->description = _("East-west grid resolution 2D");
parm.ewres->guisection = _("Resolution");
parm.tbres = G_define_option();
@@ -348,7 +334,7 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- projection = window.proj;
+ G_get_default_window(&window);
set_flag = !flag.update->answer;
@@ -842,13 +828,3 @@
return 0;
}
-static char *llinfo(char *msg, char *llformat, int proj)
-{
- char buf[256];
-
- if (proj != PROJECTION_LL)
- return msg;
-
- sprintf(buf, "%s (%s %s)", msg, _("format"), llformat);
- return G_store(buf);
-}
Modified: grass/trunk/imagery/i.fft/fftmain.c
===================================================================
--- grass/trunk/imagery/i.fft/fftmain.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/imagery/i.fft/fftmain.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -63,11 +63,9 @@
int save_args(); /* function to stash the command line arguments */
struct GModule *module;
struct Option *op1, *op2, *op3, *op4;
- const char *me;
int maskfd;
G_gisinit(argv[0]);
- me = G_program_name();
module = G_define_module();
module->keywords = _("imagery");
Modified: grass/trunk/imagery/i.ifft/ifftmain.c
===================================================================
--- grass/trunk/imagery/i.ifft/ifftmain.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/imagery/i.ifft/ifftmain.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -41,10 +41,8 @@
double *data[2]; /* Data structure containing real & complex values of FFT */
struct Option *op1, *op2, *op3;
struct GModule *module;
- const char *me;
G_gisinit(argv[0]);
- me = G_program_name();
/* Set description */
module = G_define_module();
@@ -87,8 +85,8 @@
/* open input raster map */
if ((realmapset = G_find_cell(Cellmap_real, "")) == NULL)
- G_fatal_error(_("%s: %s - Unable to find the real-image map."),
- me, Cellmap_real);
+ G_fatal_error(_("Unable to find the real-image map <%s>"),
+ Cellmap_real);
if ((realfp =
G_fopen_old_misc("cell_misc", "fftreal", Cellmap_real,
@@ -96,8 +94,8 @@
G_fatal_error(_("Unable to open real-image in the cell_misc directory.\nInput map probably wasn't created by i.fft"));
if ((imagmapset = G_find_cell(Cellmap_imag, "")) == NULL)
- G_fatal_error(_("%s: %s - Unable to find the imaginary-image."),
- me, Cellmap_imag);
+ G_fatal_error(_("Unable to find the imaginary-image <%s>"),
+ Cellmap_imag);
if ((imagfp =
G_fopen_old_misc("cell_misc", "fftimag", Cellmap_imag,
Modified: grass/trunk/imagery/i.zc/main.c
===================================================================
--- grass/trunk/imagery/i.zc/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/imagery/i.zc/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -45,10 +45,8 @@
double *data[2]; /* Data structure containing real & complex values of FFT */
struct GModule *module;
struct Option *input_map, *output_map, *width, *threshold, *orientations;
- const char *me;
G_gisinit(argv[0]);
- me = G_program_name();
module = G_define_module();
module->keywords = _("imagery");
Modified: grass/trunk/include/G3d.h
===================================================================
--- grass/trunk/include/G3d.h 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/include/G3d.h 2008-08-16 06:02:01 UTC (rev 32804)
@@ -414,6 +414,7 @@
void G3d_setNullValue(void *, int, int);
/* grass/src/libes/g3d/g3dopen2.c */
+void *G3d_openNewParam(const char *, int , int, G3D_Region *, int, int, int, int, int, int, int);
/* grass/src/libes/g3d/g3dopen.c */
void *G3d_openCellOldNoHeader(const char *, const char *);
void *G3d_openCellOld(const char *, const char *, G3D_Region *, int, int);
Deleted: grass/trunk/lib/db/dbmi_client/c_begin_work.x
===================================================================
--- grass/trunk/lib/db/dbmi_client/c_begin_work.x 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/lib/db/dbmi_client/c_begin_work.x 2008-08-16 06:02:01 UTC (rev 32804)
@@ -1,26 +0,0 @@
-#include "dbmi.h"
-#include "macros.h"
-
-db_begin_work (driver, result)
- dbDriver *driver;
- int *result;
-{
- int ret_code;
-
-/* start the procedure call */
- db__set_protocol_fds (driver->send, driver->recv);
- DB_START_PROCEDURE_CALL(DB_PROC_BEGIN_WORK);
-
-/* no args */
-
-/* get the return code for the procedure call */
- DB_RECV_RETURN_CODE(&ret_code);
-
- if (ret_code != DB_OK)
- return ret_code; /* ret_code SHOULD == DB_FAILED */
-
-/* results */
- DB_RECV_INT (result);
-
- return DB_OK;
-}
Deleted: grass/trunk/lib/db/dbmi_driver/d_begin_work.x
===================================================================
--- grass/trunk/lib/db/dbmi_driver/d_begin_work.x 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/lib/db/dbmi_driver/d_begin_work.x 2008-08-16 06:02:01 UTC (rev 32804)
@@ -1,57 +0,0 @@
-/*!
- * \file db/dbmi_driver/d_begin_work.c
- *
- * \brief DBMI Library (driver) - ?
- *
- * (C) 1999-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author Joel Jones (CERL/UIUC), Radim Blazek
- */
-
-#include "dbmi.h"
-#include "macros.h"
-
-/*!
- \brief ?
-
- \return DB_OK on success
- \return DB_FAILED on failure
-*/
-int db_d_begin_work(void)
-{
- int stat;
- int result;
-
-/* no arg(s) */
-
-/* get the driver state and see if a database is open */
- if (!db__test_database_open())
- {
- db_error ("no database is open");
- DB_SEND_FAILURE();
- return DB_OK;
- };
-/* make sure all cursors are closed */
-/*
- db__close_all_cursors();
-*/
-
-/* call the procedure */
- stat = db_driver_begin_work(&result);
-
-/* send the return code */
- if (stat != DB_OK)
- {
- DB_SEND_FAILURE();
- return DB_OK;
- }
- DB_SEND_SUCCESS();
-
-/* results */
- DB_SEND_INT (result);
- return DB_OK;
-}
Deleted: grass/trunk/lib/db/stubs/begin_work.x
===================================================================
--- grass/trunk/lib/db/stubs/begin_work.x 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/lib/db/stubs/begin_work.x 2008-08-16 06:02:01 UTC (rev 32804)
@@ -1,8 +0,0 @@
-#include "dbmi.h"
-
-db_driver_begin_work (result)
- int *result;
-{
- db_procedure_not_implemented("db_begin_work");
- return DB_FAILED;
-}
Modified: grass/trunk/raster/r.flow/calc.c
===================================================================
--- grass/trunk/raster/r.flow/calc.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/r.flow/calc.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -416,9 +416,6 @@
/* Initialize GIS engine */
G_gisinit(argv[0]);
- if (G_get_set_window(®ion) == -1)
- G_fatal_error(_("Unable to get current region"));
-
module = G_define_module();
module->keywords = "raster";
module->description =
@@ -426,35 +423,6 @@
"and flowline densities (upslope areas) from a raster "
"digital elevation model (DEM)");
- larger = ((region.cols < region.rows) ? region.rows : region.cols);
- default_skip = (larger < 50) ? 1 : (int)(larger / 50);
-
- default_skip_ans =
- G_calloc((int)log10((double)default_skip) + 2, sizeof(char));
- skip_opt = G_calloc((int)log10((double)larger) + 4, sizeof(char));
-
- sprintf(default_skip_ans, "%d", default_skip);
- sprintf(skip_opt, "1-%d", larger);
-
- default_bound = (int)(4. * hypot((double)region.rows,
- (double)region.cols));
- default_bound_ans =
- G_calloc((int)log10((double)default_bound) + 4, sizeof(char));
- sprintf(default_bound_ans, "0-%d", default_bound);
-
-#ifdef OFFSET
- /* below fix changed from 0.0 to 1.0 and its effect disabled in
- * calc.c, Helena June 2005 */
-
- default_offset = 1.0; /* fixed 20. May 2001 Helena */
- default_offset_ans =
- G_calloc((int)log10(default_offset) + 2, sizeof(char));
- sprintf(default_offset_ans, "%f", default_offset);
-
- offset_opt = G_calloc((int)log10(default_offset) + 4, sizeof(char));
- sprintf(offset_opt, "0.0-500.0");
-#endif
-
pelevin = G_define_option();
pelevin->key = "elevin";
pelevin->type = TYPE_STRING;
@@ -482,7 +450,6 @@
pskip->required = NO;
pskip->options = skip_opt;
pskip->description = _("Number of cells between flowlines");
- pskip->answer = default_skip_ans;
pbound = G_define_option();
pbound->key = "bound";
@@ -490,7 +457,6 @@
pbound->required = NO;
pbound->options = default_bound_ans;
pbound->description = _("Maximum number of segments per flowline");
- pbound->answer = default_bound_ans + 2;
pflout = G_define_option();
pflout->key = "flout";
@@ -529,6 +495,45 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+
+ if (G_get_set_window(®ion) == -1)
+ G_fatal_error(_("Unable to get current region"));
+
+ larger = ((region.cols < region.rows) ? region.rows : region.cols);
+ default_skip = (larger < 50) ? 1 : (int)(larger / 50);
+
+ default_skip_ans =
+ G_calloc((int)log10((double)default_skip) + 2, sizeof(char));
+ skip_opt = G_calloc((int)log10((double)larger) + 4, sizeof(char));
+
+ sprintf(default_skip_ans, "%d", default_skip);
+ sprintf(skip_opt, "1-%d", larger);
+
+ default_bound = (int)(4. * hypot((double)region.rows,
+ (double)region.cols));
+ default_bound_ans =
+ G_calloc((int)log10((double)default_bound) + 4, sizeof(char));
+ sprintf(default_bound_ans, "0-%d", default_bound);
+
+#ifdef OFFSET
+ /* below fix changed from 0.0 to 1.0 and its effect disabled in
+ * calc.c, Helena June 2005 */
+
+ default_offset = 1.0; /* fixed 20. May 2001 Helena */
+ default_offset_ans =
+ G_calloc((int)log10(default_offset) + 2, sizeof(char));
+ sprintf(default_offset_ans, "%f", default_offset);
+
+ offset_opt = G_calloc((int)log10(default_offset) + 4, sizeof(char));
+ sprintf(offset_opt, "0.0-500.0");
+#endif
+
+ if (!pskip->answer)
+ pskip->answer = default_skip_ans;
+
+ if (!pbound->answer)
+ pbound->answer = default_bound_ans + 2;
+
parm.elevin = pelevin->answer;
parm.aspin = paspin->answer;
parm.barin = pbarin->answer;
Modified: grass/trunk/raster/r.lake/main.c
===================================================================
--- grass/trunk/raster/r.lake/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/r.lake/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -144,6 +144,8 @@
struct Cell_head window;
struct History history;
+ G_gisinit(argv[0]);
+
module = G_define_module();
module->keywords = _("raster");
module->description = _("Fills lake from seed at given level.");
@@ -188,8 +190,6 @@
if (G_parser(argc, argv)) /* Returns 0 if successful, non-zero otherwise */
exit(EXIT_FAILURE);
- G_gisinit(argv[0]);
-
if (smap_opt->answer && sdxy_opt->answer)
G_fatal_error(_("Both seed map and coordinates cannot be specifed"));
Modified: grass/trunk/raster/r.le/r.le.setup/main.c
===================================================================
--- grass/trunk/raster/r.le/r.le.setup/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/r.le/r.le.setup/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -54,9 +54,6 @@
/* Initialize the GIS calls */
G_gisinit(argv[0]);
- /* must run in a term window */
- G_putenv("GRASS_UI_TERM", "1");
-
module = G_define_module();
module->keywords = _("raster");
module->description =
Modified: grass/trunk/raster/r.out.mpeg/main.c
===================================================================
--- grass/trunk/raster/r.out.mpeg/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/r.out.mpeg/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -54,8 +54,8 @@
/* global variables */
int nrows, ncols, numviews, quality, quiet = 0;
char *vfiles[MAXVIEWS][MAXIMAGES];
-char outfile[BUFSIZ];
-char encoder[15];
+char outfile[GPATH_MAX];
+const char *encoder;
float vscale, scale; /* resampling scale factors */
int irows, icols, vrows, vcols;
@@ -66,24 +66,93 @@
static int load_files(void);
static int use_r_out(void);
static char **gee_wildfiles(char *wildarg, char *element, int *num);
-static void parse_command(int argc, char *argv[],
- char *vfiles[MAXVIEWS][MAXIMAGES], int *numviews,
- int *numframes, int *quality, int *convert);
+static void parse_command(struct Option **viewopts,
+ char *vfiles[MAXVIEWS][MAXIMAGES],
+ int *numviews, int *numframes);
int main(int argc, char **argv)
{
- /* int i, j, d; */
+ struct GModule *module;
+ struct Option *viewopts[MAXVIEWS], *out, *qual;
+ struct Flag *qt, *conv;
+ int i;
int *sdimp, longdim, r_out;
G_gisinit(argv[0]);
- parse_command(argc, argv, vfiles, &numviews, &frames, &quality, &r_out);
+ module = G_define_module();
+ module->keywords = _("raster");
+ module->description = _("Raster File Series to MPEG Conversion Program.");
+
+ for (i = 0; i < MAXVIEWS; i++) {
+ char buf[BUFSIZ];
+ viewopts[i] = G_define_option();
+ sprintf(buf, "view%d", i + 1);
+ viewopts[i]->key = G_store(buf);
+ viewopts[i]->type = TYPE_STRING;
+ viewopts[i]->required = (i ? NO : YES);
+ viewopts[i]->multiple = YES;
+ viewopts[i]->gisprompt = "old,cell,Raster";
+ sprintf(buf, _("Raster file(s) for View%d"), i + 1);
+ viewopts[i]->description = G_store(buf);
+ }
+
+ out = G_define_option();
+ out->key = "output";
+ out->type = TYPE_STRING;
+ out->required = NO;
+ out->multiple = NO;
+ out->answer = "gmovie.mpg";
+ out->description = _("Name for output file");
+
+ qual = G_define_option();
+ qual->key = "qual";
+ qual->type = TYPE_INTEGER;
+ qual->required = NO;
+ qual->multiple = NO;
+ qual->answer = "3";
+ qual->options = "1-5";
+ qual->description =
+ _("Quality factor (1 = highest quality, lowest compression)");
+
+ qt = G_define_flag();
+ qt->key = 'q';
+ qt->description = _("Quiet - suppress progress report");
+
+ conv = G_define_flag();
+ conv->key = 'c';
+ conv->description =
+ _("Convert on the fly, use less disk space\n\t(requires r.out.ppm with stdout option)");
+
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+
+ parse_command(viewopts, vfiles, &numviews, &frames);
+
+ if (qt->answer)
+ quiet = 1;
+
+ r_out = 0;
+ if (conv->answer)
+ r_out = 1;
+
+ quality = 3;
+ if (qual->answer != NULL)
+ sscanf(qual->answer, "%d", &quality);
+ if (quality > 5 || quality < 1)
+ quality = 3;
+
+ if (out->answer)
+ strcpy(outfile, out->answer);
+ else
+ strcpy(outfile, "gmovie.mpg");
+
/* find a working encoder */
if (256 == G_system("ppmtompeg 2> /dev/null"))
- strcpy(encoder, "ppmtompeg");
+ encoder = "ppmtompeg";
else if (256 == G_system("mpeg_encode 2> /dev/null"))
- strcpy(encoder, "mpeg_encode");
+ encoder = "mpeg_encode";
else
G_fatal_error(_("Either mpeg_encode or ppmtompeg must be installed"));
@@ -358,90 +427,26 @@
/********************************************************************/
-static void parse_command(int argc, char *argv[],
- char *vfiles[MAXVIEWS][MAXIMAGES], int *numviews,
- int *numframes, int *quality, int *convert)
+static void parse_command(struct Option **viewopts,
+ char *vfiles[MAXVIEWS][MAXIMAGES],
+ int *numviews, int *numframes)
{
- struct GModule *module;
- struct Option *viewopts[MAXVIEWS], *out, *qual;
- struct Flag *qt, *conv;
- char buf[BUFSIZ], **wildfiles;
- int i, j, k, numi, wildnum;
+ int i, j, k;
- module = G_define_module();
- module->keywords = _("raster");
- module->description = _("Raster File Series to MPEG Conversion Program.");
-
*numviews = *numframes = 0;
- for (i = 0; i < MAXVIEWS; i++) {
- viewopts[i] = G_define_option();
- sprintf(buf, "view%d", i + 1);
- viewopts[i]->key = G_store(buf);
- viewopts[i]->type = TYPE_STRING;
- viewopts[i]->required = (i ? NO : YES);
- viewopts[i]->multiple = YES;
- viewopts[i]->gisprompt = "old,cell,Raster";
- sprintf(buf, _("Raster file(s) for View%d"), i + 1);
- viewopts[i]->description = G_store(buf);
- }
- out = G_define_option();
- out->key = "output";
- out->type = TYPE_STRING;
- out->required = NO;
- out->multiple = NO;
- out->answer = "gmovie.mpg";
- out->description = _("Name for output file");
-
- qual = G_define_option();
- qual->key = "qual";
- qual->type = TYPE_INTEGER;
- qual->required = NO;
- qual->multiple = NO;
- qual->answer = "3";
- qual->options = "1-5";
- qual->description =
- _("Quality factor (1 = highest quality, lowest compression)");
-
- qt = G_define_flag();
- qt->key = 'q';
- qt->description = _("Quiet - suppress progress report");
-
- conv = G_define_flag();
- conv->key = 'c';
- conv->description =
- _("Convert on the fly, use less disk space\n\t(requires r.out.ppm with stdout option)");
-
- if (G_parser(argc, argv))
- exit(EXIT_FAILURE);
-
- *convert = 0;
- if (qt->answer)
- quiet = 1;
- if (conv->answer)
- *convert = 1;
-
- *quality = 3;
- if (qual->answer != NULL)
- sscanf(qual->answer, "%d", quality);
- if (*quality > 5 || *quality < 1)
- *quality = 3;
-
- if (out->answer)
- strcpy(outfile, out->answer);
- else
- strcpy(outfile, "gmovie.mpg");
-
for (i = 0; i < MAXVIEWS; i++) {
if (viewopts[i]->answers) {
+ int numi, wildnum;
+
(*numviews)++;
for (j = 0, numi = 0; viewopts[i]->answers[j]; j++) {
if ((NULL != strchr(viewopts[i]->answers[j], '*')) ||
(NULL != strchr(viewopts[i]->answers[j], '?')) ||
(NULL != strchr(viewopts[i]->answers[j], '['))) {
- wildfiles = gee_wildfiles(viewopts[i]->answers[j],
- "cell", &wildnum);
+ char **wildfiles = gee_wildfiles(viewopts[i]->answers[j],
+ "cell", &wildnum);
for (k = 0; k < wildnum; k++)
vfiles[i][numi++] = wildfiles[k];
Modified: grass/trunk/raster/r.region/main.c
===================================================================
--- grass/trunk/raster/r.region/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/r.region/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -21,7 +21,6 @@
static int nsew(const char *, const char *, const char *, const char *);
static void die(struct Option *);
-static char *llinfo(const char *, const char *, int);
int main(int argc, char *argv[])
@@ -33,7 +32,6 @@
char *name;
char *mapset;
char *err;
- int projection;
struct GModule *module;
struct
@@ -55,10 +53,6 @@
module->description =
_("Sets the boundary definitions for a raster map.");
- G_get_window(&window);
-
- projection = window.proj;
-
/* flags */
flag.cur = G_define_flag();
@@ -118,9 +112,7 @@
parm.north->required = NO;
parm.north->multiple = NO;
parm.north->type = TYPE_STRING;
- parm.north->description =
- llinfo(_("Value for the northern edge"), G_lat_format_string(),
- window.proj);
+ parm.north->description = _("Value for the northern edge");
parm.south = G_define_option();
parm.south->key = "s";
@@ -128,9 +120,7 @@
parm.south->required = NO;
parm.south->multiple = NO;
parm.south->type = TYPE_STRING;
- parm.south->description =
- llinfo(_("Value for the southern edge"), G_lat_format_string(),
- window.proj);
+ parm.south->description = _("Value for the southern edge");
parm.east = G_define_option();
parm.east->key = "e";
@@ -138,9 +128,7 @@
parm.east->required = NO;
parm.east->multiple = NO;
parm.east->type = TYPE_STRING;
- parm.east->description =
- llinfo(_("Value for the eastern edge"), G_lon_format_string(),
- window.proj);
+ parm.east->description = _("Value for the eastern edge");
parm.west = G_define_option();
parm.west->key = "w";
@@ -148,9 +136,7 @@
parm.west->required = NO;
parm.west->multiple = NO;
parm.west->type = TYPE_STRING;
- parm.west->description =
- llinfo(_("Value for the western edge"), G_lon_format_string(),
- window.proj);
+ parm.west->description = _("Value for the western edge");
parm.align = G_define_option();
parm.align->key = "align";
@@ -163,6 +149,8 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ G_get_window(&window);
+
name = parm.map->answer;
mapset = G_find_cell2(name, "");
@@ -393,13 +381,3 @@
return 0;
}
-static char *llinfo(const char *msg, const char *llformat, int proj)
-{
- char buf[256];
-
- if (proj != PROJECTION_LL)
- return (char *)msg;
-
- sprintf(buf, "%s (format %s)", msg, llformat);
- return G_store(buf);
-}
Modified: grass/trunk/raster/r.sun/main.c
===================================================================
--- grass/trunk/raster/r.sun/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/r.sun/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -170,8 +170,8 @@
flag;
G_gisinit(argv[0]);
- module = G_define_module();
+ module = G_define_module();
module->keywords = _("raster");
module->label = _("Solar irradiance and irradiation model.");
module->description =
@@ -183,22 +183,6 @@
"incidence angle and/or irradiance raster maps. The shadowing effect of "
"the topography is optionally incorporated.");
- if (G_get_set_window(&cellhd) == -1)
- G_fatal_error("G_get_set_window() failed");
-
- stepx = cellhd.ew_res;
- stepy = cellhd.ns_res;
- invstepx = 1. / stepx;
- invstepy = 1. / stepy;
- n /*n_cols */ = cellhd.cols;
- m /*n_rows */ = cellhd.rows;
- xmin = cellhd.west;
- ymin = cellhd.south;
- xmax = cellhd.east;
- ymax = cellhd.north;
- deltx = fabs(cellhd.east - cellhd.west);
- delty = fabs(cellhd.north - cellhd.south);
-
parm.elevin = G_define_option();
parm.elevin->key = "elevin";
parm.elevin->type = TYPE_STRING;
@@ -217,7 +201,6 @@
_("Name of the input aspect map (terrain aspect or azimuth of the solar panel) [decimal degrees]");
parm.aspin->guisection = _("Input_options");
-
parm.slopein = G_define_option();
parm.slopein->key = "slopein";
parm.slopein->type = TYPE_STRING;
@@ -236,16 +219,14 @@
_("Name of the Linke atmospheric turbidity coefficient input raster map [-]");
parm.linkein->guisection = _("Input_options");
- if (parm.linkein->answer == NULL) {
- parm.lin = G_define_option();
- parm.lin->key = "lin";
- parm.lin->type = TYPE_DOUBLE;
- parm.lin->answer = LINKE;
- parm.lin->required = NO;
- parm.lin->guisection = _("Input_options");
- parm.lin->description =
- _("A single value of the Linke atmospheric turbidity coefficient [-]");
- }
+ parm.lin = G_define_option();
+ parm.lin->key = "lin";
+ parm.lin->type = TYPE_DOUBLE;
+ parm.lin->answer = LINKE;
+ parm.lin->required = NO;
+ parm.lin->guisection = _("Input_options");
+ parm.lin->description =
+ _("A single value of the Linke atmospheric turbidity coefficient [-]");
parm.albedo = G_define_option();
parm.albedo->key = "albedo";
@@ -256,16 +237,14 @@
_("Name of the ground albedo coefficient input raster map [-]");
parm.albedo->guisection = _("Input_options");
- if (parm.albedo->answer == NULL) {
- parm.alb = G_define_option();
- parm.alb->key = "alb";
- parm.alb->type = TYPE_DOUBLE;
- parm.alb->answer = ALB;
- parm.alb->required = NO;
- parm.alb->guisection = _("Input_options");
- parm.alb->description =
- _("A single value of the ground albedo coefficient [-]");
- }
+ parm.alb = G_define_option();
+ parm.alb->key = "alb";
+ parm.alb->type = TYPE_DOUBLE;
+ parm.alb->answer = ALB;
+ parm.alb->required = NO;
+ parm.alb->guisection = _("Input_options");
+ parm.alb->description =
+ _("A single value of the ground albedo coefficient [-]");
parm.latin = G_define_option();
parm.latin->key = "latin";
@@ -276,15 +255,13 @@
_("Name of the latitudes input raster map [decimal degrees]");
parm.latin->guisection = _("Input_options");
- if (parm.latin->answer == NULL) {
- parm.lat = G_define_option();
- parm.lat->key = "lat";
- parm.lat->type = TYPE_DOUBLE;
- parm.lat->required = NO;
- parm.lat->guisection = _("Input_options");
- parm.lat->description =
- _("A single value of latitude [decimal degrees]");
- }
+ parm.lat = G_define_option();
+ parm.lat->key = "lat";
+ parm.lat->type = TYPE_DOUBLE;
+ parm.lat->required = NO;
+ parm.lat->guisection = _("Input_options");
+ parm.lat->description =
+ _("A single value of latitude [decimal degrees]");
parm.coefbh = G_define_option();
parm.coefbh->key = "coefbh";
@@ -386,6 +363,22 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (G_get_set_window(&cellhd) == -1)
+ G_fatal_error("G_get_set_window() failed");
+
+ stepx = cellhd.ew_res;
+ stepy = cellhd.ns_res;
+ invstepx = 1. / stepx;
+ invstepy = 1. / stepy;
+ n /*n_cols */ = cellhd.cols;
+ m /*n_rows */ = cellhd.rows;
+ xmin = cellhd.west;
+ ymin = cellhd.south;
+ xmax = cellhd.east;
+ ymax = cellhd.north;
+ deltx = fabs(cellhd.east - cellhd.west);
+ delty = fabs(cellhd.north - cellhd.south);
+
shd = flag.shade->answer;
elevin = parm.elevin->answer;
Modified: grass/trunk/raster/simwe/r.sim.sediment/main.c
===================================================================
--- grass/trunk/raster/simwe/r.sim.sediment/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/simwe/r.sim.sediment/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -51,7 +51,6 @@
/* DEFINE GLOB VAR */
/********************************/
-/* #define NWALK "1000000" */
#define DIFFC "0.8"
#define NITER "10"
#define ITEROUT "2"
@@ -114,54 +113,6 @@
_("Sediment transport and erosion/deposition simulation "
"using path sampling method (SIMWE)");
- if (G_get_set_window(&cellhd) == -1)
- exit(EXIT_FAILURE);
-
- conv = G_database_units_to_meters_factor();
-
- mixx = cellhd.west * conv;
- maxx = cellhd.east * conv;
- miyy = cellhd.south * conv;
- mayy = cellhd.north * conv;
-
- stepx = cellhd.ew_res * conv;
- stepy = cellhd.ns_res * conv;
- /* step = amin1(stepx,stepy); */
- step = (stepx + stepy) / 2.;
- mx = cellhd.cols;
- my = cellhd.rows;
- x_orig = cellhd.west * conv;
- y_orig = cellhd.south * conv; /* do we need this? */
- xmin = 0.;
- ymin = 0.;
- xp0 = xmin + stepx / 2.;
- yp0 = ymin + stepy / 2.;
- xmax = xmin + stepx * (float)mx;
- ymax = ymin + stepy * (float)my;
- hhc = hhmax = 0.;
-
-#if 0
- bxmi = 2093113. * conv;
- bymi = 731331. * conv;
- bxma = 2093461. * conv;
- byma = 731529. * conv;
- bresx = 2. * conv;
- bresy = 2. * conv;
- maxwab = 100000;
-
- mx2o = (int)((bxma - bxmi) / bresx);
- my2o = (int)((byma - bymi) / bresy);
-
- /* relative small box coordinates: leave 1 grid layer for overlap */
-
- bxmi = bxmi - mixx + stepx;
- bymi = bymi - miyy + stepy;
- bxma = bxma - mixx - stepx;
- byma = byma - miyy - stepy;
- mx2 = mx2o - 2 * ((int)(stepx / bresx));
- my2 = my2o - 2 * ((int)(stepy / bresy));
-#endif
-
parm.elevin = G_define_standard_option(G_OPT_R_INPUT);
parm.elevin->key = "elevin";
parm.elevin->description = _("Name of the elevation raster map [m]");
@@ -258,7 +209,6 @@
parm.nwalk = G_define_option();
parm.nwalk->key = "nwalk";
parm.nwalk->type = TYPE_INTEGER;
- /* parm.nwalk->answer = NWALK; */
parm.nwalk->required = NO;
parm.nwalk->description = _("Number of walkers");
parm.nwalk->guisection = _("Parameters");
@@ -295,22 +245,58 @@
parm.diffc->required = NO;
parm.diffc->description = _("Water diffusion constant");
parm.diffc->guisection = _("Parameters");
- /*
- flag.mscale = G_define_flag ();
- flag.mscale->key = 'm';
- flag.mscale->description = _("Multiscale simulation");
- flag.tserie = G_define_flag ();
- flag.tserie->key = 't';
- flag.tserie->description = _("Time-series output");
- */
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- /* mscale=flag.mscale->answer ? "m" : NULL;
- tserie=flag.tserie->answer ? "t" : NULL; */
+ if (G_get_set_window(&cellhd) == -1)
+ exit(EXIT_FAILURE);
+ conv = G_database_units_to_meters_factor();
+
+ mixx = cellhd.west * conv;
+ maxx = cellhd.east * conv;
+ miyy = cellhd.south * conv;
+ mayy = cellhd.north * conv;
+
+ stepx = cellhd.ew_res * conv;
+ stepy = cellhd.ns_res * conv;
+ /* step = amin1(stepx,stepy); */
+ step = (stepx + stepy) / 2.;
+ mx = cellhd.cols;
+ my = cellhd.rows;
+ x_orig = cellhd.west * conv;
+ y_orig = cellhd.south * conv; /* do we need this? */
+ xmin = 0.;
+ ymin = 0.;
+ xp0 = xmin + stepx / 2.;
+ yp0 = ymin + stepy / 2.;
+ xmax = xmin + stepx * (float)mx;
+ ymax = ymin + stepy * (float)my;
+ hhc = hhmax = 0.;
+
+#if 0
+ bxmi = 2093113. * conv;
+ bymi = 731331. * conv;
+ bxma = 2093461. * conv;
+ byma = 731529. * conv;
+ bresx = 2. * conv;
+ bresy = 2. * conv;
+ maxwab = 100000;
+
+ mx2o = (int)((bxma - bxmi) / bresx);
+ my2o = (int)((byma - bymi) / bresy);
+
+ /* relative small box coordinates: leave 1 grid layer for overlap */
+
+ bxmi = bxmi - mixx + stepx;
+ bymi = bymi - miyy + stepy;
+ bxma = bxma - mixx - stepx;
+ byma = byma - miyy - stepy;
+ mx2 = mx2o - 2 * ((int)(stepx / bresx));
+ my2 = my2o - 2 * ((int)(stepy / bresy));
+#endif
+
elevin = parm.elevin->answer;
wdepth = parm.wdepth->answer;
dxin = parm.dxin->answer;
Modified: grass/trunk/raster/simwe/r.sim.water/main.c
===================================================================
--- grass/trunk/raster/simwe/r.sim.water/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster/simwe/r.sim.water/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -119,51 +119,6 @@
_("Overland flow hydrologic simulation using "
"path sampling method (SIMWE)");
- if (G_get_set_window(&cellhd) == -1)
- exit(EXIT_FAILURE);
-
- conv = G_database_units_to_meters_factor();
-
- mixx = conv * cellhd.west;
- maxx = conv * cellhd.east;
- miyy = conv * cellhd.south;
- mayy = conv * cellhd.north;
-
- stepx = cellhd.ew_res * conv;
- stepy = cellhd.ns_res * conv;
- /* step = amin1(stepx,stepy); */
- step = (stepx + stepy) / 2.;
- mx = cellhd.cols;
- my = cellhd.rows;
- x_orig = cellhd.west * conv;
- y_orig = cellhd.south * conv; /* do we need this? */
- xmin = 0.;
- ymin = 0.;
- xp0 = xmin + stepx / 2.;
- yp0 = ymin + stepy / 2.;
- xmax = xmin + stepx * (float)mx;
- ymax = ymin + stepy * (float)my;
- /*
- bxmi=2093113. * conv;
- bymi=731331. * conv;
- bxma=2093461. * conv;
- byma=731529. * conv;
- bresx=2. * conv;
- bresy=2. * conv;
- maxwab=100000;
-
- mx2o= (int)((bxma-bxmi)/bresx);
- my2o= (int)((byma-bymi)/bresy);
- */
- /* relative small box coordinates: leave 1 grid layer for overlap */
- /*
- bxmi = bxmi - mixx + stepx;
- bymi = bymi - miyy + stepy;
- bxma = bxma - mixx - stepx;
- byma = byma - miyy - stepy;
- mx2 = mx2o - 2*((int) (stepx / bresx));
- my2 = my2o - 2*((int) (stepy / bresy));
- */
parm.elevin = G_define_standard_option(G_OPT_R_INPUT);
parm.elevin->key = "elevin";
parm.elevin->description = _("Name of the elevation raster map [m]");
@@ -232,7 +187,6 @@
_("Name of the flow controls raster map (permeability ratio 0-1)");
parm.traps->guisection = _("Input_options");
- /* needs to be updated to GRASS 6 vector format !! */
parm.sfile = G_define_standard_option(G_OPT_V_INPUT);
parm.sfile->key = "vector";
parm.sfile->required = NO;
@@ -268,7 +222,6 @@
parm.nwalk = G_define_option();
parm.nwalk->key = "nwalk";
parm.nwalk->type = TYPE_INTEGER;
- /* parm.nwalk->answer = NWALK; */
parm.nwalk->required = NO;
parm.nwalk->description =
_("Number of walkers, default is twice the no. of cells");
@@ -332,11 +285,7 @@
parm.hbeta->description =
_("Weighting factor for water flow velocity vector");
parm.hbeta->guisection = _("Parameters");
- /*
- flag.mscale = G_define_flag ();
- flag.mscale->key = 'm';
- flag.mscale->description = _("Multiscale simulation");
- */
+
flag.tserie = G_define_flag();
flag.tserie->key = 't';
flag.tserie->description = _("Time-series output");
@@ -345,13 +294,36 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- /* mscale=flag.mscale->answer; */
+ if (G_get_set_window(&cellhd) == -1)
+ exit(EXIT_FAILURE);
+
+ conv = G_database_units_to_meters_factor();
+
+ mixx = conv * cellhd.west;
+ maxx = conv * cellhd.east;
+ miyy = conv * cellhd.south;
+ mayy = conv * cellhd.north;
+
+ stepx = cellhd.ew_res * conv;
+ stepy = cellhd.ns_res * conv;
+ /* step = amin1(stepx,stepy); */
+ step = (stepx + stepy) / 2.;
+ mx = cellhd.cols;
+ my = cellhd.rows;
+ x_orig = cellhd.west * conv;
+ y_orig = cellhd.south * conv; /* do we need this? */
+ xmin = 0.;
+ ymin = 0.;
+ xp0 = xmin + stepx / 2.;
+ yp0 = ymin + stepy / 2.;
+ xmax = xmin + stepx * (float)mx;
+ ymax = ymin + stepy * (float)my;
+
ts = flag.tserie->answer;
elevin = parm.elevin->answer;
dxin = parm.dxin->answer;
dyin = parm.dyin->answer;
- /* maskmap = parm.maskmap->answer; */
rain = parm.rain->answer;
infil = parm.infil->answer;
traps = parm.traps->answer;
Modified: grass/trunk/raster3d/base/r3.mask.main.c
===================================================================
--- grass/trunk/raster3d/base/r3.mask.main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster3d/base/r3.mask.main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -31,27 +31,7 @@
} paramType;
static paramType params;
-extern void *G3d_openNewParam();
-static void setParams()
-{
- params.map = G_define_option();
- params.map->key = "map";
- params.map->type = TYPE_STRING;
- params.map->required = YES;
- params.map->multiple = NO;
- params.map->gisprompt = "old,grid3,3d-raster";
- params.map->description = _("3d raster map with reference values");
-
- params.maskVals = G_define_option();
- params.maskVals->key = "maskvalues";
- params.maskVals->key_desc = "val[-val]";
- params.maskVals->type = TYPE_STRING;
- params.maskVals->required = NO;
- params.maskVals->multiple = YES;
- params.maskVals->description = _("List of cell values to be masked out");
-}
-
/*--------------------------------------------------------------------------*/
void getParams(char **name, d_Mask ** maskRules)
@@ -154,13 +134,28 @@
module->description =
_("Establishes the current working 3D raster mask.");
+ params.map = G_define_option();
+ params.map->key = "map";
+ params.map->type = TYPE_STRING;
+ params.map->required = YES;
+ params.map->multiple = NO;
+ params.map->gisprompt = "old,grid3,3d-raster";
+ params.map->description = _("3d raster map with reference values");
- if (G3d_maskFileExists())
- G_fatal_error(_("Cannot create mask file: G3D_MASK already exists!\n Use 'g.remove rast3d=G3D_MASK' to remove the existing mask."));
+ params.maskVals = G_define_option();
+ params.maskVals->key = "maskvalues";
+ params.maskVals->key_desc = "val[-val]";
+ params.maskVals->type = TYPE_STRING;
+ params.maskVals->required = NO;
+ params.maskVals->multiple = YES;
+ params.maskVals->description = _("List of cell values to be masked out");
- setParams();
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+
+ if (G3d_maskFileExists())
+ G_fatal_error(_("Cannot create mask file: G3D_MASK already exists"));
+
getParams(&name, &maskRules);
makeMask(name, maskRules);
Modified: grass/trunk/raster3d/base/r3.null.main.c
===================================================================
--- grass/trunk/raster3d/base/r3.null.main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/raster3d/base/r3.null.main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -43,9 +43,6 @@
static void modifyNull(char *name, d_Mask * maskRules, int changeNull,
double newNullVal);
-extern void *G3d_openNewParam();
-
-
static void setParams(void)
{
params.map = G_define_option();
Modified: grass/trunk/vector/v.in.ogr/main.c
===================================================================
--- grass/trunk/vector/v.in.ogr/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/vector/v.in.ogr/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -98,11 +98,8 @@
G_gisinit(argv[0]);
- G_begin_polygon_area_calculations(); /* Used in geom() */
-
module = G_define_module();
module->keywords = _("vector, import");
- /* module->description = G_store (buf); */
module->description = _("Convert OGR vector layers to GRASS vector map.");
dsn_opt = G_define_option();
@@ -245,6 +242,8 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ G_begin_polygon_area_calculations(); /* Used in geom() */
+
OGRRegisterAll();
if (G_verbose() > G_verbose_min())
Modified: grass/trunk/vector/v.label.sa/main.c
===================================================================
--- grass/trunk/vector/v.label.sa/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/vector/v.label.sa/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -20,14 +20,6 @@
#define DEFAULT_CHARSET "UTF-8"
/**
- * This function defines the parameters and calls the command-line parser
- * @param argc Count of command line arguments
- * @param argv The command line arguments.
- * @param p The parameters structure.
- */
-static void parse_args(int argc, char *argv[], struct params *p);
-
-/**
* The main function controls the program flow.
*/
int main(int argc, char *argv[])
@@ -41,6 +33,7 @@
srand((unsigned int)time(NULL));
G_gisinit(argv[0]);
+
module = G_define_module();
module->keywords = _("vector, paint labels");
module->description =
@@ -48,190 +41,145 @@
// fprintf(stderr, "Parsing options and flags\n");
/* parse options and flags */
- parse_args(argc, argv, &p);
+ p.map = G_define_standard_option(G_OPT_V_MAP);
- /* initialize labels (get text from database, and get features) */
- labels = labels_init(&p, &n_labels);
- /* start algorithm */
- /* 1. candidate position generation */
- label_candidates(labels, n_labels);
- /* 2. position evaluation */
- label_candidate_overlap(labels, n_labels);
- /* 3. position selection */
- simulate_annealing(labels, n_labels, &p);
- /* write lables to file */
- fprintf(stderr, "Writing labels to file: ...");
- labelf = G_fopen_new("paint/labels", p.labels->answer);
- for (i = 0; i < n_labels; i++) {
- if (labels[i].n_candidates > 0) {
- print_label(labelf, &labels[i], &p);
- }
- G_percent(i, (n_labels - 1), 1);
- }
- fclose(labelf);
+ p.type = G_define_standard_option(G_OPT_V_TYPE);
+ p.type->options = "point,line,area";
+ p.type->answer = "point,line,area";
- /* dumping the skyline of the labels */
- /* {
- int n=1;
- char *f;
- FILE *skyf;
- f = G_tempfile();
- skyf = fopen(f, "w");
- printf("Writing label skylines & label points to file %s", f);
- fprintf(skyf, "VERTI:\n");
- printf("\n%d labels:\n", n_labels);
- for (i = 0; i < n_labels; i++) {
- printf("%s has %d candidates\n", labels[i].text, labels[i].n_candidates);
- if (labels[i].n_candidates > 0) {
- int j;
- label_t *l = &labels[i];
- j = l->current_candidate;
- // for(j=0; j < l->n_candidates; j++) {
- {
- int k;
- label_candidate_t *cc = &l->candidates[j];
- struct line_pnts *sky = skyline_trans_rot(l->skyline,
- &cc->point,
- cc->rotation);
- fprintf(skyf, "L %d 1\n", sky->n_points);
- for(k=0;k < sky->n_points; k++) {
- fprintf(skyf, " %.12f %.12f\n", sky->x[k], sky->y[k]);
- }
- fprintf(skyf, " %-5d %-10d\n", 1, 1000+n);
- // The label point
- fprintf(skyf, "P 1 1\n");
- fprintf(skyf, " %.12f %.12f\n", cc->point.x, cc->point.y);
- fprintf(skyf, " %-5d %-10d\n", 1, 2000+n);
- n++;
- }
- }
- }
- free(f);
- fclose(skyf);
- } */
+ p.layer = G_define_standard_option(G_OPT_V_FIELD);
- return EXIT_SUCCESS;
-}
-
-static void parse_args(int argc, char *argv[], struct params *p)
-{
- p->map = G_define_standard_option(G_OPT_V_MAP);
-
- p->type = G_define_standard_option(G_OPT_V_TYPE);
- p->type->options = "point,line,area";
- p->type->answer = "point,line,area";
-
- p->layer = G_define_standard_option(G_OPT_V_FIELD);
-
- p->column = G_define_option();
- p->column->key = "column";
- p->column->type = TYPE_STRING;
- p->column->required = YES;
- p->column->description =
+ p.column = G_define_option();
+ p.column->key = "column";
+ p.column->type = TYPE_STRING;
+ p.column->required = YES;
+ p.column->description =
_("Name of attribute column to be used for labels");
- p->labels = G_define_option();
- p->labels->key = "labels";
- p->labels->description = _("Name for new paint-label file");
- p->labels->type = TYPE_STRING;
- p->labels->required = YES;
- p->labels->key_desc = "name";
+ p.labels = G_define_option();
+ p.labels->key = "labels";
+ p.labels->description = _("Name for new paint-label file");
+ p.labels->type = TYPE_STRING;
+ p.labels->required = YES;
+ p.labels->key_desc = "name";
- p->font = G_define_option();
- p->font->key = "font";
- p->font->type = TYPE_STRING;
- p->font->required = YES;
- p->font->description =
+ p.font = G_define_option();
+ p.font->key = "font";
+ p.font->type = TYPE_STRING;
+ p.font->required = YES;
+ p.font->description =
_("Name of TrueType font (as listed in the fontcap)");
- p->font->guisection = _("Font");
- p->font->gisprompt = "font";
+ p.font->guisection = _("Font");
+ p.font->gisprompt = "font";
- p->size = G_define_option();
- p->size->key = "size";
- p->size->description = _("Label size (in map-units)");
- p->size->type = TYPE_DOUBLE;
- p->size->answer = "100";
- p->size->guisection = _("Font");
+ p.size = G_define_option();
+ p.size->key = "size";
+ p.size->description = _("Label size (in map-units)");
+ p.size->type = TYPE_DOUBLE;
+ p.size->answer = "100";
+ p.size->guisection = _("Font");
- p->isize = G_define_option();
- p->isize->key = "isize";
- p->isize->description = _("Icon size of point features (in map-units)");
- p->isize->type = TYPE_DOUBLE;
- p->isize->answer = "10";
+ p.isize = G_define_option();
+ p.isize->key = "isize";
+ p.isize->description = _("Icon size of point features (in map-units)");
+ p.isize->type = TYPE_DOUBLE;
+ p.isize->answer = "10";
- p->charset = G_define_option();
- p->charset->key = "charset";
- p->charset->type = TYPE_STRING;
- p->charset->required = NO;
- p->charset->answer = DEFAULT_CHARSET;
- p->charset->description =
+ p.charset = G_define_option();
+ p.charset->key = "charset";
+ p.charset->type = TYPE_STRING;
+ p.charset->required = NO;
+ p.charset->answer = DEFAULT_CHARSET;
+ p.charset->description =
"Character encoding (default: " DEFAULT_CHARSET ")";
- p->color = G_define_option();
- p->color->key = "color";
- p->color->description = _("Text color");
- p->color->type = TYPE_STRING;
- p->color->answer = "black";
- p->color->options = "aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
+ p.color = G_define_option();
+ p.color->key = "color";
+ p.color->description = _("Text color");
+ p.color->type = TYPE_STRING;
+ p.color->answer = "black";
+ p.color->options = "aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
"magenta,orange,purple,red,violet,white,yellow";
- p->color->guisection = _("Colors");
+ p.color->guisection = _("Colors");
- p->hlcolor = G_define_option();
- p->hlcolor->key = "hcolor";
- p->hlcolor->description = _("Hilight color for text");
- p->hlcolor->type = TYPE_STRING;
- p->hlcolor->answer = "none";
- p->hlcolor->options =
+ p.hlcolor = G_define_option();
+ p.hlcolor->key = "hcolor";
+ p.hlcolor->description = _("Hilight color for text");
+ p.hlcolor->type = TYPE_STRING;
+ p.hlcolor->answer = "none";
+ p.hlcolor->options =
"none,aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
"magenta,orange,purple,red,violet,white,yellow";
- p->hlcolor->guisection = _("Colors");
+ p.hlcolor->guisection = _("Colors");
- p->hlwidth = G_define_option();
- p->hlwidth->key = "hwidth";
- p->hlwidth->description = _("Width of highlight coloring");
- p->hlwidth->type = TYPE_DOUBLE;
- p->hlwidth->answer = "0";
- p->hlwidth->guisection = _("Colors");
+ p.hlwidth = G_define_option();
+ p.hlwidth->key = "hwidth";
+ p.hlwidth->description = _("Width of highlight coloring");
+ p.hlwidth->type = TYPE_DOUBLE;
+ p.hlwidth->answer = "0";
+ p.hlwidth->guisection = _("Colors");
- p->bgcolor = G_define_option();
- p->bgcolor->key = "background";
- p->bgcolor->description = _("Background color");
- p->bgcolor->type = TYPE_STRING;
- p->bgcolor->answer = "none";
- p->bgcolor->options =
+ p.bgcolor = G_define_option();
+ p.bgcolor->key = "background";
+ p.bgcolor->description = _("Background color");
+ p.bgcolor->type = TYPE_STRING;
+ p.bgcolor->answer = "none";
+ p.bgcolor->options =
"none,aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
"magenta,orange,purple,red,violet,white,yellow";
- p->bgcolor->guisection = _("Colors");
+ p.bgcolor->guisection = _("Colors");
- p->opaque = G_define_option();
- p->opaque->key = "opaque";
- p->opaque->description =
+ p.opaque = G_define_option();
+ p.opaque->key = "opaque";
+ p.opaque->description =
_("Opaque to vector (only relevant if background color is selected)");
- p->opaque->type = TYPE_STRING;
- p->opaque->answer = "yes";
- p->opaque->options = "yes,no";
- p->opaque->key_desc = "yes|no";
- p->opaque->guisection = _("Colors");
+ p.opaque->type = TYPE_STRING;
+ p.opaque->answer = "yes";
+ p.opaque->options = "yes,no";
+ p.opaque->key_desc = "yes|no";
+ p.opaque->guisection = _("Colors");
- p->bocolor = G_define_option();
- p->bocolor->key = "border";
- p->bocolor->description = _("Border color");
- p->bocolor->type = TYPE_STRING;
- p->bocolor->answer = "none";
- p->bocolor->options =
+ p.bocolor = G_define_option();
+ p.bocolor->key = "border";
+ p.bocolor->description = _("Border color");
+ p.bocolor->type = TYPE_STRING;
+ p.bocolor->answer = "none";
+ p.bocolor->options =
"none,aqua,black,blue,brown,cyan,gray,green,grey,indigo,"
"magenta,orange,purple,red,violet,white,yellow";
- p->bocolor->guisection = _("Colors");
+ p.bocolor->guisection = _("Colors");
- p->bowidth = G_define_option();
- p->bowidth->key = "width";
- p->bowidth->description = _("Border width (only for ps.map output)");
- p->bowidth->type = TYPE_DOUBLE;
- p->bowidth->answer = "0";
- p->bowidth->guisection = _("Colors");
+ p.bowidth = G_define_option();
+ p.bowidth->key = "width";
+ p.bowidth->description = _("Border width (only for ps.map output)");
+ p.bowidth->type = TYPE_DOUBLE;
+ p.bowidth->answer = "0";
+ p.bowidth->guisection = _("Colors");
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+
+ /* initialize labels (get text from database, and get features) */
+ labels = labels_init(&p, &n_labels);
+ /* start algorithm */
+ /* 1. candidate position generation */
+ label_candidates(labels, n_labels);
+ /* 2. position evaluation */
+ label_candidate_overlap(labels, n_labels);
+ /* 3. position selection */
+ simulate_annealing(labels, n_labels, &p);
+ /* write lables to file */
+ fprintf(stderr, "Writing labels to file: ...");
+ labelf = G_fopen_new("paint/labels", p.labels->answer);
+ for (i = 0; i < n_labels; i++) {
+ if (labels[i].n_candidates > 0) {
+ print_label(labelf, &labels[i], &p);
+ }
+ G_percent(i, (n_labels - 1), 1);
+ }
+ fclose(labelf);
+
+ return EXIT_SUCCESS;
}
void print_label(FILE * labelf, label_t * label, struct params *p)
Modified: grass/trunk/vector/v.surf.rst/main.c
===================================================================
--- grass/trunk/vector/v.surf.rst/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/vector/v.surf.rst/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -163,26 +163,6 @@
"point or isoline data in vector format to floating point "
"raster format using regularized spline with tension.");
- if (G_get_set_window(&cellhd) == -1)
- G_fatal_error("G_get_set_window() failed");
- ew_res = cellhd.ew_res;
- ns_res = cellhd.ns_res;
- n_cols = cellhd.cols;
- n_rows = cellhd.rows;
- x_orig = cellhd.west;
- y_orig = cellhd.south;
- xm = cellhd.east;
- ym = cellhd.north;
- if (ew_res < ns_res)
- dmin = ew_res / 2;
- else
- dmin = ns_res / 2;
- disk = n_rows * n_cols * sizeof(int);
- sdisk = n_rows * n_cols * sizeof(short int);
- sprintf(dmaxchar, "%f", dmin * 5);
- sprintf(dminchar, "%f", dmin);
-
-
flag.cv = G_define_flag();
flag.cv->key = 'c';
flag.cv->description =
@@ -299,7 +279,6 @@
parm.dmin->key = "dmin";
parm.dmin->type = TYPE_DOUBLE;
parm.dmin->required = NO;
- parm.dmin->answer = dminchar;
parm.dmin->description =
_("Minimum distance between points (to remove almost identical points)");
parm.dmin->guisection = _("Settings");
@@ -308,7 +287,6 @@
parm.dmax->key = "dmax";
parm.dmax->type = TYPE_DOUBLE;
parm.dmax->required = NO;
- parm.dmax->answer = dmaxchar;
parm.dmax->description =
_("Maximum distance between points on isoline (to insert additional points)");
parm.dmax->guisection = _("Settings");
@@ -366,11 +344,34 @@
parm.scalex->description = _("Anisotropy scaling factor");
parm.scalex->guisection = _("Anisotropy");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (G_get_set_window(&cellhd) == -1)
+ G_fatal_error("G_get_set_window() failed");
+ ew_res = cellhd.ew_res;
+ ns_res = cellhd.ns_res;
+ n_cols = cellhd.cols;
+ n_rows = cellhd.rows;
+ x_orig = cellhd.west;
+ y_orig = cellhd.south;
+ xm = cellhd.east;
+ ym = cellhd.north;
+ if (ew_res < ns_res)
+ dmin = ew_res / 2;
+ else
+ dmin = ns_res / 2;
+ disk = n_rows * n_cols * sizeof(int);
+ sdisk = n_rows * n_cols * sizeof(short int);
+ sprintf(dmaxchar, "%f", dmin * 5);
+ sprintf(dminchar, "%f", dmin);
+
+ if (!parm.dmin->answer)
+ parm.dmin->answer = dminchar;
+ if (!parm.dmax->answer)
+ parm.dmax->answer = dmaxchar;
+
per = 1;
input = parm.input->answer;
field = atoi(parm.field->answer);
Modified: grass/trunk/vector/v.vol.rst/main.c
===================================================================
--- grass/trunk/vector/v.vol.rst/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/vector/v.vol.rst/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -241,31 +241,6 @@
_("Interpolates point data to a G3D grid volume using "
"regularized spline with tension (RST) algorithm.");
- if (G_get_set_window(&cellhd) == -1)
- G_fatal_error("G_get_set_window() failed");
-
- G3d_getWindow(¤t_region);
- G3d_readWindow(¤t_region, NULL);
-
- ew_res = current_region.ew_res;
- ns_res = current_region.ns_res;
- n_cols = current_region.cols;
- n_rows = current_region.rows;
- x_orig = current_region.west;
- y_orig = current_region.south;
- n_levs = current_region.depths;
- tb_res = current_region.tb_res;
- z_orig = current_region.bottom;
-
- dmin = amin1(ew_res, ns_res) / 2;
- disk = n_rows * n_cols * sizeof(float);
- sprintf(dminchar, "%lf", dmin);
-
- nsizr = n_rows;
- nsizc = n_cols;
- nsizl = n_levs;
- n_rows_in = n_rows; /* fix by JH 04/24/02 */
-
parm.input = G_define_option();
parm.input->key = "input";
parm.input->type = TYPE_STRING;
@@ -358,7 +333,6 @@
parm.dmin1 = G_define_option();
parm.dmin1->key = "dmin";
parm.dmin1->type = TYPE_DOUBLE;
- parm.dmin1->answer = dminchar;
parm.dmin1->required = NO;
parm.dmin1->description =
_("Minimum distance between points (to remove almost identical points)");
@@ -460,6 +434,34 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (G_get_set_window(&cellhd) == -1)
+ G_fatal_error("G_get_set_window() failed");
+
+ G3d_getWindow(¤t_region);
+ G3d_readWindow(¤t_region, NULL);
+
+ ew_res = current_region.ew_res;
+ ns_res = current_region.ns_res;
+ n_cols = current_region.cols;
+ n_rows = current_region.rows;
+ x_orig = current_region.west;
+ y_orig = current_region.south;
+ n_levs = current_region.depths;
+ tb_res = current_region.tb_res;
+ z_orig = current_region.bottom;
+
+ dmin = amin1(ew_res, ns_res) / 2;
+ disk = n_rows * n_cols * sizeof(float);
+ sprintf(dminchar, "%lf", dmin);
+
+ nsizr = n_rows;
+ nsizc = n_cols;
+ nsizl = n_levs;
+ n_rows_in = n_rows; /* fix by JH 04/24/02 */
+
+ if (!parm.dmin1->answer)
+ parm.dmin1->answer = dminchar;
+
per = 1; /*flag.per->answer; */
iw2 = 1;
sig1 = 0;
Modified: grass/trunk/visualization/xganim/main.c
===================================================================
--- grass/trunk/visualization/xganim/main.c 2008-08-16 05:51:14 UTC (rev 32803)
+++ grass/trunk/visualization/xganim/main.c 2008-08-16 06:02:01 UTC (rev 32804)
@@ -41,7 +41,7 @@
static Boolean do_run(XtPointer);
static char **gee_wildfiles(char *wildarg, char *element, int *num);
static void change_label(Widget wid, char *str);
-static void parse_command(int argc, char **argv,
+static void parse_command(struct Option **viewopts,
char *vfiles[MAXVIEWS][MAXIMAGES],
int *numviews, int *numframes);
@@ -85,16 +85,29 @@
Arg wargs[15];
unsigned int n;
+ struct Option *viewopts[MAXVIEWS];
- toplevel = XtAppInitialize(&AppC, "xganimate", NULL, 0,
- &argc, argv, NULL, wargs, 0);
+ G_gisinit(argv[0]);
- theDisplay = XtDisplay(toplevel);
+ for (i = 0; i < MAXVIEWS; i++) {
+ char buf[BUFSIZ];
+ viewopts[i] = G_define_option();
+ sprintf(buf, "view%d", i + 1);
+ viewopts[i]->key = G_store(buf);
+ viewopts[i]->type = TYPE_STRING;
+ viewopts[i]->required = (i ? NO : YES);
+ viewopts[i]->multiple = YES;
+ viewopts[i]->gisprompt = "old,cell,Raster";;
+ sprintf(buf, _("Raster file(s) for View%d"), i + 1);
+ viewopts[i]->description = G_store(buf);
+ }
- G_gisinit(argv[0]);
- parse_command(argc, argv, vfiles, &numviews, &frames);
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+ parse_command(viewopts, vfiles, &numviews, &frames);
+
/* debug */
if (G_verbose() > G_verbose_std()) {
for (i = 0; i < numviews; i++) {
@@ -159,7 +172,11 @@
nrows += (1 + (nrows / vrows)) * BORDER_W;
ncols += (1 + (ncols / vcols)) * BORDER_W;
+ toplevel = XtAppInitialize(&AppC, "xganimate", NULL, 0,
+ &argc, argv, NULL, wargs, 0);
+ theDisplay = XtDisplay(toplevel);
+
n = 0;
if (ncols > nrows) {
XtSetArg(wargs[n], XmNwidth, ncols);
@@ -580,40 +597,26 @@
/********************************************************************/
-static void parse_command(int argc, char **argv,
+static void parse_command(struct Option **viewopts,
char *vfiles[MAXVIEWS][MAXIMAGES],
int *numviews, int *numframes)
{
- struct Option *viewopts[MAXVIEWS];
- char buf[BUFSIZ], **wildfiles;
- int i, j, k, numi, wildnum;
+ int i, j, k;
*numviews = *numframes = 0;
- for (i = 0; i < MAXVIEWS; i++) {
- viewopts[i] = G_define_option();
- sprintf(buf, "view%d", i + 1);
- viewopts[i]->key = G_store(buf);
- viewopts[i]->type = TYPE_STRING;
- viewopts[i]->required = (i ? NO : YES);
- viewopts[i]->multiple = YES;
- viewopts[i]->gisprompt = "old,cell,Raster";;
- sprintf(buf, _("Raster file(s) for View%d"), i + 1);
- viewopts[i]->description = G_store(buf);
- }
- if (G_parser(argc, argv))
- exit(EXIT_FAILURE);
-
for (i = 0; i < MAXVIEWS; i++) {
if (viewopts[i]->answers) {
+ int numi, wildnum;
+
(*numviews)++;
for (j = 0, numi = 0; viewopts[i]->answers[j]; j++) {
if ((NULL != strchr(viewopts[i]->answers[j], '*')) ||
(NULL != strchr(viewopts[i]->answers[j], '?')) ||
(NULL != strchr(viewopts[i]->answers[j], '['))) {
- wildfiles = gee_wildfiles(viewopts[i]->answers[j],
- "cell", &wildnum);
+ char **wildfiles = gee_wildfiles(viewopts[i]->answers[j],
+ "cell", &wildnum);
for (k = 0; k < wildnum; k++)
vfiles[i][numi++] = wildfiles[k];
More information about the grass-commit
mailing list