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; ...@@ -10,6 +10,10 @@ var playImages;
var reportImg = activePoints[0]; var reportImg = activePoints[0];
//var myChart; //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 // mostrar imagen al dar click en los puntos
document.getElementById("myChart").onclick = function (evt) { document.getElementById("myChart").onclick = function (evt) {
...@@ -29,7 +33,7 @@ document.getElementById("myChart").onclick = function (evt) { ...@@ -29,7 +33,7 @@ document.getElementById("myChart").onclick = function (evt) {
//console.log(firstPoint) //console.log(firstPoint)
//console.log(firstPoint._datasetIndex) //indice de la clase a la que pertenece (vegetación, agua, etc.) //console.log(firstPoint._datasetIndex) //indice de la clase a la que pertenece (vegetación, agua, etc.)
var label = myChart.data.labels[firstPoint._index]; var label = myChart.data.labels[firstPoint._index];
addImageLayer(label) //addImageLayer(label)
console.log("label: ") console.log("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.) //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) { ...@@ -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("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" SCLlayers.forEach(function (layer) {
document.getElementById("scl_shadows").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_shadows.png" if (layer != "no_data") {
document.getElementById("scl_cloud_shadows").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_cloud_shadows.png" 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" }
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"
//document.getElementById("scl_vegetation").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_vegetation.png" //document.getElementById("scl_vegetation").src = "../../static/reports/tmpImages/repsat_test_dev/" + scl_path + label + "_SCL_60m_vegetation.png"
} }
......
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
<h4>End date: {{ endDate }}</h4> <h4>End date: {{ endDate }}</h4>
</div> </div>
<div class="col-lg-2 text-center"> <div class="col-lg-2 text-center">
<h4>Clouds: {{ clouds }}</h4> <h4>Clouds: {{ clouds }} %</h4>
</div> </div>
</div> </div>
</div> </div>
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
<div class="row img-comp-container"> <div class="row img-comp-container">
<div class="col-lg-3 col-md-2 col-xs-2 listImg"> <div class="col-lg-3 col-md-2 col-xs-2 listImg">
<label>Image 1</label> <label>Image 1</label>
<div class="list"> <div class ="list" style="margin-bottom: 20px">
<ul id="imageListFirst"> <ul id="imageListFirst">
{% for label in labels %} {% for label in labels %}
{% if label == labels.0 %} {% if label == labels.0 %}
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_not-vegetated.png" 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;"> style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_water" <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" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_water.png"
style="position: absolute; top: 0; z-index:1;"> style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_unclassified" <img onclick="window.open(this.src)" class="img-responsive" id="scl_unclassified"
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_unclassified.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_unclassified.png"
style="position: absolute; top: 0; z-index:1;"> style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_cloud_medium_probability" <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" 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;"> style="position: absolute; top: 0; z-index:1;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_cloud_high_probability" <img onclick="window.open(this.src)" class="img-responsive" id="scl_cloud_high_probability"
...@@ -423,10 +423,12 @@ ...@@ -423,10 +423,12 @@
if(meta.hidden){ if(meta.hidden){
console.log("Mostrar!!!") console.log("Mostrar!!!")
SCLlayers.push(layer)
document.getElementById("scl_"+layer).src = "../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}"+label+"_SCL_60m_"+layer+".png" document.getElementById("scl_"+layer).src = "../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}"+label+"_SCL_60m_"+layer+".png"
} }
else{ else{
console.log("Ocultar!!") console.log("Ocultar!!")
SCLlayers.splice(SCLlayers.indexOf(layer), 1);
document.getElementById("scl_"+layer).src = "" document.getElementById("scl_"+layer).src = ""
} }
//if (index > 1) { //if (index > 1) {
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
</a> </a>
</li> </li>
<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> <i class="fa fa-file-pdf-o"></i>
<span>Export to PDF v2</span> <span>Export to PDF v2</span>
<span class="pull-right-container"> <span class="pull-right-container">
......
...@@ -7,16 +7,13 @@ import xml.etree.ElementTree as ET ...@@ -7,16 +7,13 @@ import xml.etree.ElementTree as ET
# Create your views here. # Create your views here.
from collections import OrderedDict from collections import OrderedDict
from django.core.paginator import Paginator from datetime import datetime
from django.http import HttpResponse, Http404, JsonResponse from django.http import HttpResponse, Http404, JsonResponse
from django.shortcuts import render, render_to_response from django.shortcuts import render
from fpdf import FPDF from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from GeoInt_SIDT.tasks import add
from catalog.models import Purchase from catalog.models import Purchase
from GeoInt_SIDT.tasks import *
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
...@@ -37,13 +34,15 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -37,13 +34,15 @@ def report_L2ASCL(request, report, purchase_id):
reporteDir = report.replace('_sclData', '') reporteDir = report.replace('_sclData', '')
path = USERS_PATH + request.user.email + '/' + purchase_id + '/' path = USERS_PATH + request.user.email + '/' + purchase_id + '/'
if os.path.isfile(path + reporteDir + '.pdf'): #PDFGenerator(request, path, reporteDir)
pass
else: #if os.path.isfile(path + reporteDir + '.pdf'):
# pass
#else:
########################################## ##########################################
# Generador de pdfs # # Generador de pdfs #
########################################## ##########################################
PDFGenerator(path, reporteDir) # PDFGenerator(request, path, reporteDir)
########################################## ##########################################
# Generador de pdfs # # Generador de pdfs #
########################################## ##########################################
...@@ -112,8 +111,14 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -112,8 +111,14 @@ def report_L2ASCL(request, report, purchase_id):
item['backgroundColor'] = colors[int(l)] item['backgroundColor'] = colors[int(l)]
data['datasets'].append(item) data['datasets'].append(item)
data['datasets'].sort(key=lambda k: max(k['data'])) data['datasets'].sort(key=lambda k: max(k['data']))
PDFGenerator(request, path, reporteDir,data['datasets'])
graphData['data'] = data graphData['data'] = data
label = graphData['data']['labels'][0] label = graphData['data']['labels'][0]
defaultLabel = graphData['data']['labels'][0] defaultLabel = graphData['data']['labels'][0]
...@@ -334,28 +339,10 @@ def tileinfo(request): ...@@ -334,28 +339,10 @@ def tileinfo(request):
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# def tareas(): def PDFGenerator(request,ruta, reporteDir, datasets):
# result = add.apply_async((2, 1), countdown=3) thumbs = ruta+'out/'+reporteDir+'/TCI/thumbnails/'
# result.get() SCL = ruta+'out/'+reporteDir+'/SCL/'
# 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/making_charts #
# check https://developers.google.com/chart/image/docs/chart_params#gcharts_cht # # check https://developers.google.com/chart/image/docs/chart_params#gcharts_cht #
...@@ -364,38 +351,67 @@ def PDFGenerator(path, reporteDir): ...@@ -364,38 +351,67 @@ def PDFGenerator(path, reporteDir):
# chl = labels # # chl = labels #
################################################################################# #################################################################################
url = "http://chart.apis.google.com/chart" \ path, dirs, files = next(os.walk(thumbs))
"?cht=p3" \ w, h = letter
"&chd=t:60,40" \
"&chs=500x200" \
"&chl=Hello|World" \ c = canvas.Canvas(ruta+reporteDir + ".pdf", pagesize=letter,)
"&.png"
self.image(url) # Header #
# Arial bold 15 c.drawImage(USERS_PATH + 'header.png', 170, h - 90, width=300, height=70)
self.set_font('Arial', 'B', 15)
# Move to the right
self.cell(80) c.showPage()
# Title
self.cell(30, 10, 'Title', 1, 0, 'C') # aqui estan los datos de todas las lineas #
# Line break #for data2 in datasets:
self.ln(20) # solo de la linea verde #
#print(data2['data'][0])
# Page footer
def footer(self):
# Position at 1.5 cm from bottom
self.set_y(-15)
# Arial italic 8 # body #
self.set_font('Arial', 'I', 8) for file in files:
# Page number
self.cell(0, 10, 'Page ' + str(self.page_no()) + '/{nb}', 0, 0, 'C')
date = datetime.strptime(file[:8], '%Y%m%d').strftime('%d/%m/%Y')
# Instantiation of inherited class
pdf = PDF() c.drawString(280, h - 125, date)
pdf.alias_nb_pages()
pdf.add_page() c.drawString(160, h - 165, 'TCI')
pdf.set_font('Times', '', 12) c.drawString(440, h - 165, 'SCL')
for i in range(1, 5): c.drawImage(USERS_PATH + 'header.png', 170, h - 90, width=300, height=70)
pdf.imagenes()
# Thumb image #
pdf.output(path + reporteDir + '.pdf', 'F') 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