Programmatically creating vector arrows in KML

Posted by mettadore on Stack Overflow See other posts from Stack Overflow or by mettadore
Published on 2009-07-24T17:11:43Z Indexed on 2010/03/31 20:33 UTC
Read the original article Hit count: 514

Filed under:
|
|

Does anyone have any practical examples of programmatically drawing icons as vectors in KML? Specifically, I have data with a magnitude and an azimuth at given coordinates, and I would like to have icons (or another graphical element) generated based on these values.

Some thoughts on how I might approach it:

  1. Image directory (a brute force way): Make an image director of 360 different image files (probably batch rotate a single image) each pointing in a cooresponding azimuth. I've seen things like "Excel to KML," but am looking for code that I can use within a program, rather than a web utility. Issue: Arrow does not contain magnitude context, so that would have to be a label. I'd rather dynamically lengthen the arrow.

  2. Line creation in KML: Perhaps create a formula that creates a line with the origin at the coordinate points, with the length of the line proportional to the magnitute, and angled according to azimuth. There would then be two more lines, perhaps 30 degrees or so extending from the end of the previous line to make the arrow head. Issues: Not a separate image icon, so not sure how it would work in KML. Also not sure how easy it would be to generate this algorithm.

  3. Separate image generation: Perhaps create a PHP file that uses imagemagick or something similar to dynamically generate a .png file in a similar method to the above, and then link to the icon using the URI "domain.tld/imagegen.php?magnitude=magvalue&azimuth=azmvalue". Issue: Still have the problem of actually writing the algorithm for image generation.

So, the question: has anyone else come up with solutions for programmatic vector (rather than merely arrow) generation?

© Stack Overflow or respective owner

Related posts about vectors

Related posts about kml