2009/11/6 Artem Pavlenko <[email protected]>:
> Excellent visualisation of alien craft landing! Seriously, great to see how
> label collision work through different zoom levels, very cool.
>
> 2009/11/6 Philip Stubbs <[email protected]>
>>
>> I have been having some fun with doing an animation.
>> http://www.youtube.com/watch?v=mxcTimoiX30
>>
>> I am having trouble getting my head round a decent algorithm to
>> provide a sooth zoom or pan type action. Unfortunately my programming
>> skills are limited, and find it easier to build on other examples than
>> start from scratch. Does anybody know of any animation scripts that
>> work well with Mapnik?
>>
> Not sure. If you find some please let us know!
> Cheers
> Artem

Well I did not find any either. Not that I looked very hard. I have
however had another stab on my own, and think this is much closer to
what I was expecting to see.

http://www.youtube.com/watch?v=-bc50sC8adM

For any that are interested, here is the script that I used.

#!/usr/bin/python

from mapnik import *
import math, sys, os

if __name__ == "__main__":
   try:
       mapfile = os.environ['MAPNIK_MAP_FILE']
   except KeyError:
       mapfile = "osm.xml"
   map_uri = "image.png"

   #---------------------------------------------------
   #  Change this to the bounding box you want
   #
   ll_start = (-6.5, 49.5, 2.1, 59)
   ll_finish = (-1.227, 50.812, -1.222, 50.815)
   ll = [-180.0, -90.0, 180.0, 90.0]
   #---------------------------------------------------

   NumFrames = 600
   z = 15
   f = 1.0
   imgx = 1280
   imgy = 720

   m = Map(imgx,imgy)
   load_map(m,mapfile)
   prj = Projection("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgri...@null +no_defs
+over")
   for i in range(1,NumFrames+1):
       for j in range(0,4):
           if i == 1:
               ll[j] = ll_start[j]
           else:
               ll[j] = ll_finish[j]+((ll[j]-ll_finish[j])*f)
               if f > 0.98:
                   f = f - 0.0001
       c0 = prj.forward(Coord(ll[0],ll[1]))
       c1 = prj.forward(Coord(ll[2],ll[3]))
       bbox = Envelope(c0.x,c0.y,c1.x,c1.y)
       m.zoom_to_box(bbox)
       print "About to render frame %d at %0.3f, %0.3f, %0.3f, %0.3f"
% (i, ll[0], ll[1], ll[2], ll[3])
       map_uri = "frames2/image%03d.png" % (i)
       render_to_file(m, map_uri, 'png')


--
Philip Stubbs
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to