Tuesday, February 12, 2008

Flash-y Map-plication vs. 500 marker limit

I've been pushing capabilities of javascript mapping frameworks. There's a real limit on the number of markers a browser can display without getting bogged down. 500 is a good limit, and that's probably too high for internet explorer. You can put as many markers as you like via WMS tiles. You can even take map clicks, send them back as AJAX queries and open an info window. I recently helped my friend do this, and we have a pretty snappy map displaying 5,000+ clickable "markers" no problem. It's actually not markers, just tiles, but it works quite well:
That's a snapshot of the google maps application, with an info window that appears when a marker is clicked. It sends a GetFeatureInfo request back to a mapserver WMS.

Vector drawing in the browser is limited. The amazing efforts of the OpenLayers, featureserver projects make this difficult to assert, as they abstract away all of the browser incompatibilities and give a nice platform to do real vector editing in a map. Still, there's a limit, and even if browsers become twice as fast in the next 2-3 years (and that's a big if, because the slowest commonly used browser will be the weakest link), the limit will be at 1000 markers.
Flash is built to do vector drawing. It's cross-browser. I've got my toes wet with a flash-based project and now that I am passed (part of) the learning curve, I figured I'd see what's available for GIS applications in flash...

Yahoo fairly recently released their Actionscript 3.0 version of their maps API. The examples look very straight-forward, if a bit heavy on the under-scores--even for a pythonista. But it's not open source, and there is no indication on how one would request tiles from any source--say WMS.
There is a 3D earth viewer with a nice javascript API, but it's not open source and I dont need the 3D stuff.

I'm still looking at worldkit, and even provided a patch to allow it to compile with mtasc. The worldkit approach as I understand it is to just provide the functionality in the flash movie, and only offer customization through an inutitive config.xml file, so no actionscript programming is necessary. Of course, this isn't strictly the case, but I think it's the way that it's most used. It's licensed GPL...

Then there's modest maps who are truly open source, with a trac bug tracker and BSD licensed code, multiple developers, clean design, and libraries for both actionscript 2.0 and 3.0. And they can display imagery from any of the major providers, I don't quite understand how they get by without violating the licensing restrictions, but they are making javascript calls--presumably to get the copyright info associated with the region of interest. They have a coordinate conversion system that seems very clean, though I also dont understand how to relate it to proj4 definitions--or the EPSG code in a WMS request. If I can understand how to use this, and even if it's possible to have layers that overlay base imagery I'd go with modest maps.

Anyone know of any others? I guess my criteria are:
  1. Active, currently developed
  2. Open source
  3. WMS friendly

I was able to get a modestmaps actionscript 2.0 movie to show 2500 markers, with the map still very responsive. The as3 version should perform even better because a marker can be a subclass of the more lightweight Sprite, rather than the full movieclip.
this is a shot of the randomly placed markers.

Sunday, February 10, 2008

python bioinformatics

There's a new article out in BMC Bioinformatics with a comparison of the speed and length of programs from various languages. This article was sent to the biology in python (BIP) mailing list. Looking at the code, it's not that bad, but it is clear that the authors are not pythonistas, and that the reviewers have done a great job on the actual paper, but likely there was no thorough review of the code.
The authors define their own max() function that needlessly overrides python's built-in, and they use the code:
that indicates there was not a thorough understanding of python, or a complete code review. Even a non-python programmer should have seen the intent was to strip a newline '\n', but the operation is not inplace, so the desired behavior could be achieved by:
line = line.rstrip('\n')
Syntactical mistakes aside, python was given a poor review on speed. Andrew Dalke, of wide-finder (and general python-bio) fame ran the alignment program (which seems to be Needleman-Wunsch) and found the psyco JIT'ed version to run in 1.7 seconds instead of the original 18+.

Given the lack of polish on the programs, even from other languages, the question then is what's the recourse? On the BIP list, some even suggested requesting that the authors retract the article. I think that's going too far as (to my knowledge) the code runs, and does more/less what it should. An alternate approach may be to propose more thorough code review for all articles, not just those that are benchmarks. As an example of informal code review, had the authors sent their code to the python list, they would undoubtedly have received numerous suggestions for making the code faster and more idiomatic. Likewise for the other languages. Clearly, that's not a solution for all cases, but given reasonably active communities for Bio-Python, Perl, Java, Ruby, a journal or author should be able to find a competent reviewer--especially in the most common scenarios where a single language was used. Journals demand a very specific format of the text of an article, should have similar standards for any code that is used in the article? Should they require automated tests? This presents a problem for those that use proprietary software. But one of the points of a scientific paper is to document the methods sufficiently to reproduce the results, is the actual code required to do so?
It's an interesting question, I don't know the answer. I notice 2 things:
1) A reviewer is not expected to know how to program, but she is expected to understand the science.
2) We do not have the same standards for code review as for reviewing the text.

Do the ends justify the means?