Opened 15 years ago

Closed 12 years ago

#669 closed enhancement (fixed)

let users save/load mapcalc expressions

Reported by: timmie Owned by: timmie
Priority: normal Milestone: 6.5.0
Component: wxGUI Version: svn-develbranch6
Keywords: map calculator, r.mapcalc Cc: grass-dev@…, martinl
CPU: x86-32 Platform: All

Description

The mapcalc expressions are sometimes long. Please enable a save/laod option.

The mapcalc expression files may have placefolders for raster files or reference particular rasters.

Attachments (2)

mcalc_builder.py (25.0 KB ) - added by timmie 14 years ago.
mcalc_builde mods
mcalc_builder_loadsave_diff.txt (8.1 KB ) - added by timmie 14 years ago.
a diff of the changes

Download all attachments as: .zip

Change History (26)

comment:1 by timmie, 15 years ago

Type: defectenhancement

comment:2 by hamish, 15 years ago

Milestone: 6.4.06.5.0

why not just cut & paste from a text file or redirect from a file on the command line? (r.mapcalc will accept input from stdin already)

comment:3 by martinl, 15 years ago

wxGUI in GRASS >= 65 uses combobox for showing history of commands. It can probably help. Also take a look at raster mapcalculator dialog (Raster -> Map calculator).

Martin

in reply to:  3 comment:4 by timmie, 15 years ago

@hamish: I was talking about the GUI version Raster -> Map calculator I know that I can save shell expressions or history to a text file.

Replying to martinl:

wxGUI in GRASS >= 65 uses combobox for showing history of commands. It can probably help. Also take a look at raster mapcalculator dialog (Raster -> Map calculator).

Yes, the combobox-history is helpful.

I mean in the Raster -> Map calculator there could be a button save and another for load where one can just save the expression. It could then be shared among projects and users.

comment:5 by martinl, 15 years ago

Keywords: map calculator added

in reply to:  description ; comment:6 by 1gray, 15 years ago

Replying to timmie:

The mapcalc expressions are sometimes long. Please enable a save/laod option. The mapcalc expression files may have placefolders for raster files or reference particular rasters.

This is already possible when using the command-line interface. Consider, e. g.:

  bash$ (r=baz ; a=foo ; b=bar ; r.mapcalc "\"$r\" = \"$a\" + \"$b\"")

Note that you can rely on all the Bash facilities here, like, e. g., looping constructs:

  bash$ (for i in $(seq 1 10) ; do
             r.mapcalc "\"result${i}\" = \"baz\" * \"foo${i}\" + \"bar${i}\""
         done)

After the snippet of code is tested, it may easily be shared with the colleagues using either:

  • shared local filesystem;
  • shared NFS or SMB/CIFS volume;
  • shared VCS or your own public DVCS repository;
  • a mailing list, a newsgroup or a Wiki page;
  • a WWW page;
  • or a sheer variety of other means.

IOW, all the requested functionality is, in fact, present in GRASS (except for the sharing part, but why should it be?) Therefore, I'm suggesting wontfix for this one.

in reply to:  6 comment:7 by glynn, 15 years ago

Replying to 1gray:

This is already possible when using the command-line interface. Consider, e. g.:

  bash$ (r=baz ; a=foo ; b=bar ; r.mapcalc "\"$r\" = \"$a\" + \"$b\"")

Note that r.mapcalc allows map names to be quoted using either single or double quotes, so the above can be written as:

  bash$ (r=baz ; a=foo ; b=bar ; r.mapcalc "'$r' = '$a' + '$b'")

This is probably clearer than using backslash and double-quote.

in reply to:  6 comment:8 by timmie, 15 years ago

Replying to 1gray:

Replying to timmie:

The mapcalc expressions are sometimes long. Please enable a save/laod option. The mapcalc expression files may have placefolders for raster files or reference particular rasters.

This is already possible when using the command-line interface. Consider, e. g.:

When talking about saving I meant from the wxGUI based map calculator. See below my component selection.

Thanks for your understanding.

comment:9 by hamish, 15 years ago

Keywords: r.mapcalc added

the SQL Builder GUI is another similar place where save-a-string might be useful as part of a GRASS Notepad collection.

|
|
|- [-] Mapcalc expressions
|   |
|   |-- A + B + sin(C)
|   |-- sqrt(A^2 + B^2)
|
|- [+] SQL expressions

comment:10 by hamish, 15 years ago

|
|- [+] Command line expressions
|
|- [+] Miscellanea

by timmie, 14 years ago

Attachment: mcalc_builder.py added

mcalc_builde mods

comment:11 by timmie, 14 years ago

Owner: changed from grass-dev@… to timmie

The attached file will offer options to save/load expressions to files. A Grass notepad is not included.

comment:12 by timmie, 14 years ago

I also tried to tackle: http://trac.osgeo.org/grass/ticket/923

But here I definately need help.

comment:13 by hamish, 14 years ago

Cc: grass-dev@… added

in reply to:  11 ; comment:14 by martinl, 14 years ago

Replying to timmie:

The attached file will offer options to save/load expressions to files. A Grass notepad is not included.

Next time please attach a diff file (generated by 'svn diff') rather then full file...

in reply to:  14 comment:15 by timmie, 14 years ago

Next time please attach a diff file (generated by 'svn diff') rather then full file...

Thanks for remembering! Do you wnat to receive a diff? Is use a BZR mirror. but the diff schould be the same.

by timmie, 14 years ago

a diff of the changes

comment:16 by timmie, 14 years ago

Hello, does this patch qualify for includion into GRASS?

comment:17 by timmie, 14 years ago

Sorry for instisting, but does this qualify or is there something wrong with my patch? I would welcome this feature a lot. Tired of copy paste to editors or taking screenshot of mapcalculator.

in reply to:  17 comment:18 by martinl, 14 years ago

Cc: martinl added

Replying to timmie:

Sorry for instisting, but does this qualify or is there something wrong with my patch? I would welcome this feature a lot. Tired of copy paste to editors or taking screenshot of mapcalculator.

Modified patch committed in r44068, testing welcomed. Thanks for the patch. Martin

comment:19 by timmie, 14 years ago

Thanks for attending this. And sorry for being instisting too much. you are also busy...

in reply to:  19 comment:20 by martinl, 14 years ago

Replying to timmie:

Thanks for attending this. And sorry for being instisting too much. you are also busy...

No problem. Can we close the ticket? Martin

comment:21 by timmie, 14 years ago

Just as note: Arc* programs also use *.exp extension to save SQL queries.

Thus we may decide to change the default file extension for mapcalc expressions to help users that work with both GIS suites.

comment:22 by timmie, 14 years ago

Thanks again for backproting the patch also.

Next task would be to enbale also saving/loading of queries (SQL). THese could then even be shared with QGIS. But that will be another bug.

comment:23 by timmie, 14 years ago

Platform: LinuxAll

in reply to:  22 comment:24 by wenzeslaus, 12 years ago

Resolution: fixed
Status: newclosed

Closing as fixed:

  • Saving and loading r.mapcalc expressions to file works for 6.4.3svn
  • Any file extension can by used (and default is none - no extension is added by default)

Other enhancements mentioned here (create a new ticked if you want them):

  • Saving and loading of SQL statements
  • Compatibility with QGIS
  • Some 'quick save', 'history' and 'recently used' functionality
Note: See TracTickets for help on using tickets.