Ticket #669 (new enhancement)

Opened 3 years ago

Last modified 19 months ago

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
Platform: All CPU: x86-32

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

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

Change History

  Changed 3 years ago by timmie

  • type changed from defect to enhancement

  Changed 3 years ago by hamish

  • milestone changed from 6.4.0 to 6.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)

follow-up: ↓ 4   Changed 3 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

in reply to: ↑ 3   Changed 3 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.

  Changed 3 years ago by martinl

  • keywords map calculator added

in reply to: ↑ description ; follow-ups: ↓ 7 ↓ 8   Changed 3 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.

in reply to: ↑ 6   Changed 3 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.

in reply to: ↑ 6   Changed 3 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.

  Changed 3 years ago by hamish

  • keywords calculator, r.mapcalc added; calculator removed

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

  Changed 3 years ago by hamish

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

Changed 20 months ago by timmie

mcalc_builde mods

follow-up: ↓ 14   Changed 20 months 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.

  Changed 20 months ago by timmie

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

But here I definately need help.

  Changed 20 months ago by hamish

  • cc grass-dev@… added

in reply to: ↑ 11 ; follow-up: ↓ 15   Changed 20 months 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...

in reply to: ↑ 14   Changed 20 months 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 20 months ago by timmie

a diff of the changes

  Changed 20 months ago by timmie

Hello, does this patch qualify for includion into GRASS?

follow-up: ↓ 18   Changed 19 months 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.

in reply to: ↑ 17   Changed 19 months 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

follow-up: ↓ 20   Changed 19 months ago by timmie

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

in reply to: ↑ 19   Changed 19 months 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

  Changed 19 months 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.

  Changed 19 months 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.

  Changed 19 months ago by timmie

  • platform changed from Linux to All
Note: See TracTickets for help on using tickets.