I have found the shape data for the borders of all the countries and a class to process it and I have written a script to convert the longitude and latitude to a pixel location on an image and to draw the countries using imagefilledpolygon
and imageline
. Everything is working great except:
1) I have a $scale variable that I can change. At $scale=1 the image is 360x180 pixel (1 pixel = 1 degree latitude/longitude). Ideally the final image I want would be about $scale = 2 (720x360) however the borderlines at 1 pixel thick look very thick. So I thought the best solution would be to generate the map at $scale=10 and then resize the generated image. The problem is imagecopyresized
does not antialias when it resizes and it leaves me with a really jagged image, how can I resize and antialias?
2) The number of points to generate a polygon of a country is a LOT. The plan is to use the same code to produce an HTML imagemap to make the countries into links. However I fear at the moment there are too many points for an imagemap (the file size might be too big). My initial approach was to skip x amount of points, which lead to some success, If I process 1 in 10 points I get an acceptable result mostly. Ideally I would have even less... when I tried 1 in 40 I found some country borders overlapped and there were some gaps between countries (but some of the busier coastlines looked better). What is a sensible way to reduce the number of points whilst maintaining a reasonable level of accuracy?
If anyone is interested I'll post the code (once it's finished.)