Are there any available tools or a recommend methods for displaying a tag or word cloud (also know as wordle) onto a world map, much like in this example: Map: United States of surnames? (There may be other examples on the NY Times.)
Note that that in the example above, word are located by fixed coordinates, whereas text clouding might be implemented with the wordle algorithm (as described on SO) in an automatic manner. So, is there a software that let you put words at random on a given country, or do you think it's best to tweak the wordle original algorithm (e.g., by adding constraints based on predefined frontiers)?
Answer
It would take very little tweaking: approximate the polygon boundary by isothetic lines (that is, horizontal and vertical segments) and, as initial conditions, place boxes (with blank content) aligned along those lines in the exterior of the polygon and in the interior of the polygon's bounding box. At this point the configuration would look exactly as if the Wordle algorithm had been going for a while and had happened to place the first words around the perimeter of the bounding box. Let the algorithm take over from there.
In effect, this amounts to representing the polygon with a quadtree from the outset and otherwise exactly reproducing the Wordle algorithm.
If you're not placing thousands of words into the polygon and if you have a little computing time to spare, you don't have to code a spatial index at all: you can perform collision detection using brute-force all-pairs comparisons of the bounding boxes. With a tiny bit more work you can maintain lists of the word locations sorted by x- and y-coordinates and exploit these lists to streamline the collision detection algorithm.
No comments:
Post a Comment