Changeset 9102 for src/django_gheat


Ignore:
Timestamp:
Apr 22, 2011, 3:44:39 PM (14 years ago)
Author:
dennisw
Message:

Zoomlevels fixed.

Location:
src/django_gheat/gheat
Files:
4 edited

Legend:

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

    r9052 r9102  
    3434
    3535SIZE = 256 # size of (square) tile; NB: changing this will break gmerc calls!
    36 MAX_ZOOM = 17 # this depends on Google API; 0 is furthest out as of recent ver.
     36MAX_ZOOM = 22 # this depends on Google API; 0 is furthest out as of recent ver.
    3737
    3838
  • src/django_gheat/gheat/management/commands/gen_tiles.py

    r9038 r9102  
    2727class LatLonToTile:
    2828
    29     def deg2num(self, lat_deg, lon_deg, zoom):
    30         lat_rad = math.radians(lat_deg)
    31         n = 2.0 ** zoom
    32         xtile = int((lon_deg + 180.0) / 360.0 * n)
    33         ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
    34         return(xtile, ytile)
     29  def deg2num(self, lat_deg, lon_deg, zoom):
     30    lat_rad = math.radians(lat_deg)
     31    n = 2.0 ** zoom
     32    xtile = int((lon_deg + 180.0) / 360.0 * n)
     33    ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
     34    return(xtile, ytile)
    3535
    3636
    3737class Command(BaseCommand):
    3838
    39     option_list = BaseCommand.option_list + (
    40         make_option("-b", "--tileview", dest="viewname", default="serve_tile"),
    41         make_option("-s", "--start", dest="start", default="52.132708,4.437389"),
    42         make_option("-e", "--end", dest="end", default="52.178837,4.551029"),
    43         make_option("-c", "--colorscheme", dest="color", default="classic"),
    44     )
     39  option_list = BaseCommand.option_list + (
     40    make_option("-b", "--tileview", dest="viewname", default="serve_tile"),
     41    make_option("-s", "--start", dest="start", default="52.132708,4.437389"),
     42    make_option("-e", "--end", dest="end", default="52.178837,4.551029"),
     43    make_option("-c", "--colorscheme", dest="color", default="classic"),
     44  )
    4545
    46     def handle(self, *args, **options):
     46  def handle(self, *args, **options):
     47    start = options['start'].split(',')
     48    end = options['end'].split(',')
     49    viewname = options['viewname']
     50    colorscheme = str(options['color'])
    4751
    48         start = options['start'].split(',')
    49         end = options['end'].split(',')
    50         viewname = options['viewname']
    51         colorscheme = str(options['color'])
     52    d2n = LatLonToTile()
    5253
    53         d2n = LatLonToTile()
     54    #initialize browser client
     55    c = Client()
     56    from gheat.models import MeetRondje
     57 #   collection = MeetRondje.objects.values('naam')
     58#    for col in collection:
     59    for tz in range(1, 21):
     60      #calculate start tiles
     61      mxmin, mymax = d2n.deg2num(float(start[0]), float(start[1]), tz)
    5462
    55         #initialize browser client
    56         c = Client()
     63      #calculate end tiles
     64      mxmax, mymin = d2n.deg2num(float(end[0]), float(end[1]), tz)
    5765
    58         for tz in range(1, 17):
    59                 #calculate start tiles
    60                 mxmin, mymax = d2n.deg2num(float(start[0]), float(start[1]), tz)
     66      #loop through each tile and generate a request to the serve_tile view using Client
     67      for ty in range(mymin, mymax+1):
     68        for tx in range(mxmin, mxmax+1):
     69          tileurl = reverse(viewname, kwargs={'color_scheme': colorscheme, 'zoom':tz, 'x':tx, 'y':ty})
     70          generate_response = c.get(tileurl)
     71          #lousy error handling. Should check why status 200 not returned... I.e. wrong colorscheme
     72          if generate_response.status_code == 200:
     73            print "Generated tile " + tileurl
     74          else:
     75            print "Failed generating tile " + tileurl
    6176
    62                 #calculate end tiles
    63                 mxmax, mymin = d2n.deg2num(float(end[0]), float(end[1]), tz)
    64 
    65                 #loop through each tile and generate a request to the serve_tile view using Client
    66                 for ty in range(mymin, mymax+1):
    67                     for tx in range(mxmin, mxmax+1):
    68                
    69                         tileurl = reverse(viewname, kwargs={'color_scheme': colorscheme, 'zoom':tz, 'x':tx, 'y':ty})
    70 
    71                         generate_response = c.get(tileurl)
    72 
    73                         #lousy error handling. Should check why status 200 not returned... I.e. wrong colorscheme
    74                         if generate_response.status_code == 200:
    75                             print "Generated tile " + tileurl
    76                         else:
    77                             print "Failed generating tile " + tileurl
    78 
  • src/django_gheat/gheat/models.py

    r9097 r9102  
    4040    return "%s @ %s,%s : %s" % (self.accespoint.ssid, self.latitude, self.longitude, self.signaal)
    4141
    42 class nodes(models.Model):
     42class Node(models.Model):
    4343  naam = models.CharField(max_length=64)
    4444  ssid = models.CharField(max_length=64)
  • src/django_gheat/gheat/views.py

    r9041 r9102  
    2727        x = int(x)
    2828        y = int(y)
    29         assert 0 <= zoom <= 17, "bad zoom: %d" % zoom
     29        assert 0 <= zoom <= 22, "bad zoom: %d" % zoom
    3030    except AssertionError, err:
    3131        return HttpResponseBadRequest()
Note: See TracChangeset for help on using the changeset viewer.