def showimg(self): adimg, cksum = request.params['adimg'].split(",") maptype = request.params['maptype'] variant = request.params['variant'] response.headers['Content-Type'] = 'image/png' response.headers['Pragma'] = '' response.headers['Cache-Control'] = 'max-age=120' if maptype == 'chart': return parse_landing_chart.get_chart_png(adimg, cksum) else: width, height = parse_landing_chart.get_width_height(adimg, cksum) projs = meta.Session.query(AirportProjection).filter( sa.and_(AirportProjection.user == session['user'], AirportProjection.mapchecksum == cksum)).all() assert len(projs) <= 1 if len(projs) == 1 and not all( [x == 0 for x in projs[0].matrix[4:6]]): matrix = projs[0].matrix print "Using real projection", matrix else: #scale = number of pixels per latlon-increment matrix = self.invent_matrix(cksum, variant) A = matrix[0:4] T = matrix[4:6] transform = customproj.Transform(A, T) llc = transform.to_latlon((width / 2, height / 2)) print "Center of map in pixels is on lat lon", llc ll1 = transform.to_latlon((0, 0)) ll2 = transform.to_latlon((0, height)) ll3 = transform.to_latlon((width, height)) ll4 = transform.to_latlon((width, 0)) im = transform_map.get_png(width, height, ll1, ll2, ll3, ll4) io = StringIO.StringIO() im.save(io, format='png') io.seek(0) return io.read()
cksum = request.params.get("cksum") if cksum == None: cksum, proj = self.get_sel_cksum(chartname) assert cksum writeInt(0xaabb1234) if version != 1 and version != 2: print "bad version" writeInt(2) #error, bad version return None if not self.checkpass(): print "badpassword" writeInt(1) #error, bad pass return None width, height = parse_landing_chart.get_width_height( chartname=chartname, cksum=cksum) dummy, cksum0 = parse_landing_chart.get_chart(blobname=chartname, cksum=cksum, level=0) assert cksum0 == cksum proj = get_proj(cksum0) if proj: matrix = proj.matrix else: matrix = [0.0 for x in xrange(6)] zeromat = all([abs(x) < 1e-13 for x in matrix]) writeInt(0) #no error writeInt(version) #version writeInt(5) #numlevels