def minor_planet_chart_pos_img(minor_planet_id, ra, dec): minor_planet = MinorPlanet.query.filter_by(id=minor_planet_id).first() if minor_planet is None: abort(404) minor_planet_ra = to_float(request.args.get('obj_ra'), None) minor_planet_dec = to_float(request.args.get('obj_dec'), None) flags = request.args.get('json') visible_objects = [] if flags else None trajectory_b64 = request.args.get('trajectory') if trajectory_b64: trajectory_json = base64.b64decode(trajectory_b64) trajectory = json.loads(trajectory_json) else: trajectory = None img_bytes = common_chart_pos_img(minor_planet_ra, minor_planet_dec, ra, dec, visible_objects=visible_objects, trajectory=trajectory) if visible_objects is not None: img = base64.b64encode(img_bytes.read()).decode() return jsonify(img=img, img_map=visible_objects) else: return send_file(img_bytes, mimetype='image/png')
def comet_chart_legend_img(comet_id, ra, dec): comet = _find_comet(comet_id) if comet is None: abort(404) comet_ra = to_float(request.args.get('obj_ra'), None) comet_dec = to_float(request.args.get('obj_dec'), None) img_bytes = common_chart_legend_img(comet_ra, comet_dec, ra, dec, ) return send_file(img_bytes, mimetype='image/png')
def planet_chart_legend_img(planet_name, ra, dec): planet = _find_planet(planet_name) if planet is None: abort(404) planet_ra = to_float(request.args.get('obj_ra'), None) planet_dec = to_float(request.args.get('obj_dec'), None) img_bytes = common_chart_legend_img(planet_ra, planet_dec, ra, dec, ) return send_file(img_bytes, mimetype='image/png')
def news_chart_pdf(news_id, ra, dec): news = News.query.filter_by(id=news_id).first() if news is None: abort(404) if not news.is_released and (current_user.is_anonymous or not current_user.is_editor): abort(404) news_ra = to_float(request.args.get('obj_ra'), None) news_dec = to_float(request.args.get('obj_dec'), None) img_bytes = common_chart_pdf_img(news_ra, news_dec, ra, dec) return send_file(img_bytes, mimetype='application/pdf')
def minor_planet_chart_legend_img(minor_planet_id, ra, dec): minor_planet = MinorPlanet.query.filter_by(id=minor_planet_id).first() if minor_planet is None: abort(404) minor_planet_ra = to_float(request.args.get('obj_ra'), None) minor_planet_dec = to_float(request.args.get('obj_dec'), None) img_bytes = common_chart_legend_img( minor_planet_ra, minor_planet_dec, ra, dec, ) return send_file(img_bytes, mimetype='image/png')
def comet_chart_pdf(comet_id, ra, dec): comet = _find_comet(comet_id) if comet is None: abort(404) comet_ra = to_float(request.args.get('obj_ra'), None) comet_dec = to_float(request.args.get('obj_dec'), None) trajectory_b64 = request.args.get('trajectory') if trajectory_b64: trajectory_json = base64.b64decode(trajectory_b64) trajectory = json.loads(trajectory_json) else: trajectory = None img_bytes = common_chart_pdf_img(comet_ra, comet_dec, ra, dec, trajectory=trajectory) return send_file(img_bytes, mimetype='application/pdf')
def minor_planet_chart_pdf(minor_planet_id, ra, dec): minor_planet = MinorPlanet.query.filter_by(id=minor_planet_id).first() if minor_planet is None: abort(404) minor_planet_ra = to_float(request.args.get('obj_ra'), None) minor_planet_dec = to_float(request.args.get('obj_dec'), None) trajectory_b64 = request.args.get('trajectory') if trajectory_b64: trajectory_json = base64.b64decode(trajectory_b64) trajectory = json.loads(trajectory_json) else: trajectory = None img_bytes = common_chart_pdf_img(minor_planet_ra, minor_planet_dec, ra, dec, trajectory=trajectory) return send_file(img_bytes, mimetype='application/pdf')