Ejemplo n.º 1
0
def tile(request, name, z, x, y):
    """ Serve a single image tile """
    try:
        mbtiles = MBTiles(name)
        data = mbtiles.tile(z, x, y)
        response = HttpResponse(mimetype='image/png')
        response.write(data)
        return response
    except MBTilesNotFoundError, e:
        logger.warning(e)
Ejemplo n.º 2
0
def tile(request, name, z, x, y):
    """ Serve a single image tile """
    try:
        mbtiles = MBTiles(name)
        data = mbtiles.tile(z, x, y)
        response = HttpResponse(mimetype='image/png')
        response.write(data)
        return response
    except MBTilesNotFoundError, e:
        logger.warning(e)
Ejemplo n.º 3
0
 def test_preview(self):
     mb = MBTiles('geography-class')
     self.failUnlessEqual((2.3401, 48.8503, 3), mb.center)
     center = mb.center_tile()
     self.failUnlessEqual((3, 4, 2), center)
     h = hashlib.md5(mb.tile(*center)).hexdigest()
     self.failUnlessEqual('e7de86eeea4e558851a7c0f6cc3082ff', h)
     # HTTP
     response = self.client.get(reverse('mbtilesmap:preview', kwargs={'name':'geography-class'}))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response['Content-type'], 'image/png')
     response = self.client.get(reverse('mbtilesmap:preview', kwargs={'name':'unknown'}))
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 4
0
 def test_preview(self):
     mb = MBTiles('geography-class')
     self.failUnlessEqual((2.3401, 48.8503, 3), mb.center)
     center = mb.center_tile()
     self.failUnlessEqual((3, 4, 2), center)
     h = hashlib.md5(mb.tile(*center)).hexdigest()
     self.failUnlessEqual('e7de86eeea4e558851a7c0f6cc3082ff', h)
     # HTTP
     response = self.client.get(
         reverse('preview', kwargs={'name': 'geography-class'}))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response['Content-type'], 'image/png')
     response = self.client.get(
         reverse('preview', kwargs={'name': 'unknown'}))
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 5
0
 def test_tile(self):
     mb = MBTiles('geography-class')
     tile = mb.tile(3, 4, 2)
     h = hashlib.md5(tile).hexdigest()
     self.failUnlessEqual('e7de86eeea4e558851a7c0f6cc3082ff', h)
Ejemplo n.º 6
0
 def test_tile(self):
     mb = MBTiles('geography-class')
     tile = mb.tile(3, 4, 2)
     h = hashlib.md5(tile).hexdigest()
     self.failUnlessEqual('e7de86eeea4e558851a7c0f6cc3082ff', h)