Ignore:
Timestamp:
May 16, 2011, 12:45:26 PM (14 years ago)
Author:
dennisw
Message:

Better mousebounds with nodelist. Some delay with mouseposition though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/website/nodelist.py

    r9196 r9201  
    1111from django.core import serializers
    1212from gheat.models import *
     13from gheat import gmerc
    1314import logging
    1415import pygame
     
    1617import tempfile
    1718
     19def get_bounds(zoom,lat,lon):
     20
     21  # Getting max radius for zoomlevel. Note that it will make a square using this, not a circle.
     22  SIZE = 250
     23  tile_height = float(40008000) / (2 ** zoom)
     24  meters_per_pixel = float(tile_height) / SIZE
     25  radius = 150 / meters_per_pixel
     26
     27  # Getting pixel location for mouseposition
     28  mouse_x, mouse_y = gmerc.ll2px(lat,lon,zoom)
     29 
     30  max_x = int(mouse_x + radius)
     31  max_y = int(mouse_y + radius)
     32  min_x = int(mouse_x - radius)
     33  min_y = int(mouse_y - radius)
     34
     35  max_lat, max_lon = gmerc.px2ll(max_x, min_y, zoom)
     36  min_lat, min_lon = gmerc.px2ll(min_x, max_y, zoom)
     37
     38  return (max_lat, max_lon, min_lat, min_lon)
     39
     40
    1841def make_list(zoom,lat,lon):
    1942
    20   maxlat = (lat + 0.01)
    21   maxlon = (lon + 0.01)
    22   minlat = (lat - 0.01)
    23   minlon = (lon - 0.01)
     43  maxlat, maxlon, minlat, minlon = get_bounds(zoom,lat,lon)
    2444
    2545  filter = {}
     
    3757  return nodelist
    3858
     59
    3960def serve_nodelist(request,zoom,lat,lon,):
    40   html = make_list(int(zoom), float(lat), float(lon))
    41   return HttpResponse(html, content_type = 'application/javascript; charset=utf8')
    42 
     61  nodelist = make_list(int(zoom), float(lat), float(lon))
     62  return HttpResponse(nodelist, content_type = 'application/javascript; charset=utf8')
Note: See TracChangeset for help on using the changeset viewer.