This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository grass.
commit e641ac37d24c3907c2370f182ae468782e7a553b Author: Bas Couwenberg <[email protected]> Date: Sun May 1 15:58:46 2016 +0200 Imported Upstream version 7.0.4 --- ChangeLog_7.0.4.gz | Bin 0 -> 827868 bytes ChangeLog_7.0.4RC1.gz | Bin 827109 -> 0 bytes display/d.mon/d.mon.html | 9 +- general/g.copy/g.copy.html | 29 +-- general/g.proj/g.proj.html | 31 ++- gui/wxpython/docs/wxGUI.html | 4 +- include/VERSION | 2 +- lib/gis/datum.table | 26 ++- lib/gis/datumtransform.table | 14 +- lib/proj/convert.c | 19 +- raster/r.in.xyz/r.in.xyz.html | 45 ++++- raster/r.mapcalc/r.mapcalc.html | 2 +- raster/r.mapcalc/r3.mapcalc.html | 2 +- raster/r.sim/r.sim.sediment/main.c | 164 ++++++++-------- raster/r.sim/r.sim.water/main.c | 159 ++++++++-------- raster/r.sim/simlib/Makefile | 5 +- raster/r.sim/simlib/hydro.c | 10 +- raster/r.sim/simlib/input.c | 251 ++++++++++++++++++++++++- raster/r.sim/simlib/observation_points.c | 19 +- raster/r.sim/simlib/output.c | 4 +- raster/r.sim/simlib/simlib.h | 96 ++++++++++ raster/r.sim/simlib/waterglobs.h | 28 +-- raster/r.sim/test/test.sh | 47 +++++ raster/r.water.outlet/r.water.outlet.html | 6 +- scripts/g.search.modules/g.search.modules.html | 4 +- scripts/r.pack/r.pack.html | 2 +- vector/v.db.select/main.c | 2 +- vector/v.net/v.net.html | 14 +- 28 files changed, 718 insertions(+), 276 deletions(-) diff --git a/ChangeLog_7.0.4.gz b/ChangeLog_7.0.4.gz new file mode 100644 index 0000000..140be15 Binary files /dev/null and b/ChangeLog_7.0.4.gz differ diff --git a/ChangeLog_7.0.4RC1.gz b/ChangeLog_7.0.4RC1.gz deleted file mode 100644 index 7b033b3..0000000 Binary files a/ChangeLog_7.0.4RC1.gz and /dev/null differ diff --git a/display/d.mon/d.mon.html b/display/d.mon/d.mon.html index 3236392..bb00247 100644 --- a/display/d.mon/d.mon.html +++ b/display/d.mon/d.mon.html @@ -49,6 +49,13 @@ the graphics monitors the user wishes to direct output to. Currently <em>selected</em> a monitor can be released by <b>-r</b> flag. +<h2>NOTES</h2> + +<em>d.mon</em> is designed for interactive use. If non-interactive use +is needed (e.g., in a script) set <tt>GRASS_RENDER_IMMEDIATE=png</tt> +(or <tt>=cairo</tt>) and use the related environment +<a href="variables.html">variables</a> to control output size etc. + <h2>EXAMPLES</h2> <h3>wx0 monitor</h3> @@ -130,4 +137,4 @@ of variables for rendering</a>, Martin Landa, OSGeoREL, Czech Technical University in Prague, Czech Republic -<p><i>Last changed: $Date: 2016-01-28 12:27:18 +0100 (Thu, 28 Jan 2016) $</i> +<p><i>Last changed: $Date: 2016-04-26 00:11:32 +0200 (Tue, 26 Apr 2016) $</i> diff --git a/general/g.copy/g.copy.html b/general/g.copy/g.copy.html index df9a8f8..07eec26 100644 --- a/general/g.copy/g.copy.html +++ b/general/g.copy/g.copy.html @@ -39,31 +39,14 @@ named <b>from</b> map in each of the mapset directories listed in the user's current mapset search path in the order in which mapsets are listed there (see <em><a href="g.mapsets.html">g.mapsets</a></em>). -<h2>NOTES</h2> - -If the user does not enter parameter values but instead -types only <em>g.copy</em> on the command line the program -will prompt the user for a data type, the name of a file of -this data type to copy, and the name of a new file to hold -the copy. After both file names have been entered, the -copy is created and the user is again prompted for a data -element to be copied, until the user hits RETURN. When -prompted for file names, the user may enter 'list' to see a -list of existing files, or hit RETURN to end the file -listing. - -<p> -If a file has support files (e.g., as do raster data -files), these support files will also be copied. - <h2>SEE ALSO</h2> <em> - <a href="g.access.html">g.access</a>, - <a href="g.list.html">g.list</a>, - <a href="g.mapsets.html">g.mapsets</a>, - <a href="g.remove.html">g.remove</a>, - <a href="g.rename.html">g.rename</a> +<a href="g.access.html">g.access</a>, +<a href="g.list.html">g.list</a>, +<a href="g.mapsets.html">g.mapsets</a>, +<a href="g.remove.html">g.remove</a>, +<a href="g.rename.html">g.rename</a> </em> <h2>AUTHOR</h2> @@ -73,4 +56,4 @@ U.S. Army Construction Engineering Research Laboratory <p> -<i>Last changed: $Date: 2016-01-28 12:27:18 +0100 (Thu, 28 Jan 2016) $</i> +<i>Last changed: $Date: 2016-04-29 16:26:02 +0200 (Fri, 29 Apr 2016) $</i> diff --git a/general/g.proj/g.proj.html b/general/g.proj/g.proj.html index 2ace36d..38543a5 100644 --- a/general/g.proj/g.proj.html +++ b/general/g.proj/g.proj.html @@ -110,19 +110,32 @@ limited to 8000 bytes. <h2>EXAMPLES</h2> +<h3>Print information</h3> + Print the projection information for the current location:<br> <div class="code"><pre> g.proj -p </pre></div> -<p>Create a '.prj' file in ESRI format corresponding to the current location:<br> +<p> +List the possible datum transformation parameters for the current location:<br> + +<div class="code"><pre> +g.proj -t datumtrans=-1 +</pre></div> + +<h3>Create projection (PRJ) file</h3> + +Create a '.prj' file in ESRI format corresponding to the current location:<br> <div class="code"><pre> g.proj -wef > irish_grid.prj </pre></div> -<p>Read the projection information from a geotiff file and print it in PROJ.4 +<h3>Read projection from file</h3> + +Read the projection information from a GeoTIFF file and print it in PROJ.4 format:<br> <div class="code"><pre> @@ -136,6 +149,8 @@ format:<br> cat proj4.description | g.proj -w proj4=- </pre></div> +<h3>Create new location</h3> + <p>Create a new location with the co-ordinate system referred to by EPSG code 4326 (Latitude-Longitude/WGS84), without explicitly specifying datum transformation parameters:<br> @@ -155,6 +170,8 @@ g.proj -c epsg=900913 location=google 29900 (Irish Grid), selecting datum transformation parameter set no. 2:<br> <div class="code"><pre> +# list available datums for EPSG code 29900 +g.proj -t datumtrans=-1 epsg=29900 g.proj -c epsg=29900 datumtrans=2 location=irish_grid </pre></div> @@ -165,12 +182,6 @@ location, but forcing a change to datum transformation parameter set no. 1:<br> g.proj -c location=newloc -t datumtrans=1 </pre></div> -<p>List the possible datum transformation parameters for the current location:<br> - -<div class="code"><pre> -g.proj -t datumtrans=-1 -</pre></div> - <p>Create a new location with the co-ordinate system from a WKT definition stored in a text file:<br> @@ -186,6 +197,8 @@ parameters:<br> g.proj -c location=spain proj4="+proj=utm +zone=30 +ellps=intl" datum=eur50 datumtrans=0 </pre></div> +<h3>Using g.proj output for GDAL/OGR tools</h3> + <p>Reproject external raster map to current GRASS projection (does not always make sense!) using the GDAL 'gdalwarp' tool. We recommend to use the ERDAS/Img format and not to use the ESRI style of WKT:<br> @@ -228,4 +241,4 @@ ogr2ogr -t_srs "`g.proj -wf`" polbnda_italy_GB_ovest.shp polbnda_italy_LL.shp Paul Kelly -<p><i>Last changed: $Date: 2016-01-29 10:56:07 +0100 (Fri, 29 Jan 2016) $</i> +<p><i>Last changed: $Date: 2016-04-24 18:51:23 +0200 (Sun, 24 Apr 2016) $</i> diff --git a/gui/wxpython/docs/wxGUI.html b/gui/wxpython/docs/wxGUI.html index 817e53f..dea5b3f 100644 --- a/gui/wxpython/docs/wxGUI.html +++ b/gui/wxpython/docs/wxGUI.html @@ -718,7 +718,7 @@ Stepan Turek, OSGeoREL, Czech Technical University in Prague, Czech Republic<br> Tereza Fiedlerova, OSGeoREL, Czech Technical University in Prague, Czech Republic<br> Matej Krejci, OSGeoREL, Czech Technical University in Prague, Czech Republic<br><br> -Icons created by <a href="http://robert.szczepanek.pl">Robert Szczepanek</a>, Poland (<a href="https://svn.osgeo.org/osgeo/graphics/trunk/toolbar-icons/24x24/">SVN</a>) +Icons created by <a href="http://robert.szczepanek.pl">Robert Szczepanek</a>, Poland (<a href="https://github.com/Cracert/GIS-icons">Git repository</a>) <p> -<i>$Date: 2016-03-25 16:15:23 +0100 (Fri, 25 Mar 2016) $</i> +<i>$Date: 2016-04-26 17:15:05 +0200 (Tue, 26 Apr 2016) $</i> diff --git a/include/VERSION b/include/VERSION index 42bf832..f44b869 100644 --- a/include/VERSION +++ b/include/VERSION @@ -1,4 +1,4 @@ 7 0 -4RC1 +4 2016 diff --git a/lib/gis/datum.table b/lib/gis/datum.table index 30c006c..b3a061d 100644 --- a/lib/gis/datum.table +++ b/lib/gis/datum.table @@ -1,14 +1,20 @@ -# this file contains datum shift parameters, +# Datum Transformation Parameter Lists for GRASS +# (single 3-parameter datum transformation)) +# +# This file contains datum shift parameters, # it supplies a datum database table for GRASS # format: # shortname "Full EPSG-style name" ellipsoid dx= dy= dz= # -# where short name is a single word datum specifier, -# Full EPSG-style name is the exact name used in the European -# Petroleum Survey Group (EPSG) database (enclosed in double quotes), -# ellipsoid is the acronym of the ellipsoid used with this map datum, -# dx, dy and dz are the datum shift parameters. -# no spaces allowed before or after the =. +# where +# * short name is a single word datum specifier, +# * Full EPSG-style name is the exact name used in the European +# Petroleum Survey Group (EPSG) database (enclosed in double quotes), +# * ellipsoid is the acronym of the ellipsoid used with this map datum, +# (GRASS ellipsoid code, from ellipse.table) +# * dx, dy and dz are the datum shift parameters that should cover the +# whole area the datum is used in. +# Note: no spaces allowed before or after the =. # # In general the 3-parameter transformation given in this file should # be a mean solution for the countries or area the datum is used in. @@ -25,8 +31,7 @@ # cited from NIMA document TR8350.2 # # Datum parameters for/from European Terrestrial Reference System ETRS89 -# are here: http://crs.ifag.de/crs_national.php -# http://crs.bkg.bund.de/crs-eu +# are here: http://www.crs-geo.eu # World Geodetic System 1984 wgs84 "WGS_1984" wgs84 dx=0.0 dy=0.0 dz=0.0 @@ -36,6 +41,7 @@ wgs72 "WGS_1972" wgs72 dx=0.0 dy=0.0 dz=5.0 nad27 "North_American_Datum_1927" clark66 dx=-22.0 dy=157.0 dz=176.0 # North American 1983 nad83 "North_American_Datum_1983" grs80 dx=0.0 dy=0.0 dz=0.0 +nad83harn "NAD83_High_Accuracy_Reference_Network" grs80 dx=0.0 dy=0.0 dz=0.0 # Tokyo datum mean tokyo "Tokyo" bessel dx=-148 dy=507 dz=685 # Ordnance Survey of Great Britain (1936) @@ -91,4 +97,4 @@ itrf92 "ITRF92" grs80 dx=0 dy=0 dz=0 # https://epsg.io/5514 + https://epsg.io/6156-datum S_JTSK "System_Jednotne_Trigonometricke_Site_Katastralni" bessel dx=589 dy=76 dz=480 # http://spatialreference.org/ref/epsg/4674/ -Sistema_de_Referencia_Geocentrico_para_America_del_Sur_2000 "Sistema_de_Referencia_Geocentrico_para_America_del_Sur_2000" grs80 dx=0 dy=0 dz=0 +sirgas2000 "Sistema_de_Referencia_Geocentrico_para_las_AmericaS_2000" grs80 dx=0 dy=0 dz=0 diff --git a/lib/gis/datumtransform.table b/lib/gis/datumtransform.table index d7635b2..48d81eb 100644 --- a/lib/gis/datumtransform.table +++ b/lib/gis/datumtransform.table @@ -1,15 +1,23 @@ # Datum Transformation Parameter Lists for GRASS +# (allows multiple different sets of datum transformation parameters to be +# supplied for any datum) # # Line Format: -# shortname "PROJ.4-style parameters" "Where Used" "Comment" +# shortname "parameters" "Where Used" "Comment" # -# 4 fields on each line, shortname should be already listed in datum.table +# where +# * parameters can be in any format accepted by PROJ.4, +# so towgs84= 3 parameters or 7 parameters, or nadgrids= +# * area of validity +# * comment +# Hence, 4 fields on each line, and shortname should be already +# listed in datum.table. # # All but 1st field must be enclosed in quotes ("") An empty field can # contain a single space between the quotes (" ") but try to provide as # much detail as possible for the user. # -# datum.table only holds one 3-parameter transformation. Extra sets of +# Note: datum.table only holds one 3-parameter transformation. Extra sets of # transformation parameters may be defined in this file for each datum # and will be presented to the user to select the most appropriate one for # his/her location. The "Where Used" and "Comment" fields should contain diff --git a/lib/proj/convert.c b/lib/proj/convert.c index 6393480..f92fdcf 100644 --- a/lib/proj/convert.c +++ b/lib/proj/convert.c @@ -141,9 +141,12 @@ OGRSpatialReferenceH GPJ_grass_to_osr(const struct Key_Value * proj_info, return NULL; } G_free(proj4mod); + + /* this messes up PROJCS versus GEOGCS! sysname = G_find_key_value("name", proj_info); if (sysname) OSRSetProjCS(hSRS, sysname); + */ if ((errcode = OSRExportToWkt(hSRS, &wkt)) != OGRERR_NONE) { G_warning(_("OGR can't get WKT-style parameter string " @@ -742,14 +745,24 @@ const char *GPJ_set_csv_loc(const char *name) /* The list below is only for files that use a non-standard name for a * datum that is already supported in GRASS. The number of entries must be even; * they are all in pairs. The first one in the pair is the non-standard name; - * the second is the GRASS name. If a name appears more than once (as for + * the second is the GRASS/GDAL name. If a name appears more than once (as for * European_Terrestrial_Reference_System_1989) then it means there was more * than one non-standard name for it that needs to be accounted for. * * N.B. The order of these pairs is different from that in * ogr/ogrfromepsg.cpp in the GDAL source tree! GRASS uses the EPSG * names in its WKT representation except WGS_1984 and WGS_1972 as - * these shortened versions seem to be standard + * these shortened versions seem to be standard. + * Below order: + * the equivalent name comes first in the pair, and + * the EPSG name (as used in the GRASS datum.table file) comes second. + * + * The datum parameters are stored in + * ../gis/datum.table # 3 parameters + * ../gis/datumtransform.table # 7 parameters (requires entry in datum.table) + * + * Hint: use GDAL's "testepsg" to identify the canonical name, e.g. + * testepsg epsg:4674 */ static const char *papszDatumEquiv[] = { @@ -785,8 +798,6 @@ static const char *papszDatumEquiv[] = { "Deutsches_Hauptdreiecksnetz", "South_American_1969", "South_American_Datum_1969", - "Sistema_de_Referencia_Geocentrico_para_las_AmericaS_2000", - "Sistema_de_Referencia_Geocentrico_para_America_del_Sur_2000", "ITRF_1992", "ITRF92", NULL diff --git a/raster/r.in.xyz/r.in.xyz.html b/raster/r.in.xyz/r.in.xyz.html index b7d575e..4f84942 100644 --- a/raster/r.in.xyz/r.in.xyz.html +++ b/raster/r.in.xyz/r.in.xyz.html @@ -202,8 +202,49 @@ attribute(s), the data can be imported using either the x or y coordinate as a fake z column for <b>method</b>=<tt>n</tt> (count number of points per grid cell), the z values are ignored anyway. -<h2>EXAMPLE</h2> +<h2>EXAMPLES</h2> +<h3>Import of x,y,z ASCII into DEM</h3> + +Sometimes elevation data are delivered as x,y,z ASCII files instead of +a raster matrix: + +<!-- NC: preparation for this example +g.region raster=elevation res=15 -p +# +r.stats -1g elevation > elevation.xyz +--> + +<div class="code"><pre> +# Important: observe the raster spacing from the ASCII file: +# ASCII file format (example): +# 630007.5 228492.5 141.99614 +# 630022.5 228492.5 141.37904 +# 630037.5 228492.5 142.29822 +# 630052.5 228492.5 143.97987 +# ... +# The point distance is 15m here. + +# detect extent, print result as g.region parameters +r.in.xyz input=elevation.xyz separator=space -s output=dummy -g +# ... n=228492.5 s=215007.5 e=644992.5 w=630007.5 b=55.578793 t=156.32986 + +# set computational region, along with the actual raster resolution +# which is defined by the ASCII file point spacing: +g.region n=228492.5 s=215007.5 e=644992.5 w=630007.5 res=15 -p + +# enlarge computational region by half a raster cell (here 7.5m) to +# store the points as cell centers: +g.region n=n+7.5 s=s-7.5 w=w-7.5 e=e+7.5 -p + +# import XYZ ASCII file, with z values as raster cell values +r.in.xyz input=elevation.xyz separator=space method=mean output=myelev + +# univariate statistics for verification of raster values +r.univar myelev +</pre></div> + +<h3>Import of LiDAR data and DEM creation</h3> Import the <a href="http://www.grassbook.org/ncexternal/index.html">Jockey's Ridge, NC, LIDAR dataset</a> (compressed file "lidaratm2.txt.gz"), and process it into a clean DEM: @@ -310,4 +351,4 @@ Extended by Volker Wichmann to support the aggregate functions <i>median, percentile, skewness</i> and <i>trimmed mean</i>. <p> -<i>Last changed: $Date: 2016-02-24 14:28:01 +0100 (Wed, 24 Feb 2016) $</i> +<i>Last changed: $Date: 2016-04-29 09:45:23 +0200 (Fri, 29 Apr 2016) $</i> diff --git a/raster/r.mapcalc/r.mapcalc.html b/raster/r.mapcalc/r.mapcalc.html index 40184e7..191c19b 100644 --- a/raster/r.mapcalc/r.mapcalc.html +++ b/raster/r.mapcalc/r.mapcalc.html @@ -746,4 +746,4 @@ Research Laboratory <p>Glynn Clements <p> -<i>Last changed: $Date: 2016-04-18 00:00:57 +0200 (Mo, 18. Apr 2016) $</i> +<i>Last changed: $Date: 2016-04-18 00:00:57 +0200 (Mon, 18 Apr 2016) $</i> diff --git a/raster/r.mapcalc/r3.mapcalc.html b/raster/r.mapcalc/r3.mapcalc.html index 06e00a0..97fd611 100644 --- a/raster/r.mapcalc/r3.mapcalc.html +++ b/raster/r.mapcalc/r3.mapcalc.html @@ -619,4 +619,4 @@ Tomas Paudits & Jaro Hofierka, funded by GeoModel s.r.o., Slovakia <p>Glynn Clements <p> -<i>Last changed: $Date: 2016-04-18 00:00:57 +0200 (Mo, 18. Apr 2016) $</i> +<i>Last changed: $Date: 2016-04-18 00:00:57 +0200 (Mon, 18 Apr 2016) $</i> diff --git a/raster/r.sim/r.sim.sediment/main.c b/raster/r.sim/r.sim.sediment/main.c index 371bfb0..877d214 100644 --- a/raster/r.sim/r.sim.sediment/main.c +++ b/raster/r.sim/r.sim.sediment/main.c @@ -81,7 +81,7 @@ /********************************/ -#include <grass/waterglobs.h> +#include <grass/simlib.h> char fncdsm[32]; char filnam[10]; @@ -102,6 +102,9 @@ int main(int argc, char *argv[]) int ii; int ret_val; static int rand1 = 12345; + struct Cell_head cellhd; + struct WaterParams wp; + struct options parm; G_gisinit(argv[0]); @@ -261,122 +264,115 @@ int main(int argc, char *argv[]) G_get_set_window(&cellhd); - 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; - 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.; + WaterParams_init(&wp); + + wp.conv = G_database_units_to_meters_factor(); + + wp.mixx = cellhd.west * wp.conv; + wp.maxx = cellhd.east * wp.conv; + wp.miyy = cellhd.south * wp.conv; + wp.mayy = cellhd.north * wp.conv; + + wp.stepx = cellhd.ew_res * wp.conv; + wp.stepy = cellhd.ns_res * wp.conv; + /* wp.step = amin1(wp.stepx,wp.stepy); */ + wp.step = (wp.stepx + wp.stepy) / 2.; + wp.mx = cellhd.cols; + wp.my = cellhd.rows; + wp.xmin = 0.; + wp.ymin = 0.; + wp.xp0 = wp.xmin + wp.stepx / 2.; + wp.yp0 = wp.ymin + wp.stepy / 2.; + wp.xmax = wp.xmin + wp.stepx * (float)wp.mx; + wp.ymax = wp.ymin + wp.stepy * (float)wp.my; + wp.hhc = wp.hhmax = 0.; #if 0 - bxmi = 2093113. * conv; - bymi = 731331. * conv; - bxma = 2093461. * conv; - byma = 731529. * conv; - bresx = 2. * conv; - bresy = 2. * conv; - maxwab = 100000; + wp.bxmi = 2093113. * wp.conv; + wp.bymi = 731331. * wp.conv; + wp.bxma = 2093461. * wp.conv; + wp.byma = 731529. * wp.conv; + wp.bresx = 2. * wp.conv; + wp.bresy = 2. * wp.conv; + wp.maxwab = 100000; - mx2o = (int)((bxma - bxmi) / bresx); - my2o = (int)((byma - bymi) / bresy); + wp.mx2o = (int)((wp.bxma - wp.bxmi) / wp.bresx); + wp.my2o = (int)((wp.byma - wp.bymi) / wp.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)); + wp.bxmi = wp.bxmi - wp.mixx + wp.stepx; + wp.bymi = wp.bymi - wp.miyy + wp.stepy; + wp.bxma = wp.bxma - wp.mixx - wp.stepx; + wp.byma = wp.byma - wp.miyy - wp.stepy; + wp.mx2 = wp.mx2o - 2 * ((int)(wp.stepx / wp.bresx)); + wp.my2 = wp.my2o - 2 * ((int)(wp.stepy / wp.bresy)); #endif - elevin = parm.elevin->answer; - wdepth = parm.wdepth->answer; - dxin = parm.dxin->answer; - dyin = parm.dyin->answer; - detin = parm.detin->answer; - tranin = parm.tranin->answer; - tauin = parm.tauin->answer; - manin = parm.manin->answer; - tc = parm.tc->answer; - et = parm.et->answer; - conc = parm.conc->answer; - flux = parm.flux->answer; - erdep = parm.erdep->answer; - outwalk = parm.outwalk->answer; - - /* sscanf(parm.nwalk->answer, "%d", &maxwa); */ - sscanf(parm.niter->answer, "%d", ×ec); - sscanf(parm.outiter->answer, "%d", &iterout); -/* sscanf(parm.density->answer, "%d", &ldemo); */ - sscanf(parm.diffc->answer, "%lf", &frac); - sscanf(parm.maninval->answer, "%lf", &manin_val); + wp.elevin = parm.elevin->answer; + wp.wdepth = parm.wdepth->answer; + wp.dxin = parm.dxin->answer; + wp.dyin = parm.dyin->answer; + wp.detin = parm.detin->answer; + wp.tranin = parm.tranin->answer; + wp.tauin = parm.tauin->answer; + wp.manin = parm.manin->answer; + wp.tc = parm.tc->answer; + wp.et = parm.et->answer; + wp.conc = parm.conc->answer; + wp.flux = parm.flux->answer; + wp.erdep = parm.erdep->answer; + wp.outwalk = parm.outwalk->answer; + + /* sscanf(parm.nwalk->answer, "%d", &wp.maxwa); */ + sscanf(parm.niter->answer, "%d", &wp.timesec); + sscanf(parm.outiter->answer, "%d", &wp.iterout); +/* sscanf(parm.density->answer, "%d", &wp.ldemo); */ + sscanf(parm.diffc->answer, "%lf", &wp.frac); + sscanf(parm.maninval->answer, "%lf", &wp.manin_val); /* Recompute timesec from user input in minutes * to real timesec in seconds */ - timesec = timesec * 60; - iterout = iterout * 60; - if ((timesec / iterout) > 100) + wp.timesec = wp.timesec * 60; + wp.iterout = wp.iterout * 60; + if ((wp.timesec / wp.iterout) > 100) G_message(_("More than 100 files are going to be created !!!!!")); /* compute how big the raster is and set this to appr 2 walkers per cell */ if (parm.nwalk->answer == NULL) { - maxwa = mx * my * 2; - rwalk = (double)(mx * my * 2.); - G_message(_("default nwalk=%d, rwalk=%f"), maxwa, rwalk); + wp.maxwa = wp.mx * wp.my * 2; + wp.rwalk = (double)(wp.mx * wp.my * 2.); + G_message(_("default nwalk=%d, rwalk=%f"), wp.maxwa, wp.rwalk); } else { - sscanf(parm.nwalk->answer, "%d", &maxwa); - rwalk = (double)maxwa; + sscanf(parm.nwalk->answer, "%d", &wp.maxwa); + wp.rwalk = (double)wp.maxwa; } /*rwalk = (double) maxwa; */ - if (conv != 1.0) - G_message(_("Using metric conversion factor %f, step=%f"), conv, - step); + if (wp.conv != 1.0) + G_message(_("Using metric conversion factor %f, step=%f"), wp.conv, + wp.step); + init_library_globals(&wp); - if ((tc == NULL) && (et == NULL) && (conc == NULL) && (flux == NULL) && - (erdep == NULL)) + if ((wp.tc == NULL) && (wp.et == NULL) && (wp.conc == NULL) && (wp.flux == NULL) && + (wp.erdep == NULL)) G_warning(_("You are not outputting any raster or site files")); ret_val = input_data(); if (ret_val != 1) G_fatal_error(_("Input failed")); - /* mandatory for si,sigma */ - - si = G_alloc_matrix(my, mx); - sigma = G_alloc_matrix(my, mx); - - /* memory allocation for output grids */ - - dif = G_alloc_fmatrix(my, mx); - if (erdep != NULL || et != NULL) - er = G_alloc_fmatrix(my, mx); + alloc_grids_sediment(); G_srand48(rand1); grad_check(); - - if (et != NULL) - erod(si); + init_grids_sediment(); /* treba dat output pre topoerdep */ main_loop(); - if (tserie == NULL) { + /* always true for sediment? */ + if (wp.tserie == NULL) { ii = output_data(0, 1.); if (ii != 1) G_fatal_error(_("Cannot write raster maps")); diff --git a/raster/r.sim/r.sim.water/main.c b/raster/r.sim/r.sim.water/main.c index 622e5b2..1e7e9a3 100644 --- a/raster/r.sim/r.sim.water/main.c +++ b/raster/r.sim/r.sim.water/main.c @@ -88,7 +88,7 @@ /********************************/ -#include <grass/waterglobs.h> +#include <grass/simlib.h> /****************************************/ @@ -102,6 +102,10 @@ int main(int argc, char *argv[]) double x_orig, y_orig; static int rand1 = 12345; struct GModule *module; + struct Cell_head cellhd; + struct WaterParams wp; + struct options parm; + struct flags flag; G_gisinit(argv[0]); @@ -298,48 +302,58 @@ int main(int argc, char *argv[]) G_get_set_window(&cellhd); - conv = G_database_units_to_meters_factor(); + WaterParams_init(&wp); - mixx = conv * cellhd.west; - maxx = conv * cellhd.east; - miyy = conv * cellhd.south; - mayy = conv * cellhd.north; + wp.conv = G_database_units_to_meters_factor(); - stepx = cellhd.ew_res * conv; - stepy = cellhd.ns_res * conv; + G_debug(3, "Conversion factor is set to: %f", wp.conv); + + wp.mixx = wp.conv * cellhd.west; + wp.maxx = wp.conv * cellhd.east; + wp.miyy = wp.conv * cellhd.south; + wp.mayy = wp.conv * cellhd.north; + + wp.stepx = cellhd.ew_res * wp.conv; + wp.stepy = cellhd.ns_res * wp.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; - rain = parm.rain->answer; - infil = parm.infil->answer; - traps = parm.traps->answer; - manin = parm.manin->answer; - depth = parm.depth->answer; - disch = parm.disch->answer; - err = parm.err->answer; - outwalk = parm.outwalk->answer; - - sscanf(parm.niter->answer, "%d", ×ec); - sscanf(parm.outiter->answer, "%d", &iterout); - sscanf(parm.diffc->answer, "%lf", &frac); - sscanf(parm.hmax->answer, "%lf", &hhmax); - sscanf(parm.halpha->answer, "%lf", &halpha); - sscanf(parm.hbeta->answer, "%lf", &hbeta); + wp.step = (wp.stepx + wp.stepy) / 2.; + wp.mx = cellhd.cols; + wp.my = cellhd.rows; + x_orig = cellhd.west * wp.conv; + y_orig = cellhd.south * wp.conv; /* do we need this? */ + wp.xmin = 0.; + wp.ymin = 0.; + wp.xp0 = wp.xmin + wp.stepx / 2.; + wp.yp0 = wp.ymin + wp.stepy / 2.; + wp.xmax = wp.xmin + wp.stepx * (float)wp.mx; + wp.ymax = wp.ymin + wp.stepy * (float)wp.my; + + G_debug(3, "xmax: %f, ymax: %f", wp.xmax, wp.ymax); + + wp.ts = flag.tserie->answer; + + wp.elevin = parm.elevin->answer; + wp.dxin = parm.dxin->answer; + wp.dyin = parm.dyin->answer; + wp.rain = parm.rain->answer; + wp.infil = parm.infil->answer; + wp.traps = parm.traps->answer; + wp.manin = parm.manin->answer; + wp.depth = parm.depth->answer; + wp.disch = parm.disch->answer; + wp.err = parm.err->answer; + wp.outwalk = parm.outwalk->answer; + + G_debug(3, "Parsing numeric parameters"); + + sscanf(parm.niter->answer, "%d", &wp.timesec); + sscanf(parm.outiter->answer, "%d", &wp.iterout); + sscanf(parm.diffc->answer, "%lf", &wp.frac); + sscanf(parm.hmax->answer, "%lf", &wp.hhmax); + sscanf(parm.halpha->answer, "%lf", &wp.halpha); + sscanf(parm.hbeta->answer, "%lf", &wp.hbeta); + + G_debug(3, "Parsing rain parameters"); /* if no rain map input, then: */ if (parm.rain->answer == NULL) { @@ -347,28 +361,28 @@ int main(int argc, char *argv[]) /* if no rain unique value input */ if (parm.rainval->answer == NULL) { /*No rain input so use default */ - sscanf(RAINVAL, "%lf", &rain_val); + sscanf(RAINVAL, "%lf", &wp.rain_val); /* if rain unique input exist, load it */ } else { /*Unique value input only */ - sscanf(parm.rainval->answer, "%lf", &rain_val); + sscanf(parm.rainval->answer, "%lf", &wp.rain_val); } /* if Rain map exists */ } else { /*Map input, so set rain_val to -999.99 */ if (parm.rainval->answer == NULL) { - rain_val = -999.99; + wp.rain_val = -999.99; } else { /*both map and unique value exist */ /*Choose the map, discard the unique value */ - rain_val = -999.99; + wp.rain_val = -999.99; } } /* Report the final value of rain_val */ - G_debug(3, "rain_val is set to: %f\n", rain_val); + G_debug(3, "rain_val is set to: %f\n", wp.rain_val); /* if no Mannings map, then: */ if (parm.manin->answer == NULL) { @@ -376,28 +390,28 @@ int main(int argc, char *argv[]) /* if no Mannings unique value input */ if (parm.maninval->answer == NULL) { /*No Mannings input so use default */ - sscanf(MANINVAL, "%lf", &manin_val); + sscanf(MANINVAL, "%lf", &wp.manin_val); /* if Mannings unique input value exists, load it */ } else { /*Unique value input only */ - sscanf(parm.maninval->answer, "%lf", &manin_val); + sscanf(parm.maninval->answer, "%lf", &wp.manin_val); } /* if Mannings map exists */ } else { /* Map input, set manin_val to -999.99 */ if (parm.maninval->answer == NULL) { - manin_val = -999.99; + wp.manin_val = -999.99; } else { /*both map and unique value exist */ /*Choose map, discard the unique value */ - manin_val = -999.99; + wp.manin_val = -999.99; } } /* Report the final value of manin_val */ - G_debug(1, "manin_val is set to: %f\n", manin_val); + G_debug(1, "manin_val is set to: %f\n", wp.manin_val); /* if no infiltration map, then: */ if (parm.infil->answer == NULL) { @@ -405,67 +419,62 @@ int main(int argc, char *argv[]) /*if no infiltration unique value input */ if (parm.infilval->answer == NULL) { /*No infiltration unique value so use default */ - sscanf(INFILVAL, "%lf", &infil_val); + sscanf(INFILVAL, "%lf", &wp.infil_val); /* if infiltration unique value exists, load it */ } else { /*unique value input only */ - sscanf(parm.infilval->answer, "%lf", &infil_val); + sscanf(parm.infilval->answer, "%lf", &wp.infil_val); } /* if infiltration map exists */ } else { /* Map input, set infil_val to -999.99 */ if (parm.infilval->answer == NULL) { - infil_val = -999.99; + wp.infil_val = -999.99; } else { /*both map and unique value exist */ /*Choose map, discard the unique value */ - infil_val = -999.99; + wp.infil_val = -999.99; } } /* Report the final value of infil_val */ - G_debug(1, "infil_val is set to: %f\n", infil_val); + G_debug(1, "infil_val is set to: %f\n", wp.infil_val); /* Recompute timesec from user input in minutes * to real timesec in seconds */ - timesec = timesec * 60.0; - iterout = iterout * 60.0; - if ((timesec / iterout) > 100.0 && ts == 1) + wp.timesec = wp.timesec * 60.0; + wp.iterout = wp.iterout * 60.0; + if ((wp.timesec / wp.iterout) > 100.0 && wp.ts == 1) G_message(_("More than 100 files are going to be created !!!!!")); /* compute how big the raster is and set this to appr 2 walkers per cell */ if (parm.nwalk->answer == NULL) { - maxwa = mx * my * 2; - rwalk = (double)(mx * my * 2.); - G_message(_("default nwalk=%d, rwalk=%f"), maxwa, rwalk); + wp.maxwa = wp.mx * wp.my * 2; + wp.rwalk = (double)(wp.mx * wp.my * 2.); + G_message(_("default nwalk=%d, rwalk=%f"), wp.maxwa, wp.rwalk); } else { - sscanf(parm.nwalk->answer, "%d", &maxwa); - rwalk = (double)maxwa; + sscanf(parm.nwalk->answer, "%d", &wp.maxwa); + wp.rwalk = (double)wp.maxwa; } /* rwalk = (double) maxwa; */ - if (conv != 1.0) - G_message(_("Using metric conversion factor %f, step=%f"), conv, - step); + if (wp.conv != 1.0) + G_message(_("Using metric conversion factor %f, step=%f"), wp.conv, + wp.step); + + init_library_globals(&wp); - if ((depth == NULL) && (disch == NULL) && (err == NULL)) + if ((wp.depth == NULL) && (wp.disch == NULL) && (wp.err == NULL)) G_warning(_("You are not outputting any raster maps")); ret_val = input_data(); if (ret_val != 1) G_fatal_error(_("Input failed")); - - /* memory allocation for output grids */ - G_debug(1, "beginning memory allocation for output grids"); - - gama = G_alloc_matrix(my, mx); - if (err != NULL) - gammas = G_alloc_matrix(my, mx); - dif = G_alloc_fmatrix(my, mx); + alloc_grids_water(); G_debug(1, "seeding randoms"); G_srand48(rand1); diff --git a/raster/r.sim/simlib/Makefile b/raster/r.sim/simlib/Makefile index 1595440..3d3b5f9 100644 --- a/raster/r.sim/simlib/Makefile +++ b/raster/r.sim/simlib/Makefile @@ -9,7 +9,4 @@ LIB = SIM include $(MODULE_TOPDIR)/include/Make/Lib.make -default: $(ARCH_INCDIR)/waterglobs.h lib - -$(ARCH_INCDIR)/waterglobs.h: waterglobs.h - cp waterglobs.h $(ARCH_INCDIR)/waterglobs.h +default: $(ARCH_INCDIR)/waterglobs.h $(ARCH_INCDIR)/simlib.h lib diff --git a/raster/r.sim/simlib/hydro.c b/raster/r.sim/simlib/hydro.c index 5002dbf..aa79ac3 100644 --- a/raster/r.sim/simlib/hydro.c +++ b/raster/r.sim/simlib/hydro.c @@ -24,6 +24,7 @@ #include <grass/glocale.h> #include <grass/waterglobs.h> +#include <grass/simlib.h> /* * Soeren 8. Mar 2011 TODO: @@ -32,8 +33,6 @@ * */ -struct options parm; -struct flags flag; struct _points points; char *elevin; @@ -43,11 +42,12 @@ char *rain; char *infil; char *traps; char *manin; -/* char *observation; */ char *depth; char *disch; char *err; -char *outwalk; +char *outwalk; +char *observation; +char *logfile; char *mapset; char *mscale; char *tserie; @@ -68,8 +68,6 @@ char *infilval; struct seed seed; -struct Cell_head cellhd; - double xmin, ymin, xmax, ymax; double mayy, miyy, maxx, mixx; int mx, my; diff --git a/raster/r.sim/simlib/input.c b/raster/r.sim/simlib/input.c index 7b43671..1cbddf5 100644 --- a/raster/r.sim/simlib/input.c +++ b/raster/r.sim/simlib/input.c @@ -7,6 +7,7 @@ #include <grass/glocale.h> #include <grass/linkm.h> #include <grass/gmath.h> +#include <grass/simlib.h> #include <grass/waterglobs.h> @@ -18,6 +19,254 @@ static double ** create_double_matrix(int rows, int cols, double fill_value); static void copy_matrix_undef_double_to_float_values(int rows, int cols, double **source, float **target); static void copy_matrix_undef_float_values(int rows, int cols, float **source, float **target); +/*! + * \brief Initialize WaterParams structure. + */ +void WaterParams_init(struct WaterParams *wp) +{ + /* this is little bit lengthy and perhaps error-prone + * but it simplifies initialization since then there is no + * difference in between initialization in water and sediment + * for the variables which are not used and would have been + * initialized if they were just global variables */ + wp->ymin = 0; + wp->xmax = 0; + wp->ymax = 0; + wp->mayy = 0; + wp->miyy = 0; + wp->maxx = 0; + wp->mixx = 0; + wp->mx = 0; + wp->my = 0; + wp->mx2 = 0; + wp->my2 = 0; + + wp->bxmi = 0; + wp->bymi = 0; + wp->bxma = 0; + wp->byma = 0; + wp->bresx = 0; + wp->bresy = 0; + wp->maxwab = 0; + wp->step = 0; + wp->conv = 0; + + wp->frac = 0; + wp->bxmi = 0; + wp->bymi = 0; + + wp->hbeta = 0; + wp->hhmax = 0; + wp->sisum = 0; + wp->vmean = 0; + wp->infsum = 0; + wp->infmean = 0; + wp->maxw = 0; + wp->maxwa = 0; + wp->nwalk = 0; + wp->rwalk = 0; + wp->bresx = 0; + wp->bresy = 0; + wp->xrand = 0; + wp->yrand = 0; + wp->stepx = 0; + wp->stepy = 0; + wp->xp0 = 0; + wp->yp0 = 0; + wp->chmean = 0; + wp->si0 = 0; + wp->deltap = 0; + wp->deldif = 0; + wp->cch = 0; + wp->hhc = 0; + wp->halpha = 0; + wp->eps = 0; + wp->maxwab = 0; + wp->nstack = 0; + wp->iterout = 0; + wp->mx2o = 0; + wp->my2o = 0; + wp->miter = 0; + wp->nwalka = 0; + wp->timec = 0; + wp->ts = 0; + wp->timesec = 0; + + wp->rain_val = 0; + wp->manin_val = 0; + wp->infil_val = 0; + + wp->elevin = NULL; + wp->dxin = NULL; + wp->dyin = NULL; + wp->rain = NULL; + wp->infil = NULL; + wp->traps = NULL; + wp->manin = NULL; + wp->depth = NULL; + wp->disch = NULL; + wp->err = NULL; + wp->outwalk = NULL; + wp->observation = NULL; + wp->logfile = NULL; + wp->mapset = NULL; + wp->mscale = NULL; + wp->tserie = NULL; + + wp->wdepth = NULL; + wp->detin = NULL; + wp->tranin = NULL; + wp->tauin = NULL; + wp->tc = NULL; + wp->et = NULL; + wp->conc = NULL; + wp->flux = NULL; + wp->erdep = NULL; + + wp->rainval = NULL; + wp->maninval = NULL; + wp->infilval = NULL; +} + +/*! + * \brief Initialize global variables in the library. + */ +void init_library_globals(struct WaterParams *wp) +{ + /* this is little bit lengthy and perhaps error-prone + * but it separates library from its interface */ + ymin = wp->ymin; + xmax = wp->xmax; + ymax = wp->ymax; + mayy = wp->mayy; + miyy = wp->miyy; + maxx = wp->maxx; + mixx = wp->mixx; + mx = wp->mx; + my = wp->my; + mx2 = wp->mx2; + my2 = wp->my2; + + bxmi = wp->bxmi; + bymi = wp->bymi; + bxma = wp->bxma; + byma = wp->byma; + bresx = wp->bresx; + bresy = wp->bresy; + maxwab = wp->maxwab; + step = wp->step; + conv = wp->conv; + + frac = wp->frac; + bxmi = wp->bxmi; + bymi = wp->bymi; + + hbeta = wp->hbeta; + hhmax = wp->hhmax; + sisum = wp->sisum; + vmean = wp->vmean; + infsum = wp->infsum; + infmean = wp->infmean; + maxw = wp->maxw; + maxwa = wp->maxwa; + nwalk = wp->nwalk; + rwalk = wp->rwalk; + bresx = wp->bresx; + bresy = wp->bresy; + xrand = wp->xrand; + yrand = wp->yrand; + stepx = wp->stepx; + stepy = wp->stepy; + xp0 = wp->xp0; + yp0 = wp->yp0; + chmean = wp->chmean; + si0 = wp->si0; + deltap = wp->deltap; + deldif = wp->deldif; + cch = wp->cch; + hhc = wp->hhc; + halpha = wp->halpha; + eps = wp->eps; + maxwab = wp->maxwab; + nstack = wp->nstack; + iterout = wp->iterout; + mx2o = wp->mx2o; + my2o = wp->my2o; + miter = wp->miter; + nwalka = wp->nwalka; + timec = wp->timec; + ts = wp->ts; + timesec = wp->timesec; + + rain_val = wp->rain_val; + manin_val = wp->manin_val; + infil_val = wp->infil_val; + + elevin = wp->elevin; + dxin = wp->dxin; + dyin = wp->dyin; + rain = wp->rain; + infil = wp->infil; + traps = wp->traps; + manin = wp->manin; + depth = wp->depth; + disch = wp->disch; + err = wp->err; + outwalk = wp->outwalk; + observation = wp->observation; + logfile = wp->logfile; + mapset = wp->mapset; + mscale = wp->mscale; + tserie = wp->tserie; + + wdepth = wp->wdepth; + detin = wp->detin; + tranin = wp->tranin; + tauin = wp->tauin; + tc = wp->tc; + et = wp->et; + conc = wp->conc; + flux = wp->flux; + erdep = wp->erdep; + + rainval = wp->rainval; + maninval = wp->maninval; + infilval = wp->infilval; +} + +/* we do the allocation inside because we anyway need to set the variables */ + +void alloc_grids_water() +{ + /* memory allocation for output grids */ + G_debug(1, "beginning memory allocation for output grids"); + + gama = G_alloc_matrix(my, mx); + if (err != NULL) + gammas = G_alloc_matrix(my, mx); + dif = G_alloc_fmatrix(my, mx); +} + +void alloc_grids_sediment() +{ + /* mandatory for si,sigma */ + + si = G_alloc_matrix(my, mx); + sigma = G_alloc_matrix(my, mx); + + /* memory allocation for output grids */ + + dif = G_alloc_fmatrix(my, mx); + if (erdep != NULL || et != NULL) + er = G_alloc_fmatrix(my, mx); +} + +void init_grids_sediment() +{ + /* this should be fulfilled for sediment but not water */ + if (et != NULL) + erod(si); +} /* ************************************************************** */ /* GRASS input procedures, allocations */ @@ -34,7 +283,7 @@ static void copy_matrix_undef_float_values(int rows, int cols, float **source, int input_data(void) { int rows = my, cols = mx; /* my and mx are global variables */ - double unitconv = 0.0000002; /* mm/hr to m/s */ + double unitconv = 0.000000278; /* mm/hr to m/s */ int if_rain = 0; G_debug(1, "Running MAR 2011 version, started modifications on 20080211"); diff --git a/raster/r.sim/simlib/observation_points.c b/raster/r.sim/simlib/observation_points.c index aef985b..6725b78 100644 --- a/raster/r.sim/simlib/observation_points.c +++ b/raster/r.sim/simlib/observation_points.c @@ -19,24 +19,26 @@ void create_observation_points() struct line_cats *cts; double x, y; int type, cat, i; + struct Cell_head cellhd; - if(parm.observation->answer != NULL) + if(observation != NULL) if_log += 1; - if(parm.logfile->answer != NULL) + if(logfile != NULL) if_log += 1; /* Nothing to do */ if(if_log == 0) return; + /* why both are required ? */ if(if_log == 1) G_fatal_error("Observation vector map and logfile must be provided"); Vect_set_open_level(1); - if (Vect_open_old(&Map, parm.observation->answer, "") < 0) - G_fatal_error(_("Unable to open vector map <%s>"), parm.observation->answer); + if (Vect_open_old(&Map, observation, "") < 0) + G_fatal_error(_("Unable to open vector map <%s>"), observation); Vect_rewind(&Map); @@ -46,6 +48,9 @@ void create_observation_points() /* Initialize point structure */ init_points(&points, 128); + /* get the current computational region set in the runtime */ + G_get_set_window(&cellhd); + /* Read all vector points */ while(1) { type = Vect_read_next_line(&Map, pts, cts); @@ -56,7 +61,7 @@ void create_observation_points() if(type == -1) { Vect_close(&Map); - G_fatal_error(_("Unable to read points from map %s"), parm.observation->answer); + G_fatal_error(_("Unable to read points from map %s"), observation); } if(type == GV_POINT) { @@ -74,10 +79,10 @@ void create_observation_points() Vect_close(&Map); /* Open the logfile */ - points.output = fopen(parm.logfile->answer, "w"); + points.output = fopen(logfile, "w"); if(points.output == NULL) - G_fatal_error(_("Unable to open observation logfile %s for writing"), parm.logfile->answer); + G_fatal_error(_("Unable to open observation logfile %s for writing"), logfile); points.is_open = 1; diff --git a/raster/r.sim/simlib/output.c b/raster/r.sim/simlib/output.c index 355fce2..f29995e 100644 --- a/raster/r.sim/simlib/output.c +++ b/raster/r.sim/simlib/output.c @@ -122,7 +122,7 @@ int output_data(int tt, double ft) /* Write the output walkers */ output_walker_as_vector(tt_minutes, ndigit, ×tamp); - Rast_set_window(&cellhd); + /* we write in the same region as we used for reading */ if (my != Rast_window_rows()) G_fatal_error("OOPS: rows changed from %d to %d", mx, @@ -636,7 +636,7 @@ int output_et() /* float a1,a2; */ - Rast_set_window(&cellhd); + /* we write in the same region as we used for reading */ if (et) { et_cell = Rast_allocate_f_buf(); diff --git a/raster/r.sim/simlib/simlib.h b/raster/r.sim/simlib/simlib.h new file mode 100644 index 0000000..3747302 --- /dev/null +++ b/raster/r.sim/simlib/simlib.h @@ -0,0 +1,96 @@ +#ifndef __SIMLIB_H__ +#define __SIMLIB_H__ + +/*! \file simlib.h + * \brief This is the interface for the simlib (SIMWE) library. + */ + +struct WaterParams +{ + double xmin, ymin, xmax, ymax; + double mayy, miyy, maxx, mixx; + int mx, my; + int mx2, my2; + + double bxmi, bymi, bxma, byma, bresx, bresy; + int maxwab; + double step, conv; + + double frac; + + double hbeta; + double hhmax, sisum, vmean; + double infsum, infmean; + int maxw, maxwa, nwalk; + double rwalk, xrand, yrand; + double stepx, stepy, xp0, yp0; + double chmean, si0, deltap, deldif, cch, hhc, halpha; + double eps; + int nstack; + int iterout, mx2o, my2o; + int miter, nwalka; + double timec; + int ts, timesec; + + double rain_val; + double manin_val; + double infil_val; + + char *elevin; + char *dxin; + char *dyin; + char *rain; + char *infil; + char *traps; + char *manin; + char *depth; + char *disch; + char *err; + char *outwalk; + char *observation; + char *logfile; + char *mapset; + char *mscale; + char *tserie; + + char *wdepth; + char *detin; + char *tranin; + char *tauin; + char *tc; + char *et; + char *conc; + char *flux; + char *erdep; + + char *rainval; + char *maninval; + char *infilval; +}; + +void WaterParams_init(struct WaterParams *wp); +void init_library_globals(struct WaterParams *wp); +void alloc_grids_water(); +void alloc_grids_sediment(); +void init_grids_sediment(); + +int input_data(void); +int grad_check(void); +void main_loop(void); +int output_data(int, double); + +struct options +{ + struct Option *elevin, *dxin, *dyin, *rain, *infil, *traps, *manin, + *observation, *depth, *disch, *err, *outwalk, *nwalk, *niter, *outiter, + *density, *diffc, *hmax, *halpha, *hbeta, *wdepth, *detin, *tranin, + *tauin, *tc, *et, *conc, *flux, *erdep, *rainval, *maninval, + *infilval, *logfile; +}; + +struct flags +{ + struct Flag *mscale, *tserie; +}; + +#endif /* __SIMLIB_H__ */ diff --git a/raster/r.sim/simlib/waterglobs.h b/raster/r.sim/simlib/waterglobs.h index 86efaed..324edf1 100644 --- a/raster/r.sim/simlib/waterglobs.h +++ b/raster/r.sim/simlib/waterglobs.h @@ -14,11 +14,12 @@ extern char *rain; extern char *infil; extern char *traps; extern char *manin; -/* extern char *observation; */ extern char *depth; extern char *disch; extern char *err; extern char *outwalk; +extern char *observation; +extern char *logfile; extern char *mapset; extern char *mscale; extern char *tserie; @@ -37,24 +38,6 @@ extern char *rainval; extern char *maninval; extern char *infilval; -struct options -{ - struct Option *elevin, *dxin, *dyin, *rain, *infil, *traps, *manin, - *observation, *depth, *disch, *err, *outwalk, *nwalk, *niter, *outiter, - *density, *diffc, *hmax, *halpha, *hbeta, *wdepth, *detin, *tranin, - *tauin, *tc, *et, *conc, *flux, *erdep, *rainval, *maninval, - *infilval, *logfile; -}; - -extern struct options parm; - -struct flags -{ - struct Flag *mscale, *tserie; -}; - -extern struct flags flag; - struct seed { long int is1, is2; @@ -62,9 +45,6 @@ struct seed extern struct seed seed; - -extern struct Cell_head cellhd; - struct _points { double *x; /* x coor for each point */ @@ -77,11 +57,7 @@ struct _points }; extern struct _points points; -extern int input_data(void); -extern int grad_check(void); extern void erod(double **); -extern void main_loop(void); -extern int output_data(int, double); extern int output_et(void); extern double simwe_rand(void); extern double gasdev(void); diff --git a/raster/r.sim/test/test.sh b/raster/r.sim/test/test.sh new file mode 100755 index 0000000..58a1891 --- /dev/null +++ b/raster/r.sim/test/test.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +# assumes full NC SPM + +# execute the following in old version in a separate mapset +# the switch to another mapset and execute it with a new version + +g.region rural_1m res=2 -p +v.surf.rst -d input=elev_lid792_bepts elevation=elev_lid792_2m slope=dx_2m aspect=dy_2m tension=15 smooth=1.5 npmin=150 +r.sim.water -t elevation=elev_lid792_2m dx=dx_2m dy=dy_2m rain_value=50 infil_value=0 man_value=0.05 depth=wdp_2m discharge=disch_2m nwalkers=100000 niterations=120 output_step=20 +r.mapcalc "tranin = 0.001" +r.mapcalc "detin = 0.001" +r.mapcalc "tauin = 0.01" +g.copy rast=wdp_2m.120,wdp_2m +r.sim.sediment elevation=elev_lid792_2m dx=dx_2m dy=dy_2m water_depth=wdp_2m detachment_coeff=detin transport_coeff=tranin shear_stress=tauin man_value=0.05 nwalkers=1000000 niterations=120 transport_capacity=tcapacity tlimit_erosion_deposition=erdepmax sediment_flux=sedflow erosion_deposition=erdepsimwe + +g.copy rast=disch_2m.120,disch_2m + +# execute the following only in one of the mapsets + +REF_MAPSET=rsim_before + +r.mapcalc "elev_lid792_2m_diff = elev_lid792_2m@$REF_MAPSET - elev_lid792_2m" +r.mapcalc "dx_2m_diff = dx_2m@$REF_MAPSET - " +r.mapcalc "dy_2m_diff = dy_2m@$REF_MAPSET - dy_2m" + +r.mapcalc "wdp_2m_diff = wdp_2m@$REF_MAPSET - wdp_2m" +r.mapcalc "disch_2m_diff = disch_2m@$REF_MAPSET - disch_2m" + +r.mapcalc "tcapacity_diff = tcapacity@$REF_MAPSET - tcapacity" +r.mapcalc "erdepmax_diff = erdepmax@$REF_MAPSET - erdepmax" +r.mapcalc "sedflow_diff = sedflow@$REF_MAPSET - sedflow" +r.mapcalc "erdepsimwe_diff = erdepsimwe@$REF_MAPSET - erdepsimwe" + +# expecting zeros + +r.univar elev_lid792_2m_diff +r.univar dx_2m_diff +r.univar dy_2m_diff + +r.univar wdp_2m_diff +r.univar disch_2m_diff + +r.univar tcapacity_diff +r.univar erdepmax_diff +r.univar sedflow_diff +r.univar erdepsimwe_diff diff --git a/raster/r.water.outlet/r.water.outlet.html b/raster/r.water.outlet/r.water.outlet.html index ffae747..8cbd27d 100644 --- a/raster/r.water.outlet/r.water.outlet.html +++ b/raster/r.water.outlet/r.water.outlet.html @@ -35,8 +35,8 @@ Carolina sample dataset</a> region: g.region raster=elev_lid792_1m -p # the watershed outlet position should be placed on a stream (from # accumulation map): -r.watershed elev_lid792_1m thresh=5000 accum=accum_5K drain=draindir_5K output=basin_5K -r.water.outlet input=draindir_5K output=basin_A30 coord=638740.423248,220271.519225 +r.watershed elev_lid792_1m threshold=5000 accumulation=accum_5K drainage=draindir_5K basin=basin_5K +r.water.outlet input=draindir_5K output=basin_A30 coordinates=638740.423248,220271.519225 d.mon wx0 d.rast map=accum_5K @@ -67,4 +67,4 @@ d.his h=accum_5K i=basin_A30 Charles Ehlschlaeger, U.S. Army Construction Engineering Research Laboratory <p> -<i>Last changed: $Date: 2014-12-19 22:55:37 +0100 (Fri, 19 Dec 2014) $</i> +<i>Last changed: $Date: 2016-04-26 02:49:55 +0200 (Tue, 26 Apr 2016) $</i> diff --git a/scripts/g.search.modules/g.search.modules.html b/scripts/g.search.modules/g.search.modules.html index 8910592..5faf96c 100644 --- a/scripts/g.search.modules/g.search.modules.html +++ b/scripts/g.search.modules/g.search.modules.html @@ -1,6 +1,6 @@ <h2>DESCRIPTION</h2> -<em>r.search.module</em> searches for given keyword in GRASS modules name, +<em>g.search.module</em> searches for given keyword in GRASS modules name, description, keywords and optionally manpages too. <h2>NOTES</h2> @@ -67,4 +67,4 @@ db.select Jachym Cepicky, OpenGeoLabs s.r.o., Czech Republic <p> -<i>Last changed: $Date: 2015-12-01 09:49:42 +0100 (Tue, 01 Dec 2015) $</i> +<i>Last changed: $Date: 2016-04-21 16:34:29 +0200 (Thu, 21 Apr 2016) $</i> diff --git a/scripts/r.pack/r.pack.html b/scripts/r.pack/r.pack.html index 998fa32..424bc30 100644 --- a/scripts/r.pack/r.pack.html +++ b/scripts/r.pack/r.pack.html @@ -49,4 +49,4 @@ Original Bash script written by Hamish Bowman, Otago University, New Zealand Converted to Python and updated for GRASS 7 by Martin Landa, Czech Technical University in Prague, Czech Republic <p> -<i>Last changed: $Date: 2016-04-14 09:01:56 +0200 (Do, 14. Apr 2016) $</i> +<i>Last changed: $Date: 2016-04-14 09:01:56 +0200 (Thu, 14 Apr 2016) $</i> diff --git a/vector/v.db.select/main.c b/vector/v.db.select/main.c index f0cbdd2..7d8bea2 100644 --- a/vector/v.db.select/main.c +++ b/vector/v.db.select/main.c @@ -43,7 +43,7 @@ int main(int argc, char **argv) struct field_info *Fi; int ncols, col, more; struct Map_info Map; - char query[1024]; + char query[DB_SQL_MAX]; struct ilist *list_lines; char *fs, *vs; struct bound_box *min_box, *line_box; diff --git a/vector/v.net/v.net.html b/vector/v.net/v.net.html index f38713e..4f2a480 100644 --- a/vector/v.net/v.net.html +++ b/vector/v.net/v.net.html @@ -39,9 +39,9 @@ the <em>connect</em> operation, some lines will share the same category. In order to assign unique costs to each line, a new layer needs to be created with<br> <!-- like this it is rather useless, still to be improved (eg as a full example below!) --> -<tt>v.category map=yourmap operation=add cat=1 step=1 layer=3</tt><br> +<tt>v.category map=yourmap option=add cat=1 step=1 layer=3 output=newmap</tt><br> followed by<br> -<tt>v.db.addtable map=yourmap layer=3 table=tablename</tt>.</li> +<tt>v.db.addtable map=newmap layer=3 table=tablename</tt>.</li> <li>Create nodes and arcs from a vector line/boundary file using the <em>node</em> operation. This is useful if you are mostly interested @@ -132,7 +132,7 @@ The examples are <a href="http://www.grassbook.org/datasets/datasets-3rd-edition <div class="code"><pre> v.net input=streets_wake output=streets_node operation=nodes # verify result -v.category streets_node operation=report +v.category streets_node option=report </pre></div> <h3>Merge in nodes from a separate map within given threshold</h3> @@ -141,7 +141,7 @@ v.category streets_node operation=report v.net input=streets_wake points=firestations out=streets_net \ operation=connect threshold=500 # verify result -v.category streets_net operation=report +v.category streets_net option=report </pre></div> The nodes are stored in layer 2 unless <tt>node_layer=1</tt> is used. @@ -161,7 +161,7 @@ Option 1: Save the file (e.g. "points.txt") and generate the map: v.net points=geodetic_swwake_pts output=geodetic_swwake_pts_net \ operation=arcs file=points.txt # verify result -v.category geodetic_swwake_pts_net operation=report +v.category geodetic_swwake_pts_net option=report </pre></div> <p> @@ -175,7 +175,7 @@ v.net points=geodetic_swwake_pts output=geodetic_swwake_pts_net \ EOF # verify result -v.category geodetic_swwake_pts_net operation=report +v.category geodetic_swwake_pts_net option=report </pre></div> <h2>SEE ALSO</h2> @@ -213,4 +213,4 @@ Prague, Czech Republic (operation 'connect' and 'arcs')<br> Markus Metz: important fixes and improvements <p> -<i>Last changed: $Date: 2015-10-27 16:43:43 +0100 (Tue, 27 Oct 2015) $</i> +<i>Last changed: $Date: 2016-04-30 21:04:20 +0200 (Sat, 30 Apr 2016) $</i> -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/grass.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

