Skip to content
Snippets Groups Projects
Commit deeb5490 authored by Kevin S. Hahn's avatar Kevin S. Hahn
Browse files

starts routes to fetch montage info and get tiles

parent af74d5ad
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,7 @@ routes = [
webapp2.Route(r'/<:[0-9a-f]{24}>', acquisitions.Acquisition, name='acquisition'),
webapp2.Route(r'/<:[0-9a-f]{24}>/file', acquisitions.Acquisition, handler_method='get_file', methods=['GET', 'POST']),
webapp2.Route(r'/<:[0-9a-f]{24}>/file', acquisitions.Acquisition, handler_method='put_file', methods=['PUT']),
webapp2.Route(r'/<:[0-9a-f]{24}>/tile', acquisitions.Acquisition, handler_method='get_tile', methods=['GET']),
webapp2.Route(r'/<:[0-9a-f]{24}>/attachment', acquisitions.Acquisition, handler_method='delete_attachment', methods=['DELETE']),
webapp2.Route(r'/<:[0-9a-f]{24}>/attachment', acquisitions.Acquisition, handler_method='get_attachment', methods=['GET', 'POST']),
webapp2.Route(r'/<:[0-9a-f]{24}>/attachment', acquisitions.Acquisition, handler_method='put_attachment', methods=['PUT']),
......
......@@ -325,6 +325,34 @@ class Container(base.RequestHandler):
else:
self.abort(400, '%s is not listed in the sha1s' % fname)
def get_tile(self, cid):
"""fetch info about a tiled tiff, or retrieve a specific tile."""
_id = bson.ObjectId(cid)
montage_info = self.dbc.find_one(
{
'_id': _id,
'$and': [
{'files.kinds': ['montage']},
{'files.ext': '.tiff'},
],
},
['files.$'],
)
if not montage_info:
self.abort(404, 'montage tiff not found')
fn = montage_info['files'][0]['name'] + montage_info['files'][0]['ext']
fp = os.path.join(self.app.config['data_path'], cid[-3:], cid, fn)
z = self.request.get('z')
x = self.request.get('x')
y = self.request.get('y')
if not (z and x and y):
return util.get_info(fp)
else:
self.response.content_type = 'image/png'
tile = util.get_tile(fp, int(z), int(x), int(y))
if tile:
self.response.write(tile)
def get_attachment(self, cid):
"""Download one attachment."""
fname = self.request.get('name')
......
......@@ -12,6 +12,11 @@ import datetime
import tempdir as tempfile
import scitran.data
import scitran.data.medimg.montage
get_info = scitran.data.medimg.montage.get_info
get_tile = scitran.data.medimg.montage.get_tile
PROJECTION_FIELDS = ['timestamp', 'permissions', 'public']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment