pdf v2

parent f8931e6d
...@@ -46,8 +46,8 @@ def report_L2ASCL(request, purchase_id): ...@@ -46,8 +46,8 @@ def report_L2ASCL(request, purchase_id):
template = "sclData.html" template = "sclData.html"
reporteDir = 'mask' reporteDir = 'mask'
folders = "" folders = ""
purchase = Purchase.objects.values('user__email', 'is_public', 'search__search_name', purchase = Purchase.objects.values('user__email', 'is_public', 'search__search_name',
'search__process_id__name').get(pk=purchase_id) 'search__process_id__name').get(pk=purchase_id)
email = purchase['user__email'] email = purchase['user__email']
path = USERS_PATH + email + '/' + purchase_id + '/' path = USERS_PATH + email + '/' + purchase_id + '/'
scl_data_path = USERS_PATH + email + "/" + purchase_id + "/scl_data.json" scl_data_path = USERS_PATH + email + "/" + purchase_id + "/scl_data.json"
...@@ -74,7 +74,7 @@ def report_L2ASCL(request, purchase_id): ...@@ -74,7 +74,7 @@ def report_L2ASCL(request, purchase_id):
"process": purchase['search__process_id__name'], "process": purchase['search__process_id__name'],
"startDate": startDate, "startDate": startDate,
"endDate": endDate, "endDate": endDate,
"clouds": dataProduct['clouds'], "clouds": dataProduct['clouds'],
"platform": dataProduct['platform'], "platform": dataProduct['platform'],
"productLevel": dataProduct['productLevel'], "productLevel": dataProduct['productLevel'],
"polygon": dataProduct['wkt'], "polygon": dataProduct['wkt'],
...@@ -333,16 +333,27 @@ def dataToTable(name, data): ...@@ -333,16 +333,27 @@ def dataToTable(name, data):
# create the table for our document # create the table for our document
def myTable(path1, path2, basefile): def myTable(path1, path2, basefile):
image1 = Image(path1, height=300, width=200, mask='auto') #image1 = Image(path1, height=300, width=200, mask='auto')
image1 = Image(path1)
if image1.imageWidth < image1.imageHeight:
print ("mas alto que ancho")
image2 = Image(path1, height=300, width=200, mask='auto')
else:
image2 = Image(path1, height=150, width=400, mask='auto')
path, dirs, files = next(os.walk(path2)) path, dirs, files = next(os.walk(path2))
for file in files: for file in files:
if file.startswith(basefile[:8]): if file.startswith(basefile[:8]):
if file.endswith('.tif') and not file.endswith('0.tif'): if file.endswith('.tif') and not file.endswith('0.tif'):
# image2 = Image(path2 + file, height=300, width=200, mask='auto') # image2 = Image(path2 + file, height=300, width=200, mask='auto')
image2 = image1 image3 = image2
data = [['TCI', 'SCL'], [image1, image2]] if image1.imageWidth < image1.imageHeight:
data = [['TCI', 'SCL'], [image2, image3]]
else:
data = [['TCI'], [image2], ['SCL'], [image3]]
t = Table(data) t = Table(data)
GRID_STYLE = TableStyle( GRID_STYLE = TableStyle(
...@@ -372,7 +383,7 @@ def myBarChart(data, maxi, fecha): ...@@ -372,7 +383,7 @@ def myBarChart(data, maxi, fecha):
bc.strokeColor = colors.black bc.strokeColor = colors.black
bc.valueAxis.valueMin = 0 bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = maxi+100 bc.valueAxis.valueMax = maxi + 100
bc.valueAxis.valueStep = 50 bc.valueAxis.valueStep = 50
bc.categoryAxis.labels.boxAnchor = 'ne' bc.categoryAxis.labels.boxAnchor = 'ne'
...@@ -456,19 +467,25 @@ def PDFGenerator(request, ruta, reporteDir, datasets): ...@@ -456,19 +467,25 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
values = [] values = []
labels = [] labels = []
maxi = 0 maxi = 0
#for data in datasets: # for data in datasets:
for data in datasets[:len(datasets) - 1]: for data in datasets[:len(datasets) - 1]:
if maxi > data['data'][index]: if maxi > data['data'][index]:
maxi = maxi maxi = maxi
else: else:
maxi = data['data'][index] maxi = data['data'][index]
#print (maxi) # print (maxi)
values.append([data['data'][index]]) values.append([data['data'][index]])
labels.append(data['label']) labels.append(data['label'])
path1 = thumbs + file path1 = thumbs + file
# Header # Header
# print (width)
#########################33
im = Image(USERS_PATH + 'header.png', width=300, height=70) im = Image(USERS_PATH + 'header.png', width=300, height=70)
im.hAlign = 'CENTER' im.hAlign = 'CENTER'
story.append(im) story.append(im)
...@@ -491,9 +508,9 @@ def PDFGenerator(request, ruta, reporteDir, datasets): ...@@ -491,9 +508,9 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
story.append(Spacer(1, .5 * inch)) story.append(Spacer(1, .5 * inch))
# add barchart and legend # add barchart and legend
#drawing = myBarChart(values[:len(values) - 1], maxi, file) # drawing = myBarChart(values[:len(values) - 1], maxi, file)
drawing = myBarChart(values, maxi, file) drawing = myBarChart(values, maxi, file)
#drawing = myBarLegend(drawing, labels[:len(labels) - 1]) # drawing = myBarLegend(drawing, labels[:len(labels) - 1])
drawing = myBarLegend(drawing, labels) drawing = myBarLegend(drawing, labels)
drawing.hAlign = 'CENTER' drawing.hAlign = 'CENTER'
story.append(drawing) story.append(drawing)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment