Opened 11 years ago

Closed 8 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 10 years ago.
mcalc_builde mods
mcalc_builder_loadsave_diff.txt (8.1 KB) - added by timmie 10 years ago.
a diff of the changes

Download all attachments as: .zip

Change History (26)

comment:1 Changed 11 years ago by timmie

Type: defectenhancement

comment:2 Changed 11 years ago by hamish

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 Changed 11 years ago by 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).

Martin

comment:4 in reply to:  3 Changed 11 years ago by timmie

@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 Changed 11 years ago by martinl

Keywords: map calculator added

comment:6 in reply to:  description ; Changed 11 years ago by 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.:

  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.

comment:7 in reply to:  6 Changed 11 years ago by glynn

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.

comment:8 in reply to:  6 Changed 11 years ago by timmie

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 Changed 11 years ago by hamish

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 Changed 11 years ago by hamish

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

Changed 10 years ago by timmie

Attachment: mcalc_builder.py added

mcalc_builde mods

comment:11 Changed 10 years ago by timmie

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 Changed 10 years ago by timmie

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

But here I definately need help.

comment:13 Changed 10 years ago by hamish

Cc: grass-dev@… added

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

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...

comment:15 in reply to:  14 Changed 10 years ago by timmie

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.

Changed 10 years ago by timmie

a diff of the changes

comment:16 Changed 9 years ago by timmie

Hello, does this patch qualify for includion into GRASS?

comment:17 Changed 9 years ago by 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.

comment:18 in reply to:  17 Changed 9 years ago by martinl

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 Changed 9 years ago by timmie

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

comment:20 in reply to:  19 Changed 9 years ago by martinl

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 Changed 9 years ago by timmie

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 Changed 9 years ago by timmie

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 Changed 9 years ago by timmie

Platform: LinuxAll

comment:24 in reply to:  22 Changed 8 years ago by wenzeslaus

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.