Changeset 10615 for src/django_gheat


Ignore:
Timestamp:
Apr 29, 2012, 7:59:27 PM (13 years ago)
Author:
rick
Message:

Weed out whole bunch of unused code, to avoid huge dependency listing.

Location:
src/django_gheat
Files:
10 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/__init__.py

    r9145 r10615  
    1 import logging
    2 import os
    3 
    4 from gheat import gheatsettings as settings
    5 
    6 from django.core.exceptions import ImproperlyConfigured
    7 from django.db import connection
    8 
    9 # Logging config
    10 # ==============
    11 
    12 if settings.DEBUG:
    13     level = logging.WARNING
    14 else:
    15     level = logging.WARNING
    16 if os.getenv('DEBUG', None):
    17     level = logging.DEBUG
    18 
    19 logging.basicConfig(level=level) # Ack! This should be in Aspen. :^(
    20 log = logging.getLogger('gheat')
    21 
    22 
    23 # Configuration
    24 # =============
    25 # Set some things that backends will need.
    26 ALWAYS_BUILD = settings.GHEAT_ALWAYS_BUILD = False
    27 BUILD_EMPTIES = settings.GHEAT_BUILD_EMPTIES = False
    28 
    29 DIRMODE = settings.GHEAT_DIRMODE
    30 try:
    31     DIRMODE = int(eval(DIRMODE))
    32 except (NameError, SyntaxError, ValueError):
    33     raise ImproperlyConfigured("dirmode (%s) must be an integer." % dirmode)
    34 
    35 SIZE = 256 # size of (square) tile; NB: changing this will break gmerc calls!
    36 MAX_ZOOM = 22 # this depends on Google API; 0 is furthest out as of recent ver.
    37 
    38 
    39 # Try to find an image library.
    40 # =============================
    41 
    42 BACKEND = None
    43 BACKEND_PIL = False
    44 BACKEND_PYGAME = False
    45 
    46 _want = settings.GHEAT_BACKEND.lower()
    47 if _want not in ('pil', 'pygame', ''):
    48     raise ImproperlyConfigured( "The %s backend is not supported, only PIL and "
    49                             + "Pygame (assuming those libraries are installed)."
    50                              )
    51 
    52 if _want:
    53     if _want == 'pygame':
    54         from gheat import pygame_ as backend
    55     elif _want == 'pil':
    56         from gheat import pil_ as backend
    57     BACKEND = _want
    58 else:
    59     try:
    60         from gheat import pygame_ as backend
    61         BACKEND = 'pygame'
    62     except ImportError:
    63         try:
    64             from gheat import pil_ as backend
    65             BACKEND = 'pil'
    66         except ImportError:
    67             raise
    68             pass
    69    
    70     if BACKEND is None:
    71         raise ImportError("Neither Pygame nor PIL could be imported.")
    72 
    73 BACKEND_PYGAME = BACKEND == 'pygame'
    74 BACKEND_PIL = BACKEND == 'pil'
    75 
    76 log.info("Using the %s library" % BACKEND)
    77 
    78 
    79 # Set up color schemes and dots.
    80 # ==============================
    81 
    82 color_schemes = dict()          # this is used below
    83    
    84 _color_schemes_dir = os.path.join(settings.GHEAT_CONF_DIR, 'color-schemes')
    85 for fname in os.listdir(_color_schemes_dir):
    86     if not fname.endswith('.png'):
    87         continue
    88     name = os.path.splitext(fname)[0]
    89     fspath = os.path.join(_color_schemes_dir, fname)
    90     color_schemes[name] = backend.ColorScheme(name, fspath)
    91 
    92 def load_dots(backend):
    93     """Given a backend module, return a mapping of zoom level to Dot object.
    94     """
    95     return dict([(zoom, backend.Dot(zoom)) for zoom in range(MAX_ZOOM)])
    96 dots = load_dots(backend) # factored for easier use from scripts
    97 
    98 # Some util methods
    99 # =================
    100 def translate(root, url):
    101     """Translate a URL to the filesystem.
    102 
    103     We specifically avoid removing symlinks in the path so that the filepath
    104     remains under the website root. Also, we don't want trailing slashes for
    105     directories.
    106 
    107     """
    108     parts = [root] + url.lstrip('/').split('/')
    109     return os.sep.join(parts).rstrip(os.sep)
    110 
    111 ROOT = settings.GHEAT_MEDIA_ROOT
  • src/django_gheat/gheat/urls.py

    r9006 r10615  
    1 # -*- coding: utf-8 -*-
    2 from django.conf.urls.defaults import *
    3 
    4 urlpatterns = patterns('gheat.views',
    5     url(
    6         # Example : today/fire/12/3,2.png
    7         regex = r'^(?P<color_scheme>\w+)/(?P<zoom>\d+)/(?P<x>\d+),(?P<y>\d+).png$',
    8         view = 'serve_tile',
    9         name = 'serve_tile',
    10        ),
    11     )
  • src/django_gheat/httpd/maps.conf

    r9556 r10615  
    1414  RedirectMatch temp ^/$ /d/wlheatmap/
    1515  Alias /d/static /usr/local/django_gheat/sitestatic
     16  WSGIDaemonProcess maps processes=2 threads=15 display-name=%{GROUP}
     17  WSGIProcessGroup maps
    1618  WSGIScriptAlias /d /usr/local/django_gheat/django.wsgi
    1719  <Directory /usr/local/django_gheat>
  • src/django_gheat/httpd/osmproxy.conf

    r9556 r10615  
    1818  </Proxy>
    1919  # Example /7/63/43.png
     20  <Location /osm-tile-proxy>
     21    Order allow,deny
     22    Allow from all
     23  </Location>
    2024  ProxyPassMatch ^/osm-tile-proxy/(\d{1,2}/\d{1,6}/\d{1,6}\.png)$ balancer://osmcluster/$1 lbmethod=byrequests
    2125  CacheEnable disk /osm-tile-proxy/
  • src/django_gheat/wlheatmap/tile.py

    r9662 r10615  
    1616import time
    1717
    18 # Rending with PIL and computation with numpy has proven to be to slow to be
    19 # usable, but is still in here for refence purposes.
    20 try:
    21   from PIL import Image
    22   import ImageDraw
    23   import numpy as np
    24 except ImportError:
    25   pass
    2618
    2719class PyGamePicture():
     
    7062      pygame.draw.circle(new_surf,combined_colour,center,r,0)
    7163    self.surf.blit(new_surf,(0,0),special_flags=pygame.BLEND_RGBA_MAX)
    72 
    73 
    74 class PILPicture():
    75   """ Basic PIL class, allowing simple image manipulations """
    76   im = None
    77   def __init__(self, method, size):
    78     self.im = Image.new(method, size)
    79     self.data = np.array(self.im)
    80 
    81   def write(self,fh,format='png'):
    82         self.im.save(fh,format)
    83 
    84   def make_circle(self,draw, center, radius,colour=(0,255,0)):
    85     """ Cicle gradient is created by creating smaller and smaller cicles """
    86     (center_x, center_y) = center
    87     for i in range(0,radius):
    88       draw.ellipse(
    89         (center_x - radius + i,
    90          center_y - radius + i,
    91          center_x + radius - i,
    92          center_y + radius - i
    93         ),
    94         colour +(255 * i/(radius * 2),)
    95       )
    96 
    97   def add_circle(self, center, radius, colour):
    98     """ Adding a new cicle is a matter of creating a new one in a empty layer
    99     and merging it with the current one
    100 
    101     XXX: Very heavy code, should actually only work on the data arrays, instead
    102     of doing all the magic with high-level images """
    103 
    104     im_new = Image.new("RGBA", self.im.size)
    105     draw = ImageDraw.Draw(im_new)
    106     self.make_circle(draw, center, radius, colour)
    107    
    108     data2 = np.array(im_new)
    109    
    110     # Add channels to make new images
    111     self.data = self.data + data2
    112     self.im = Image.fromarray(self.data)
    113 
    11464
    11565
Note: See TracChangeset for help on using the changeset viewer.