Commit 86ec3834 authored by Emmanuel René Huchim Puc's avatar Emmanuel René Huchim Puc

Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev

parents a7086234 7e0995c5
......@@ -10,6 +10,10 @@ var playImages;
var reportImg = activePoints[0];
//var myChart;
var SCLlayers = []
config.data.datasets.forEach(function (layer) {
SCLlayers.push(layer.label.toLowerCase().replace(/\s/g, '_'));
});
// mostrar imagen al dar click en los puntos
document.getElementById("myChart").onclick = function (evt) {
......@@ -29,7 +33,7 @@ document.getElementById("myChart").onclick = function (evt) {
//console.log(firstPoint)
//console.log(firstPoint._datasetIndex) //indice de la clase a la que pertenece (vegetación, agua, etc.)
var label = myChart.data.labels[firstPoint._index];
addImageLayer(label)
//addImageLayer(label)
console.log("label: ")
console.log(label)
//console.log(myChart.legend.legendItems[firstPoint._datasetIndex].text) //nombre de la capa a la que pertenece (vegetación, agua, etc.)
......@@ -130,17 +134,11 @@ function updateImage(imagePoint) {
document.getElementById("satImage").src = "../../static/reports/tmpImages/repsat_test_dev/" + image_path + label + "_TCI_60m.jpg"
document.getElementById("scl_saturated").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_saturated.png"
document.getElementById("scl_shadows").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_shadows.png"
document.getElementById("scl_cloud_shadows").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_cloud_shadows.png"
document.getElementById("scl_vegetation").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_vegetation.png"
document.getElementById("scl_not-vegetated").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_not-vegetated.png"
document.getElementById("scl_water").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_water.png"
document.getElementById("scl_unclassified").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_unclassified.png"
document.getElementById("scl_cloud_medium_probability").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_cloud_medium_probability.png"
document.getElementById("scl_cloud_high_probability").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_cloud_high_probability.png"
document.getElementById("scl_thin_cirrus").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_thin_cirrus.png"
document.getElementById("scl_snow").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_snow.png"
SCLlayers.forEach(function (layer) {
if (layer != "no_data") {
document.getElementById("scl_" + layer).src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_" + layer + ".png"
}
})
//document.getElementById("scl_vegetation").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_vegetation.png"
}
......
......@@ -139,7 +139,7 @@
<h4>End date: {{ endDate }}</h4>
</div>
<div class="col-lg-2 text-center">
<h4>Clouds: {{ clouds }}</h4>
<h4>Clouds: {{ clouds }} %</h4>
</div>
</div>
</div>
......@@ -219,7 +219,7 @@
<div class="row img-comp-container">
<div class="col-lg-3 col-md-2 col-xs-2 listImg">
<label>Image 1</label>
<div class="list">
<div class ="list" style="margin-bottom: 20px">
<ul id="imageListFirst">
{% for label in labels %}
{% if label == labels.0 %}
......@@ -295,7 +295,7 @@
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_not-vegetated.png"
style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_water"
width="400px"
width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_water.png"
style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_unclassified"
......@@ -303,7 +303,7 @@
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_unclassified.png"
style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_cloud_medium_probability"
width="400px"
width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_cloud_medium_probability.png"
style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_cloud_high_probability"
......@@ -423,10 +423,12 @@
if(meta.hidden){
console.log("Mostrar!!!")
SCLlayers.push(layer)
document.getElementById("scl_"+layer).src = "../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}"+label+"_SCL_60m_"+layer+".png"
}
else{
console.log("Ocultar!!")
SCLlayers.splice(SCLlayers.indexOf(layer), 1);
document.getElementById("scl_"+layer).src = ""
}
//if (index > 1) {
......
......@@ -136,7 +136,7 @@
</a>
</li>
<li>
<a class="treeview submenu" href="../../static/reports/tmpImages/repsat_test_dev/{{ request.user.email }}/{{ purchaseID }}/{{ zone }}.pdf" id="downloadPdf">
<a class="treeview submenu" href="../../static/reports/tmpImages/repsat_test_dev/{{ request.user.email }}/{{ purchaseID }}/{{ zone }}.pdf" id="downloadPdf" target="_blank">
<i class="fa fa-file-pdf-o"></i>
<span>Export to PDF v2</span>
<span class="pull-right-container">
......
......@@ -7,16 +7,13 @@ import xml.etree.ElementTree as ET
# Create your views here.
from collections import OrderedDict
from django.core.paginator import Paginator
from datetime import datetime
from django.http import HttpResponse, Http404, JsonResponse
from django.shortcuts import render, render_to_response
from fpdf import FPDF
from django.shortcuts import render
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from django.views.decorators.csrf import csrf_exempt
from GeoInt_SIDT.tasks import add
from catalog.models import Purchase
from GeoInt_SIDT.tasks import *
# -------------------------------------------------------------------------------
......@@ -37,13 +34,15 @@ def report_L2ASCL(request, report, purchase_id):
reporteDir = report.replace('_sclData', '')
path = USERS_PATH + request.user.email + '/' + purchase_id + '/'
if os.path.isfile(path + reporteDir + '.pdf'):
pass
else:
#PDFGenerator(request, path, reporteDir)
#if os.path.isfile(path + reporteDir + '.pdf'):
# pass
#else:
##########################################
# Generador de pdfs #
##########################################
PDFGenerator(path, reporteDir)
# PDFGenerator(request, path, reporteDir)
##########################################
# Generador de pdfs #
##########################################
......@@ -112,8 +111,14 @@ def report_L2ASCL(request, report, purchase_id):
item['backgroundColor'] = colors[int(l)]
data['datasets'].append(item)
data['datasets'].sort(key=lambda k: max(k['data']))
PDFGenerator(request, path, reporteDir,data['datasets'])
graphData['data'] = data
label = graphData['data']['labels'][0]
defaultLabel = graphData['data']['labels'][0]
......@@ -334,68 +339,79 @@ def tileinfo(request):
# ------------------------------------------------------------------------
# def tareas():
# result = add.apply_async((2, 1), countdown=3)
# result.get()
# return render_to_response('reports_table.html', {"result": result.get()})
def PDFGenerator(path, reporteDir):
class PDF(FPDF):
def header(self):
#self.image('logo.jpg')
# Arial bold 15
self.set_font('Arial', 'B', 15)
# Move to the right
self.cell(80)
# Title
self.cell(30, 10, 'Title', 1, 0, 'C')
# Line break
self.ln(20)
def imagenes(self):
#################################################################################
# check https://developers.google.com/chart/image/docs/making_charts #
# check https://developers.google.com/chart/image/docs/chart_params#gcharts_cht #
# cht = type #
# chd = data values #
# chl = labels #
#################################################################################
url = "http://chart.apis.google.com/chart" \
"?cht=p3" \
"&chd=t:60,40" \
"&chs=500x200" \
"&chl=Hello|World" \
"&.png"
self.image(url)
# Arial bold 15
self.set_font('Arial', 'B', 15)
# Move to the right
self.cell(80)
# Title
self.cell(30, 10, 'Title', 1, 0, 'C')
# Line break
self.ln(20)
# Page footer
def footer(self):
# Position at 1.5 cm from bottom
self.set_y(-15)
# Arial italic 8
self.set_font('Arial', 'I', 8)
# Page number
self.cell(0, 10, 'Page ' + str(self.page_no()) + '/{nb}', 0, 0, 'C')
# Instantiation of inherited class
pdf = PDF()
pdf.alias_nb_pages()
pdf.add_page()
pdf.set_font('Times', '', 12)
for i in range(1, 5):
pdf.imagenes()
pdf.output(path + reporteDir + '.pdf', 'F')
def PDFGenerator(request,ruta, reporteDir, datasets):
thumbs = ruta+'out/'+reporteDir+'/TCI/thumbnails/'
SCL = ruta+'out/'+reporteDir+'/SCL/'
#################################################################################
# check https://developers.google.com/chart/image/docs/making_charts #
# check https://developers.google.com/chart/image/docs/chart_params#gcharts_cht #
# cht = type #
# chd = data values #
# chl = labels #
#################################################################################
path, dirs, files = next(os.walk(thumbs))
w, h = letter
c = canvas.Canvas(ruta+reporteDir + ".pdf", pagesize=letter,)
# Header #
c.drawImage(USERS_PATH + 'header.png', 170, h - 90, width=300, height=70)
c.showPage()
# aqui estan los datos de todas las lineas #
#for data2 in datasets:
# solo de la linea verde #
#print(data2['data'][0])
# body #
for file in files:
date = datetime.strptime(file[:8], '%Y%m%d').strftime('%d/%m/%Y')
c.drawString(280, h - 125, date)
c.drawString(160, h - 165, 'TCI')
c.drawString(440, h - 165, 'SCL')
c.drawImage(USERS_PATH + 'header.png', 170, h - 90, width=300, height=70)
# Thumb image #
c.drawImage(thumbs + file, 70, h - 470, height=300, width=200,mask='auto')
# SCL image #
path2, dirs2, files2 = next(os.walk(SCL))
for file2 in files2:
if file2.startswith(file[:8]):
if not file2.endswith('.tif'):
c.drawImage(SCL + file2, 350, h - 470, height=300, width=200,mask='auto')
# Chart #
# los valores deben ir en chd para cada elemento #
grafica = "https://chart.googleapis.com/chart?" \
"&chs=900x150" \
"&cht=bvs" \
"&chd=t:0,0.0216,0,5.1408,29.8728,34.1892,57.0528,142.6788,506.6496,107.8344,0" \
"&chds=a" \
"&chco=ff8afa|659acc|99d4d9|696767|98775b|ababab|dddddd|d9f9ff|44ba5d|fff98b|383838" \
"&chxt=y" \
"&chm=N,000000,0,-1,11"
c.drawImage(grafica, 140, h - 650, width=900, height=150)
c.drawImage(USERS_PATH + 'values.png', 70, h - 680, width=500, height=25)
c.showPage()
c.save()
pass
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