Exemplo n.º 1
0
 def handle(self, *args, **options):
     global map_pool
     images = GeoImage.objects.all()
     
     min_zoom = options['min_zoom']
     max_zoom = options['max_zoom'] + 1
     
     for image in images:
         self.stdout.write('[buildcache] image %d from zoom %d to %d\n'
                             % (image.pk, min_zoom, max_zoom - 1))
         try:
             bounds = get_bounds(image.geom)
             for z in range(min_zoom, max_zoom):
                 minx, maxy = tileXY(bounds['miny'], 
                                 bounds['minx'], z)
                 
                 maxx, miny = tileXY(bounds['maxy'], 
                                 bounds['maxx'], z)
                 
                 # we buffer the cache a bit
                 for x in range(minx -1, maxx +1):
                     for y in range(miny -1, maxy +1):
                         map_pool.get_map().get_tile(z,x,y)
         except Exception, e:
             print 'failed: %s'%(e,)
Exemplo n.º 2
0
def debug_view(req, pk, zoom):
    from tile.models import MongoCache
    c = MongoCache()
    g = GeoImage.objects.get(pk=int(pk))
    base = get_bounds(g.geom)
    polygon = c.get_polygon(base)
    request = {'center': {'$geoIntersects': {'$geometry': polygon}}}

    ret = []
    for item in c.index.find(request):
        k = item['_id']
        z, x, y = list(k.split('_'))
        #if z == zoom:
        bounds = item['bounds']
        ret.append(c.get_polygon(bounds))
    centers = []
    for item in c.index.find():
        centers.append(item['center'])

    return HttpResponse(json.dumps({
        'data': ret,
        'base': base,
        'centers': centers
    }),
                        content_type="text/plain")
Exemplo n.º 3
0
def debug_view(req, pk, zoom):
    from tile.models import MongoCache

    c = MongoCache()
    g = GeoImage.objects.get(pk=int(pk))
    base = get_bounds(g.geom)
    polygon = c.get_polygon(base)
    request = {"center": {"$geoIntersects": {"$geometry": polygon}}}

    ret = []
    for item in c.index.find(request):
        k = item["_id"]
        z, x, y = list(k.split("_"))
        # if z == zoom:
        bounds = item["bounds"]
        ret.append(c.get_polygon(bounds))
    centers = []
    for item in c.index.find():
        centers.append(item["center"])

    return HttpResponse(json.dumps({"data": ret, "base": base, "centers": centers}), content_type="text/plain")
Exemplo n.º 4
0
    def handle(self, *args, **options):
        global map_pool
        images = GeoImage.objects.all()

        min_zoom = options['min_zoom']
        max_zoom = options['max_zoom'] + 1

        for image in images:
            self.stdout.write('[buildcache] image %d from zoom %d to %d\n' %
                              (image.pk, min_zoom, max_zoom - 1))
            try:
                bounds = get_bounds(image.geom)
                for z in range(min_zoom, max_zoom):
                    minx, maxy = tileXY(bounds['miny'], bounds['minx'], z)

                    maxx, miny = tileXY(bounds['maxy'], bounds['maxx'], z)

                    # we buffer the cache a bit
                    for x in range(minx - 1, maxx + 1):
                        for y in range(miny - 1, maxy + 1):
                            map_pool.get_map().get_tile(z, x, y)
            except Exception, e:
                print 'failed: %s' % (e, )