Monday, January 7, 2013

Proposal: Geoscript console in uDig

Recently I proposed to add an Editor to uDig, which would support Geoscript scripting from within uDig. The full proposal (RFC) is here.

Since there were some comments/questions in the community and I think some small missunderstandings, I would like to give a small overview of what is there already and how it should work. I will not repeat here what already mentioned in the RFC.

Currently this is in proposal state and will get into uDig only if the PSC will vote in favour. That said, we are working already on it for a while now, so there is some to show.

1) Open the editor

Two new icons appear, the will allow to open the editor creating a new empty script or to open an existing script.


We will create a new one. The user will be prompted to save the new script to file and an empty editor is opened.






There are a few tool inside the editor, needed to start and stop scripts, or set the heap memory allowed to be used by a script or enable logging.

2) Script away, with command completion and syntax coloring

Inside the editor some basic command completion is available. For geoscript objects, as for example the widely use Geometry:


but also for methods, as for example the fromWKT, a handy way to create geometries on the fly:






You might have noted that first the completion proposals that start with the inserted text are suggested and after those also the once that simply contain the text.

You might also have noted that keywords have a nice syntax coloring, in order to make the script more readable... and often to help users to make sure they have no typos :)


3) run your script

Once you have something you want to run, simply push the start button. The script will be run through the Spatial Toolbox engine and print the output in the console view. Let's create two polygons and intersect them.


4) plot some result - missing imports

Geoscript needs you to define the modules you want to use in your script through the import directive, which is usually placed at the top of the script.

If we try to plot the result by simply adding the plotting directive, it will fail, because the plot module was not imported:


The editor supplies a quick way to import the most common modules, which can be useful for people starting with the scripting and that do not know where the modules are. Push the button at the right of the stop button and the imports are added to the top. After that the script will work:



5) Geoscript

Geoscript allows for some fun, the best way to get into it is to start from the tutorials page. Just to add one more complex example, lets see a script that can render a map, properly styled, to an image:



Guys it is 2013, a GIS needs a scripting engine!!
We started with the JGrass scripting years ago and failed. Now that geoscript is here, this sounds like the way to run.

Post a Comment