#399: Added "backlink" functionality to r.walk, r.cost & r.drain
----------------------+-----------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Keywords: | Platform: All
Cpu: All |
----------------------+-----------------------------------------------------
I have updated the r.walk, r.cost and r.drain modules to include
"back-link raster" functionality. Currently the path created by
r.drain does not necessarily take THE path through a cost surface,
that the cost accumulation algorithm took to generate that cost
surface. My updates add an "outdir" raster as an output from the
r.drain and r.cost modules which creates a backlink raster, or a
raster surface of the movements made to create the cost surface
(recorded in degrees). I then modified r.drain to read this surface
when it's given the "-d" flag.
I have tested it on my win32/vista build (mingw/msys), but not on linux or
mac builds. Since this is my first patch, I have added extensive
commenting which can probably be removed later.
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Changes (by hamish):
* type: defect => enhancement
Comment:
Hi,
thanks for the patches,
some comments & cleanups:
- don't use C++ style //comments (see the SUBMITTING file)
- please run tools/grass_indent.sh on the code (see SUBMITTING...)
- comments like "//cn:added;" are redundant and should be removed. that
info & source heritage is available through the SVN history, which can be
annotated line by line in the viewVc web interface. a rule there is if it
doesn't help explain the code, it is noise which helps clutter & obfuscate
the code.
- the GRASS convention for angle is to use Cartesian theta, i.e. degrees
are counted CCW from East, not compass-style CW from North. Convert with "
90-angle".
- do not remove (valid) documentation from the help pages lightly, and
certainly do not remove prior authors from the AUTHORS section of the help
page! (I spotted Roger Miller was removed, maybe others) If you are unsure
<!-- comment it out -->.
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by cnielsen):
Update:
* C++ style comments removed
* indent used (I think, I got a "sed: invalid option -- i" msg)
* unnecessary comments removed
* angles changed to CCW from East
* The removal of Roger Miller was an accident caused by me overwriting
r.drain's description.html with r.walk's. My apologies for not catching
that before upload.
-Colin
ps. r.cost.2.patch is the same as r.cost.patch (not sure how to delete
attachments)
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by dylan):
r.cost.patch applies and compiles against GRASS64-SVN r34983
r.drain patch: error on applying to documentation, does not compile
(Stripping trailing CRs from patch.)
patching file main.c
(Stripping trailing CRs from patch.)
patching file description.html
Hunk #4 FAILED at 208.
1 out of 4 hunks FAILED -- saving rejects to file description.html.rej
main.c: In function â:
main.c:697: error: â undeclared (first use in this function)
main.c:697: error: (Each undeclared identifier is reported only once
main.c:697: error: for each function it appears in.)
make: *** [OBJ.i686-pc-linux-gnu/main.o] Error
r.walk.patch: applies with one error, and compiles
(Stripping trailing CRs from patch.)
patching file main.c
(Stripping trailing CRs from patch.)
patching file description.html
Hunk #4 FAILED at 149.
1 out of 4 hunks FAILED -- saving rejects to file description.html.rej
(Stripping trailing CRs from patch.)
patching file stash.h
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by glynn):
Replying to [comment:3 dylan]:
> r.cost.patch applies and compiles against GRASS64-SVN r34983
>
> r.drain patch: error on applying to documentation, does not compile
> patching file description.html
> Hunk !#4 FAILED at 208.
> r.walk.patch: applies with one error, and compiles
> patching file description.html
> Hunk !#4 FAILED at 149.
Both of these are due to the expanded $Date$ at the bottom of the file.
> main.c: In function â:
> main.c:697: error: â undeclared (first use in this function)
> main.c:697: error: (Each undeclared identifier is reported only once
> main.c:697: error: for each function it appears in.)
> make: *** [OBJ.i686-pc-linux-gnu/main.o] Error
I don't know what happened to your comment (cut/paste issue?), but this
should read:
{{{
main.c: In function `drain_cost':
main.c:697: error: `dir_name' undeclared (first use in this function)
}}}
Indeed, dir_name is local to main(), so it isn't visible in drain_cost().
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by dylan):
Replying to [comment:4 glynn]:
> Replying to [comment:3 dylan]:
> > r.cost.patch applies and compiles against GRASS64-SVN r34983
> >
> > r.drain patch: error on applying to documentation, does not compile
>
> > patching file description.html
> > Hunk !#4 FAILED at 208.
>
> > r.walk.patch: applies with one error, and compiles
>
> > patching file description.html
> > Hunk !#4 FAILED at 149.
>
> Both of these are due to the expanded $Date$ at the bottom of the file.
>
> > main.c: In function â:
> > main.c:697: error: â undeclared (first use in this function)
> > main.c:697: error: (Each undeclared identifier is reported only once
> > main.c:697: error: for each function it appears in.)
> > make: *** [OBJ.i686-pc-linux-gnu/main.o] Error
>
> I don't know what happened to your comment (cut/paste issue?), but this
should read:
> {{{
> main.c: In function `drain_cost':
> main.c:697: error: `dir_name' undeclared (first use in this function)
> }}}
> Indeed, dir_name is local to main(), so it isn't visible in
drain_cost().
Right. Forgot about the verbatim formatting...
I have attached a new patch against r34985 that compiles cleanly.
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by dylan):
OK Some real comments.
I have noticed that the patch r.cost gives a segmentation fault if the
outdir raster is not specified. The cost surface is identical between
r.cost in SVN and the patched version. The output from the patched r.drain
(without the new backlink functionality) is identical to the SVN version
of r.drain.
Attempting to use the outdir/indir options on r.cost/r.drain does not seem
to work. I get:
{{{
r.drain -d input=cost_new output=cost.drain_new vector_points=end
indir=cost_dir --o
Directional drain selected... checking for direction raster
Direction raster found <cost_dir>
Dev note: Adapted sites library used for vector points. (module should be
updated to GRASS 6 vector library)
ERROR: Raster map (·¿Óõ·>^[[?1;2c not a direction map
}}}
Probably related to my crappy hack job getting the patched r.drain to
compile.
Another thing. Patched r.cost and r.drain do not seem to be using the
standard GRASS command line parser, as partial arguments such as 'in'
(input) are not accepted as legal arguments.
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by glynn):
Replying to [comment:6 dylan]:
> Another thing. Patched r.cost and r.drain do not seem to be using the
standard GRASS command line parser, as partial arguments such as 'in'
(input) are not accepted as legal arguments.
The patches add options indir= and outdir=. With those options, in= and
out= are no longer unique prefixes; you would need to use at least inp=
and outp= to disambiguate.
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Comment (by cnielsen):
Thanks for all the comments. I believe I have fixed all the errors
mentioned above (except the description.html $date thing, I'm not sure how
to fix that one).
I removed the problem in r.drain that dylan mentioned... Something is
still needed there but I couldn't find a working solution. I wanted an
error to come up if the user put in an invalid direction raster, but the
NULL cell value was coming up as a false positive... If someone has an
idea let me know.
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Changes (by cnielsen):
* cc: michael.barton@asu.edu (added)
Comment:
I have now implemented vectorization in r.drain to solve the knight's move
errors discussed before. I have also adapted the patches to three
different source code branches to bring my work up to date.
630rc6* = grass-6.3.0RC6
64rel* = releasebranch_6_4
6dev* = develbranch_6
Once I can get grass7 (trunk) to compile on my mingw/msys, I'll create
patches for that version as well.
As far as I can tell everything works at this point, please test and let
me know if there are any problems. If there are no problems, I would
appreciate it if the patches could be committed. Thanks.
Michael
______________________________
C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
Tempe, AZ 85287-2402
USA
#399: Added "backlink" functionality to r.walk, r.cost & r.drain
--------------------------+-------------------------------------------------
Reporter: cnielsen | Owner: grass-dev@lists.osgeo.org
Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: Raster | Version: unspecified
Resolution: | Keywords:
Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Changes (by cnielsen):
* cc: michael.barton@asu.edu (added)
Comment:
I have now implemented vectorization in r.drain to solve the knight's move
errors discussed before. I have also adapted the patches to three
different source code branches to bring my work up to date.
630rc6* = grass-6.3.0RC6
64rel* = releasebranch_6_4
6dev* = develbranch_6
Once I can get grass7 (trunk) to compile on my mingw/msys, I'll create
patches for that version as well.
As far as I can tell everything works at this point, please test and let
me know if there are any problems. If there are no problems, I would
appreciate it if the patches could be committed. Thanks.
Michael
____________________
C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University