Tuesday, April 27, 2010

Debugging batch files

Creating Smallworld images often requires one or more batch files with myriads of environment variables. This link gives a good summary of various batch file debugging techniques.

[NOTE: a reader notified me that the referenced link is broken. You can find a cached version of it at Google here]

Friday, April 16, 2010

PDF as Export Format (not just for plotting anymore)

You are all aware that Smallworld has the ability to print maps to PDF.

Now, with FME, you can export Smallworld data to PDF. In this example I:
  • Imported some Cambridge demo db data (substations, cables, supply points)
  • Imported a Google Static Map based on the bounds of the Smallworld data
  • Exported to Geospatial PDF format which is readable with Adobe Reader
I apologize for not providing the actual files, but it seems that my online file repository is no longer available. I will include screen shots instead. You can click on the image to get the full size.

FME workspace...



Adobe Reader. Note the ability to show attributes for selected objects. You can also do "goto selected object".




This was just a very simple example of mashing together data from multiple sources (including Smallworld) and exporting to a format that even "Ken's grandpa can read*".

Adobe Reader is free and widely available on most computers. It seems to me that this would be one format that would lend itself well to an inexpensive mobile field solution.

* inside joke from the FMEOdyssey 2010 meeting in Denver in March.

Tuesday, April 13, 2010

SIAS client using Silverlight

As you are no doubt aware, most SIAS client applications use Java to build their front end. I saw something really cool today done by long-time Smallworld developer Poorya Khodaverdi. He has created a Silverlight-based web application that uses SIAS services. You can see his 5-minute demo here.

As he pointed out to me, this was just a rapid application development implementation. It should be easy enough to modify the client to whatever specs a user would want. While we may all have our differing opinions of Microsoft and their Silverlight framework, I do think that any technology that makes the user interface more pleasant to work with is worth having a look at.

You can find out more about this Silverlight/SIAS integration by contacting Poorya directly at pkhodaverdi@gmail.com

Saturday, April 3, 2010

Converting Coordinate System From Smallworld to FME

When setting up an FME Workspace to interact with Smallworld, you always want to be sure that your SWORLDSWAF reader/writer coordinate system is the same as your Smallworld session's Application Coordinate System (see discussion here). The post "Smallworld/FME Configuration Tips and Tricks" has a link to a slideshow that describes how to make sure that your Smallworld Application Coordinate System and FME SWORLDSWAF reader/writer coordinate systems match . The relevant information starts on slide 31.

I recently discovered another way of figuring out the FME COORDINATE_SYSTEM_DEF that corresponds to a Smallworld coordinate_system.

The FME Workbench's CoordinateSystemDescriptioConvertor Transformer (see example here) can take a Proj.4 coordinate system definition string and convert it into a suitable FME definition.

And how do you get the Proj.4 definition string? Easy... just use the following method.


_pragma(classify_level=basic)
_method coordinate_system_mixin.proj4_string
## proj4_string : string
##
## returns a string that represents self in the Proj.4 format.
## This can be used by coordinate system converters to convert
## self into other representations.

# according to the comments in
# coordinate_system_mixin.new_proj(): "PROJ_TYPE is a symbol
# specifying the projection type. The naming convention is
# similar, but not identical, to that used in the USGS Proj4
# library. See below for details."
#
# because the Magik names are not always identical to the Proj4
# names, we provide a lookup table here.
_local projection_name_lookup << hash_table.new_with(:accurate_tmerc,:tmerc,
:accurate_utm,:utm)

_local (proj,params) << _self.proj_type_and_params

_local info << rope.new()
info.add_last(write_string("+proj=",projection_name_lookup[proj].default(proj)))

_for k,v _over params.fast_keys_and_elements()
_loop
info.add_last(write_string("+",k,"=",v))
_endloop

_local int_str << internal_text_output_stream.new()

int_str.write_list_with_separator(info,space_char)

_return int_str.string

_endmethod
$


The next step will be to write a Magik method that actually converts the Smallworld coordinate_system definition directly into the FME COORDINATE_SYSTEM_DEF string all within Magik. That should allow for some greater flexibility in automating various Smallworld/FME processes.

Enjoy!

Thursday, April 1, 2010

How to tell your emacs apart

If you, like me, tend to have more than one emacs session running, your OS toolbar will show a bunch of emacs applications running all titled "emacs@". It gets a bit tiring to have to click on the multiple emacs applications to see which one I need to jump to. I discovered that you can easily rename the title for each emacs session and that title change will also appear in your OS toolbar.

The command is...

M-x set-frame-name

... and needs to be run for each emacs session.

I imagine that someone could easily modify the .emacs file to set the frame name based on some environment variable. If anyone does that, please post a comment with the code.