Changes between Version 4 and Version 5 of tilegen


Ignore:
Timestamp:
Jun 28, 2011, 3:30:37 PM (13 years ago)
Author:
dennisw
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • tilegen

    v4 v5  
    22Let's assume that non-existed tiles will be generated realtime:
    33== Website ==
    4 It all starts at the website. A user opens the heatmap, and the browser starts requesting tiles. Let's say tile 1,1 at zoomlevel (x)1 is requested, using the classic colorscheme. The browser will request {{{classic/1/1,1.png}}}.
     4It all starts at the website. A user opens the heatmap, and the browser starts requesting tiles. Let's say tile 1,1 at zoomlevel (x)1 is requested. The browser will request {{{tile/1/1,1.png}}}.
    55
    6 Note that these values are variables. In fact, in the gheat/urls.py, the following urlpattern is given: {{{r'^(?P<color_scheme>\w+)/(?P<zoom>\d+)/(?P<x>\d+),(?P<y>\d+).png$'}}}. So when the browser requests an image, the urlpattern is recognized and the url is sent to the {{{serve_tile}}} function in {{{gheat.views}}}, as declared in gheat/urls.py.
     6Note that these values are variables. In fact, in the website/urls.py, the following urlpattern is given: {{{r'^tile/(?P<zoom>\d+)/(?P<x>\d+),(?P<y>\d+).png$'}}}. So when the browser requests an image, the urlpattern is recognized and the url is sent to the {{{serve_tile}}} function in {{{website/tile.py}}}, as declared in website/urls.py.
     7
     8== website/tile.py ==
     9=== serve_tile ===
     10This function starts with a check for cached files. A key is made with the variables from the url and the database is checked for a tile linked to that key. If no cached tile is found, a new one will be created. The {{{make_tile}}} function is called for this using the same parameters from url as before.
     11
     12=== make_tile ===
     13This function requests data from the database using the parameters, and for every coordinate it get's in return, it places a dot on the tile. Dot size and transparancy are scaled by the signal strength the accespoint was received with.
     14
     15Some calculations are made before and after the data request, and then tile is returned and will be shown on the map.
    716
    817== gheat/views.py ==
    918=== serve_tile ===
    1019The serve_tile function is responsible for serving the tile images.
    11 
    12 The function starts with a variable validation. Is the colorscheme existing? And are the zoomlevels, x, and y really digits? Is the zoomrange supported? If any error should occur, the tile will not be generated.
    13 
    14 Since our variables passed the validation, and the tile doesn't exist yet, the data will be sent to the {{{generate_tile}}} function.
     20The url parameters validated, and a request with these parameters will be sent to the {{{generate_tile}}} function.
    1521
    1622=== generate_tile ===
    17 This function sends the variables to the backend class Tile: {{{tile = backend.Tile(color_scheme, dots, zoom, x, y, fspath)}}}. The backend, declared in gheat/gheatsettings.py is the gheat/pygame_.py file. --This calculates the lat/lng bounds for the tile. After this, depending on existence, a tile will be rebuild and served or served from cache, or an empty will be served.--
     23This function sends the parameters to the backend class Tile: {{{tile = backend.Tile(color_scheme, dots, zoom, x, y, fspath)}}}. The backend, declared in gheat/gheatsettings.py is the gheat/pygame_.py file. --This calculates the lat/lng bounds for the tile. After this, depending on existence, a tile will be rebuild and served or served from cache, or an empty will be served.--
    1824
    1925== gheat/pygame_.py & gheat/base.py ==
    2026These two files will be explained in one section, since the Tile class in base.py is the base class for the Tile class in pygame.py.
    2127
    22 It starts with translating the tile coords to pixel coords. It adds the image height and with to the pixel coords, and translates it to lat & lon. These values represent the boundaries of the tile.
     28Combined, these files get the parameters, request data from the database, and for every coordinate they place a dot on the map. These dots are shown in a color depending on the selected color scheme. Instead of the actual dots being generated by the scripts (like in tile.py), the source of these dots are images located in {{{gheat/etc/dots/}}}. The same goes for the color schemes, {{{gheat/etc/color-schemes/}}}
    2329
    24 still WIP
     30A tile is returned back to {{{views.generate_tile}}}, which returns it to {{{views.serve_tile}}}, which returns it to the user and is shown on the map.