Changeset 9189


Ignore:
Timestamp:
May 12, 2011, 1:55:27 PM (14 years ago)
Author:
rick
Message:

Avoid hitting the OSM website all the time, use local caching. Makes development more easy as well.

Location:
src/django_gheat
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/settings.py

    r9188 r9189  
    22
    33import os
    4 PROJECT_HOME = os.path.dirname(__file__)
     4PROJECT_HOME = os.path.abspath(os.path.dirname(__file__))
     5OSM_CACHE_DIR = '/tmp/osm-cache'
     6OSM_CACHE = 'osm_cache'
     7
     8
    59
    610DEBUG = True
    711TEMPLATE_DEBUG = DEBUG
     12
     13if DEBUG and not os.path.exists(OSM_CACHE_DIR):
     14  os.mkdir(OSM_CACHE_DIR)
    815
    916# Required for Etags Caching Implementation
     
    3138        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    3239        'LOCATION': 'unique-snowflake'
     40    },
     41    OSM_CACHE: {
     42        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
     43        'LOCATION': OSM_CACHE_DIR,
     44        'TIMEOUT': 3600 * 24 * 7,
     45        'OPTIONS': {
     46            'MAX_ENTRIES': 100000
     47        }
    3348    }
    3449}
  • src/django_gheat/website/static/OpenStreetMap.js

    r9166 r9189  
    4545    initialize: function(name, options) {
    4646        var url = [
    47             "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
    48             "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
    49             "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
     47            "/website/osm-proxy/${z}/${x},${y}.png",
    5048        ];
    5149        options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
  • src/django_gheat/website/urls.py

    r9186 r9189  
    2020    )
    2121
     22urlpatterns += patterns('website.osm_proxy',
     23    url(
     24        # Example : today/fire/12/3,2.png
     25        regex = r'^osm-proxy/(?P<zoom>\d+)/(?P<x>\d+),(?P<y>\d+).png$',
     26        view = 'osm_proxy',
     27        name = 'osm_proxy',
     28       ),
     29    )
     30
    2231urlpatterns += patterns('website.nodelist',
    2332    url(
Note: See TracChangeset for help on using the changeset viewer.