Thursday, March 11, 2010

Fax crawler, for SailMail users

I wanted to get something more dynamic for the patterns that can be used at sea...
When ashore, no problem, the faxes are pulled out from the Internet.
At sea, that's different, you have GetFax (from SailMail) downloading the faxes from the SSB onto your hard drive, and when it's about putting the faxes together in a composite, that used to be a painful experience, you had to locate the faxes one by one... Baaaaad.
There is now a new kind of dynamic pattern. If the protocol used to get the fax(es) is not http, then there is a surprise. There is a "search:" protocol implemented like in:

search:chartview.util.SearchUtil.findMostRecentFax(".*500.*", "${fax.path}")

That allows the soft to crawl the directory where the faxes are downloaded.
It does not look that friendly, but that is quite powerful, and extendable. After the "search:" keyword is the name of the Java class and method used to find the right fax. That method must be static, take two String parameters, and return a String value, that's all. The first parameter is a regular expression to match the description of the fax to find. SailMail appropriately stores this information when a fax is downloaded through GetFax... The second parameter is the root directory to start the search from, to find the most recent, matching the regular expression pattern. In the example above, it is the value of the path stored in the Weather Wizard preferences.
It is extendable in the sense that you can write your own crawlers, in Java. It just needs to be put in the classpath.
The same kind of syntax and method is available for the GRIBs as well.

search:chartview.util.SearchUtil.findMostRecentFile(".*\.(grb|grib)$", "${grib.path}")

The idea when at sea is to have GetFax running in "auto" mode for a while, and then to use this kind of composite pattern in the Weather Wizard. This way, this rendering is just one - I said "one" - click away:

Even fuzzy faxes make sense. Click the image... Cool!
To learn how to use this feature the best way, just Google "Regular Expression", this is soooooooooooo kewl!