= Tile Generation & Data flow = Let's assume that non-existed tiles will be generated realtime: == Website == 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. The browser will request {{{tile/1/1,1.png}}}. Note that these values are variables. In fact, in the website/urls.py, the following urlpattern is given: {{{r'^tile/(?P\d+)/(?P\d+),(?P\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. == website/tile.py == === serve_tile === This 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. === make_tile === This 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. Some calculations are made before and after the data request, and then tile is returned and will be shown on the map. == gheat/views.py == === serve_tile === The serve_tile function is responsible for serving the tile images. The url parameters validated, and a request with these parameters will be sent to the {{{generate_tile}}} function. === generate_tile === This 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.-- == gheat/pygame_.py & gheat/base.py == These 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. Combined, 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/}}} A 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.