[GRASS-dev] [GRASS GIS] #2986: r.mapcalc with same variable on LHS and RHS
GRASS GIS
trac at osgeo.org
Thu Apr 21 05:58:02 PDT 2016
#2986: r.mapcalc with same variable on LHS and RHS
--------------------------+-------------------------
Reporter: mankoff | Owner: grass-dev@…
Type: defect | Status: closed
Priority: major | Milestone: 7.0.4
Component: Docs | Version: 7.0.3
Resolution: fixed | Keywords: r.mapcalc
CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Comment (by glynn):
Replying to [comment:5 mankoff]:
> Just to be clear, {{{LHS = RHS}}} **does** work. I've never actually had
it crash or return NULL or what appears to be invalid data when I've done
this. But perhaps it isn't guaranteed to work...
It works by coincidence rather than by design.
The data (cell/fcell) file and null bitmap are written to temporary files,
which are renamed into place when the map is closed. The metadata files
(cellhd, quant, histogram, categoriess, colour table, history, etc), are
stored in memory and written when the map is closed. So the output map
shouldn't change while it's being read.
A specific case which won't quite work is "r.mapcalc 'map = map'", because
that copies the categories, colour table and history from the input to the
output, but closing the output map will delete or replace those before the
copy occurs. If the logic is ever extended to cover more cases, those will
similarly fail.
Actually, I'm not sure that it will work on Windows, because at the point
that the data and null files are renamed, the original files are still
open for read (r.mapcalc never actually closes the input maps). That
should be easy to fix, though (call close_maps() from within execute()
before the loop which closes the output maps).
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2986#comment:6>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list