Commit f56c858f authored by Emmanuel René Huchim Puc's avatar Emmanuel René Huchim Puc

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

parents 0ff150d6 41381b9b
...@@ -231,13 +231,13 @@ def to_if(name): ...@@ -231,13 +231,13 @@ def to_if(name):
#----------------------------------------------- #-----------------------------------------------
def best_unit_size(bytes_size): def best_unit_size(bytes_size):
""" """
Obtenga un tamaño en bytes y conviértalo en el mejor prefijo IEC para facilitar la lectura. Obtenga un tamano en bytes y conviertalo en el mejor prefijo IEC para facilitar la lectura.
Devuelva un diccionario con tres pares de claves / valores: Devuelva un diccionario con tres pares de claves / valores:
"s" - (flotador) Tamaño del camino convertido a la mejor unidad para una fácil lectura "s" - (flotador) Tamano del camino convertido a la mejor unidad para una facil lectura
"u" - (str) El prefijo (IEC) para s (de bytes (2 ^ 0) a YiB (2 ^ 80)) "u" - (str) El prefijo (IEC) para s (de bytes (2 ^ 0) a YiB (2 ^ 80))
"b" - (int / long) El tamaño original en bytes "b" - (int / long) El tamano original en bytes
""" """
for exp in range(0, 90 , 10): for exp in range(0, 90 , 10):
......
...@@ -26,11 +26,36 @@ body ...@@ -26,11 +26,36 @@ body
height: 550px; /*should be the same height as the images*/ height: 550px; /*should be the same height as the images*/
} }
.listImg{
z-index: 4;
}
.listImg ul{
list-style: none;
padding: 0px;
margin: 0px;
cursor: pointer;
}
.listImg ul li:hover{
background: #87CEFA;
}
.listImg ul .active{
color:red
}
.list {
max-height: 220px;
overflow: auto;
}
.img-comp-img { .img-comp-img {
position: absolute; position: absolute;
width: auto; width: auto;
height: auto; height: auto;
overflow:hidden; overflow:hidden;
z-index: 2;
} }
.img-comp-img img { .img-comp-img img {
......
...@@ -13,9 +13,6 @@ var reportImg = activePoints[0]; ...@@ -13,9 +13,6 @@ var reportImg = activePoints[0];
// 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) {
if (slider != false) {
deleteComparisons()
}
stop(); stop();
console.log("on click") console.log("on click")
...@@ -45,8 +42,6 @@ document.getElementById("myChart").onclick = function (evt) { ...@@ -45,8 +42,6 @@ document.getElementById("myChart").onclick = function (evt) {
}); });
var imagePoint = activePoints[imageNumber]; var imagePoint = activePoints[imageNumber];
oldLabel = label.slice(0, 4) + "/" + label.slice(4, 6) + "/" + label.slice(6);
document.getElementById("satImageSecond").src = "../../static/reports/tmpImages/repsat_test_dev/" + image_path + label + "_TCI_60m.jpg"
updateImage(imagePoint); updateImage(imagePoint);
//updateImage(firstPoint); //updateImage(firstPoint);
//alert("{{ IMAGE_PATH }}"+label+"_TCI_60m.jpg"); //alert("{{ IMAGE_PATH }}"+label+"_TCI_60m.jpg");
...@@ -63,10 +58,6 @@ function play() { ...@@ -63,10 +58,6 @@ function play() {
// $(".next").hide(); // $(".next").hide();
// $(".prev").hide(); // $(".prev").hide();
// $("#showImage").addClass('col-lg-offset-1'); // $("#showImage").addClass('col-lg-offset-1');
if (slider == false) {
document.getElementById("titleMap").innerHTML = oldLabel + " vs " + oldLabel;
initComparisons()
}
playImages = setInterval(function () { next(); }, 4000); playImages = setInterval(function () { next(); }, 4000);
} }
...@@ -129,11 +120,8 @@ function updateImage(imagePoint) { ...@@ -129,11 +120,8 @@ function updateImage(imagePoint) {
label = imagePoint; label = imagePoint;
reportImg = imagePoint; reportImg = imagePoint;
titleLabel = label.slice(0, 4) + "/" + label.slice(4, 6) + "/" + label.slice(6); titleLabel = label.slice(0, 4) + "/" + label.slice(4, 6) + "/" + label.slice(6);
if (slider != false) {
document.getElementById("titleMap").innerHTML = oldLabel + " vs " + titleLabel;
}else{
document.getElementById("titleMap").innerHTML = titleLabel; document.getElementById("titleMap").innerHTML = titleLabel;
} document.getElementById("titleSCL").innerHTML = titleLabel
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"
...@@ -175,11 +163,11 @@ function change(newType) { ...@@ -175,11 +163,11 @@ function change(newType) {
let img, imgWidth=0, slider=false, clicked=0; let img, imgWidth=0, slider=false, clicked=0;
function initComparisons() { function initComparisons() {
$("#showSecondImage").show() // $("#showSecondImage").show()
setTimeout(function() { // setTimeout(function() {
img = document.getElementsByClassName("img-comp-overlay")[0]; img = document.getElementsByClassName("img-comp-overlay")[0];
compareImages(img); compareImages(img);
}); //});
// setTimeout(function(){ // setTimeout(function(){
// img = document.getElementsByClassName("img-comp-overlay")[0]; // img = document.getElementsByClassName("img-comp-overlay")[0];
// compareImages(img); // compareImages(img);
...@@ -195,7 +183,7 @@ function compareImages(img) { ...@@ -195,7 +183,7 @@ function compareImages(img) {
img.style.width = ((imgWidth / 2)) + 15 + "px"; img.style.width = ((imgWidth / 2)) + 15 + "px";
/*create slider:*/ /*create slider:*/
slider = document.createElement("DIV"); slider = document.createElement("DIV");
slider.setAttribute("class", "img-comp-slider col-lg-offset-1 col-md-offset-1 col-xs-offset-2"); slider.setAttribute("class", "img-comp-slider col-lg-offset-2 col-md-offset-2 col-xs-offset-2");
/*insert slider*/ /*insert slider*/
img.parentElement.insertBefore(slider, img); img.parentElement.insertBefore(slider, img);
/*position the slider in the middle:*/ /*position the slider in the middle:*/
...@@ -266,9 +254,44 @@ function deleteComparisons(){ ...@@ -266,9 +254,44 @@ function deleteComparisons(){
window.removeEventListener("mousemove", slideMove); window.removeEventListener("mousemove", slideMove);
window.removeEventListener("touchmove", slideMove); window.removeEventListener("touchmove", slideMove);
$(".img-comp-slider").remove(); $(".img-comp-slider").remove();
$("#showSecondImage").hide()
slider= false; slider= false;
} }
//deleteComparisons(); //deleteComparisons();
//initComparisons(); //initComparisons();
function selectImage1(date, element) {
$("#imageListFirst li").removeClass("active");
element.classList.add("active");
let label = date.toString();
label = label.slice(0, 4) + "/" + label.slice(4, 6) + "/" + label.slice(6);
document.getElementById("titleImageFirst").innerHTML = label;
document.getElementById("satImageFirst").src = "../../static/reports/tmpImages/repsat_test_dev/" + image_path + date + "_TCI_60m.jpg"
}
function selectImage2(date,element) {
$("#imageListSecond li").removeClass("active");
element.classList.add("active");
let label = date.toString();
label = label.slice(0, 4) + "/" + label.slice(4, 6) + "/" + label.slice(6);
document.getElementById("titleImageSecond").innerHTML = label;
document.getElementById("satImageSecond").src = "../../static/reports/tmpImages/repsat_test_dev/" + image_path + date + "_TCI_60m.jpg"
}
$('.nav-tabs a').on('shown.bs.tab', function (evt) {
let tab = $(evt.target).text();
if(tab == "Comparison"){
initComparisons()
}
});
$('.nav-tabs a').on('hide.bs.tab', function (evt) {
let tab = $(evt.target).text();
if (tab == "Comparison") {
deleteComparisons();
}
if (tab == "Images") {
stop();
}
});
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
</div> </div>
<div class="box-body"> <div class="box-body">
<div id="openchart" class="chart"> <div id="openchart" class="chart">
<canvas id="myChart" style="height: 574px"></canvas> <canvas id="myChart" style="height: 594px"></canvas>
</div> </div>
</div> </div>
<!-- /.box-body --> <!-- /.box-body -->
...@@ -173,108 +173,125 @@ ...@@ -173,108 +173,125 @@
</div> </div>
<!-- /.col (LEFT) --> <!-- /.col (LEFT) -->
<div class="col-md-4"> <div class="col-md-4">
<div class="nav-tabs-custom" id="tabs">
<!-- RIGHT IMAGES --> <ul class="nav nav-tabs">
<li class="active"><a href="#images" data-toggle="tab">Images</a></li>
<li><a href="#compared" data-toggle="tab">Comparison</a></li>
<li><a href="#classification" data-toggle="tab">SCL</a></li>
<li><a href="#map" data-toggle="tab">Map</a></li>
</ul>
<div class="tab-content" style="padding: 0px">
<div class="tab-pane active" id="images">
<div class="box box-danger"> <div class="box box-danger">
<div class="box-header with-border"> <div class="box-header" style="text-align: center">
<div class="pull-left"> <div class="pull-left">
<button type="button" id="play" class="btn btn-block btn-primary btn-xs" style="" <button type="button" id="play" class="btn btn-block btn-primary btn-xs" style="" onclick="play()">
onclick="play()">
<i class="fa fa-play"></i> Play <i class="fa fa-play"></i> Play
</button> </button>
<button type="button" id="stop" class="btn btn-block btn-primary btn-xs" <button type="button" id="stop" class="btn btn-block btn-primary btn-xs" style="display: none; margin: 0px;"
style="display: none; margin: 0px;" onclick="stop()"> onclick="stop()">
<i class="fa fa-stop"></i> Stop <i class="fa fa-stop"></i> Stop
</button> </button>
</div> </div>
<!-- <h3 class="box-title" id="titleMap">{{dafaultLabel}} - {{defaultDataSet}}</h3> -->
<h3 class="box-title" id="titleMap" style="margin-left: -40px;">{{ defaultDataSet }}</h3> <h3 class="box-title" id="titleMap" style="margin-left: -40px;">{{ defaultDataSet }}</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i
class="fa fa-minus"></i>
</button>
<!-- <button type="button" class="btn btn-box-tool" data-widget="remove" onclick="stop()"><i
class="fa fa-times"></i></button> -->
</div>
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="row img-comp-container"> <div class="row img-comp-container">
<div class="col-lg-1 col-md-1 col-xs-1 prev" style="display: none"> <div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-1 col-md-offset-1 col-xs-offset-2"
<i class="glyphicon glyphicon-chevron-left" onclick="prev()"></i> style="padding: 0px 0px 0px 42px;">
</div>
<div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-1 col-md-offset-1 col-xs-offset-2 img-comp-img" id="showImage" style="padding: 0px 0px 0px 30px;">
<!-- <img onclick="window.open(this.src)" id="satImage" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{ dafaultLabel }}_TCI_60m.jpg"
style="margin-left: auto; margin-right: auto; display: block;"> -->
<img onclick="window.open(this.src)" width="375" id="satImage" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{ dafaultLabel }}_TCI_60m.jpg" <img onclick="window.open(this.src)" width="375" id="satImage" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{ dafaultLabel }}_TCI_60m.jpg"
style="margin-left: auto; margin-right: auto; display: block;"> style="margin-left: auto; margin-right: auto; display: block;">
</div> </div>
<div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-1 col-md-offset-1 col-xs-offset-2 img-comp-img img-comp-overlay" id="showSecondImage" style="padding: 0px 0px 0px 30px; display: none">
<!-- <img onclick="window.open(this.src)" id="satImage" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{ dafaultLabel }}_TCI_60m.jpg"
style="margin-left: auto; margin-right: auto; display: block;"> -->
<img onclick="window.open(this.src)" width="375" id="satImageSecond" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{ dafaultLabel }}_TCI_60m.jpg"
style="margin-left: auto; margin-right: auto; display: block;">
</div>
<div class="col-lg-1 col-md-1 col-xs-1 next" style="display: none">
<i class="glyphicon glyphicon-chevron-right" onclick="next()"></i>
</div>
</div> </div>
</div> </div>
<!-- /.box-body --> <!-- /.box-body -->
</div> </div>
<!-- *********************** FIN imagen satelital ******************--> </div>
<!-- RIGHT MAP init --> <!-- /.tab-pane -->
<div class="tab-pane" id="compared">
<div class="box box-danger"> <div class="box box-danger">
<div class="box-header with-border"> <div class="box-header" style="text-align: center">
<h3 class="box-title">Map</h3> <h3 class="box-title" id="titleImageFirst">{{ defaultDataSet }}</h3>
<h3 class="box-title"> vs </h3>
<div class="box-tools pull-right"> <h3 class="box-title" id="titleImageSecond">{{ defaultDataSet }}</h3>
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i </div>
class="fa fa-minus"></i> <div class="box-body">
</button> <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">
<ul id="imageListFirst">
{% for label in labels %}
{% if label == labels.0 %}
<li class="active" onclick="selectImage1({{label}}, this)">{{ label }}</li>
{% else %}
<li onclick="selectImage1({{label}}, this)">{{ label }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
<label>Image 2</label>
<div class="list">
<ul id="imageListSecond">
{% for label in labels %}
{% if label == labels.1 %}
<li class="active" onclick="selectImage2({{label}}, this)">{{ label }}</li>
{% else %}
<li onclick="selectImage2({{label}}, this)">{{ label }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-2 col-md-offset-1 col-xs-offset-2 img-comp-img" id="showImage"
style="padding: 0px 0px 0px 42px;">
<img onclick="window.open(this.src)" width="375" id="satImageSecond" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{labels.1}}_TCI_60m.jpg"
style="margin-left: auto; margin-right: auto; display: block;">
</div>
<div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-2 col-md-offset-1 col-xs-offset-2 img-comp-img img-comp-overlay"
id="showSecondImage" style="padding: 0px 0px 0px 42px;"">
<img onclick="window.open(this.src)" width="375" id="satImageFirst" src="../../static/reports/tmpImages/repsat_test_dev/{{ IMAGE_PATH }}{{labels.0}}_TCI_60m.jpg"
style="margin-left: auto; margin-right: auto; display: block;">
</div> </div>
</div> </div>
<div class="box-body" style="max-height: 533px;">
<div id="minimap" style="height: 533px"></div>
</div> </div>
<!-- /.box-body --> <!-- /.box-body -->
</div> </div>
<!-- RIGHT MAP end --> </div>
<!-- ************************ SCL **********************--> <!-- /.tab-pane -->
<div class="tab-pane" id="classification">
<div class="box box-danger"> <div class="box box-danger">
<div class="box-header with-border"> <div class="box-header" style="text-align: center">
<h3 class="box-title" id="titleMap">Scene Classification Map - {{ defaultDataSet }}</h3> <h3 class="box-title" >Scene Classification Map - </h3>
<h3 class="box-title" id="titleSCL">{{ defaultDataSet }}</h3>
<div class="box-tools pull-right"> <!-- <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
class="fa fa-minus"></i> class="fa fa-minus"></i>
</button> </button>
</div> </div> -->
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="row"> <div class="row">
<div class="col-lg-1 col-md-1 col-xs-1 prev" style="display: none"> <div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-1" id="showImageSCL" style="position: relative; height: 550px; padding: 0px 0px 0px 42px;">
<i class="glyphicon glyphicon-chevron-left" onclick="prev()"></i>
</div>
<div class="col-lg-10 col-md-9 col-xs-10 col-lg-offset-1" id="showImageSCL" style="position: relative; height: 580px;">
<img onclick="window.open(this.src)" class="img-responsive" id="scl_saturated" <img onclick="window.open(this.src)" class="img-responsive" id="scl_saturated"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_saturated.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_saturated.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_shadows" <img onclick="window.open(this.src)" class="img-responsive" id="scl_shadows"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_shadows.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_shadows.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_shadows" <img onclick="window.open(this.src)" class="img-responsive" id="scl_cloud_shadows"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_cloud_shadows.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_cloud_shadows.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_vegetation" <img onclick="window.open(this.src)" class="img-responsive" id="scl_vegetation"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_vegetation.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_vegetation.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_not-vegetated" <img onclick="window.open(this.src)" class="img-responsive" id="scl_not-vegetated"
width="400px" width="375"
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"
...@@ -282,7 +299,7 @@ ...@@ -282,7 +299,7 @@
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"
width="400px" width="375"
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"
...@@ -290,28 +307,31 @@ ...@@ -290,28 +307,31 @@
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"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_cloud_high_probability.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_cloud_high_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_thin_cirrus" <img onclick="window.open(this.src)" class="img-responsive" id="scl_thin_cirrus"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_thin_cirrus.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_thin_cirrus.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_snow" <img onclick="window.open(this.src)" class="img-responsive" id="scl_snow"
width="400px" width="375"
height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_snow.png" height="400px" src="../../static/reports/tmpImages/repsat_test_dev/{{ SCL_PATH }}{{ dafaultLabel }}_SCL_60m_snow.png"
style="position: absolute; top: 0; z-index:1;"> style="position: absolute; top: 0; z-index:1;">
</div> </div>
<div class="col-lg-1 col-md-1 col-xs-1 next" style="display: none">
<i class="glyphicon glyphicon-chevron-right" onclick="next()"></i>
</div>
</div> </div>
</div> </div>
<!-- /.box-body --> <!-- /.box-body -->
</div> </div>
<!-- ****************************** FIN SCL *********************** --> </div>
<!-- /.box --> <!-- /.tab-pane -->
<div class="tab-pane" id="map">
</div>
<!-- /.tab-pane -->
</div>
<!-- /.tab-content -->
</div>
</div> </div>
</div> </div>
<!-- /.row --> <!-- /.row -->
......
...@@ -135,6 +135,15 @@ ...@@ -135,6 +135,15 @@
</span> </span>
</a> </a>
</li> </li>
<li>
<a class="treeview submenu" href="../../static/reports/tmpImages/repsat_test_dev/{{ request.user.email }}/{{ purchaseID }}/{{ zone }}.pdf" id="downloadPdf">
<i class="fa fa-file-pdf-o"></i>
<span>Export to PDF v2</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul> </ul>
</li> </li>
<li> <li>
......
...@@ -10,6 +10,7 @@ from collections import OrderedDict ...@@ -10,6 +10,7 @@ from collections import OrderedDict
from django.core.paginator import Paginator from django.core.paginator import Paginator
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, render_to_response
from fpdf import FPDF
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
...@@ -33,35 +34,47 @@ USERS_PATH = config['PATHS']['PATH_USERS'] ...@@ -33,35 +34,47 @@ USERS_PATH = config['PATHS']['PATH_USERS']
def report_L2ASCL(request, report, purchase_id): 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:
##########################################
# Generador de pdfs #
##########################################
PDFGenerator(path, reporteDir)
##########################################
# Generador de pdfs #
##########################################
image_path = request.user.email + "/" + purchase_id + "/" + "out/" + reporteDir + "/TCI/thumbnails/"
SCL_path = request.user.email + "/" + purchase_id + "/" + "out/" + reporteDir + "/SCL/"
reporteDir = report.replace('_sclData','')
image_path = request.user.email + "/" + purchase_id + "/" + "out/"+reporteDir+"/TCI/thumbnails/"
SCL_path = request.user.email + "/" + purchase_id + "/" + "out/"+reporteDir+"/SCL/"
print(image_path)
absolute_path = USERS_PATH + request.user.email + "/" + purchase_id + "/out" absolute_path = USERS_PATH + request.user.email + "/" + purchase_id + "/out"
folders = os.listdir(path=absolute_path) folders = os.listdir(absolute_path)
json_route= USERS_PATH + request.user.email + "/" + purchase_id + "/" json_route = USERS_PATH + request.user.email + "/" + purchase_id + "/"
for file in os.listdir(path=json_route): for file in os.listdir(json_route):
if file.endswith("_sclData.json") and not file.endswith("merge_out_sclData.json"): if file.endswith("_sclData.json") and not file.endswith("merge_out_sclData.json"):
with open(USERS_PATH + request.user.email + "/" + purchase_id + "/" + file) as f: with open(USERS_PATH + request.user.email + "/" + purchase_id + "/" + file) as f:
json_data = OrderedDict(json.load(f)) json_data = OrderedDict(json.load(f))
if len(json_data)==0: if len(json_data) == 0:
if file[:6] in folders: if file[:6] in folders:
folders.remove(file[:6]) folders.remove(file[:6])
with open(USERS_PATH + request.user.email + "/" + purchase_id + "/findProducts.json") as p: with open(USERS_PATH + request.user.email + "/" + purchase_id + "/findProducts.json") as p:
dataProduct = json.load(p) dataProduct = json.load(p)
startDate = str(dataProduct['startDate'])[:4] +'-'+ str(dataProduct['startDate'])[4:6]+'-'+ str(dataProduct['startDate'])[6:8] startDate = str(dataProduct['startDate'])[:4] + '-' + str(dataProduct['startDate'])[4:6] + '-' + str(
endDate = str(dataProduct['endDate'])[:4] +'-'+ str(dataProduct['endDate'])[4:6]+'-'+ str(dataProduct['endDate'])[6:8] dataProduct['startDate'])[6:8]
endDate = str(dataProduct['endDate'])[:4] + '-' + str(dataProduct['endDate'])[4:6] + '-' + str(
dataProduct['endDate'])[6:8]
with open(USERS_PATH + request.user.email + "/" + purchase_id + "/" + report + ".json") as f: with open(USERS_PATH + request.user.email + "/" + purchase_id + "/" + report + ".json") as f:
json_data = OrderedDict(json.load(f)) json_data = OrderedDict(json.load(f))
if len(json_data)==0: if len(json_data) == 0:
graphData = "" graphData = ""
defaultLabel="" defaultLabel = ""
defaultDataset="" defaultDataset = ""
folders.remove(reporteDir) folders.remove(reporteDir)
else: else:
...@@ -104,24 +117,32 @@ def report_L2ASCL(request, report, purchase_id): ...@@ -104,24 +117,32 @@ def report_L2ASCL(request, report, purchase_id):
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]
defaultDataset = label[0:4]+"/"+label[4:6]+"/"+label[6:] defaultDataset = label[0:4] + "/" + label[4:6] + "/" + label[6:]
#defaultDataset = graphData['data']['datasets'][0]['label'] # defaultDataset = graphData['data']['datasets'][0]['label']
# print(settings.BASE_URL) # print(settings.BASE_URL)
# graphData['options']['responsive']=True # graphData['options']['responsive']=True
# graphData['options']['maintainAspectRatio']=False # graphData['options']['maintainAspectRatio']=False
# print(json.dumps(graphData).encode("utf-8")) # print(json.dumps(graphData).encode("utf-8"))
return render(request, 'L2ASCL_data.html', {"graphData": json.dumps(graphData),"name":"foo", "report_name": "SCL Image Classification Data(Km²)", "startDate": startDate,"endDate": endDate,"clouds": dataProduct['clouds'], "platform": dataProduct['platform'],"productLevel": dataProduct['productLevel'] ,"IMAGE_PATH": image_path, "SCL_PATH" : SCL_path, 'dafaultLabel': defaultLabel, 'defaultDataSet': defaultDataset, "folders" : folders,"zone":reporteDir, "purchaseID": purchase_id }) return render(request, 'L2ASCL_data.html', {"graphData": json.dumps(graphData), "name": "foo",
"report_name": "SCL Image Classification Data(Km²)",
"startDate": startDate, "endDate": endDate,
"clouds": dataProduct['clouds'], "platform": dataProduct['platform'],
"productLevel": dataProduct['productLevel'], "IMAGE_PATH": image_path,
"SCL_PATH": SCL_path, 'dafaultLabel': defaultLabel,
'defaultDataSet': defaultDataset, "folders": folders,
"zone": reporteDir, "purchaseID": purchase_id, "labels": graphData['data']['labels']})
# -------------------------------------------------------------------------------def Reports(request): # -------------------------------------------------------------------------------def Reports(request):
def Reports(request): def Reports(request):
progress = 0 progress = 0
productList = [] productList = []
size = 0 size = 0
folders=[] folders = []
zip ="" zip = ""
product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate', product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate',
'search__endDate', 'search__process_id__name', 'search__search_name').filter( 'search__endDate', 'search__process_id__name', 'search__search_name').filter(
user_id=request.user.id, purchased=1) user_id=request.user.id, purchased=1)
...@@ -161,29 +182,29 @@ def Reports(request): ...@@ -161,29 +182,29 @@ def Reports(request):
final_size = str(round(size, 2)) + " MB" final_size = str(round(size, 2)) + " MB"
initial_folder = "." initial_folder = "."
absolute_path = USERS_PATH + request.user.email + "/" +str(producto['id'])+ "/out" absolute_path = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/out"
if not os.path.exists(absolute_path): if not os.path.exists(absolute_path):
print("folder out noes not exists") print("folder out noes not exists")
else: else:
folders = os.listdir(path=absolute_path) folders = os.listdir(absolute_path)
print(folders)
if len(folders)==0: if len(folders) == 0:
initial_folder="../#" initial_folder = "../#"
else: else:
initial_folder = folders.pop(0)+"_sclData" initial_folder = folders.pop(0) + "_sclData"
zip_path = USERS_PATH + request.user.email + "/" +str(producto['id']) zip_path = USERS_PATH + request.user.email + "/" + str(producto['id'])
#print(zip_path) # print(zip_path)
#"../ static / reports / tmpImages / repsat_test_dev / umorales @ centrogeo.edu.mx / "+str(producto['id']) / myzip.zip" # "../ static / reports / tmpImages / repsat_test_dev / umorales @ centrogeo.edu.mx / "+str(producto['id']) / myzip.zip"
wkt = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/findProducts.json" wkt = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/findProducts.json"
with open(wkt, 'r') as jsonfile: with open(wkt, 'r') as jsonfile:
polygon = json.load(jsonfile) polygon = json.load(jsonfile)
for file in os.listdir(path=zip_path): for file in os.listdir(zip_path):
if file.endswith(".zip"): if file.endswith(".zip"):
zip = zip_path+"/"+file zip = zip_path + "/" + file
productList.append({ productList.append({
"search_name": producto['search__search_name'], "search_name": producto['search__search_name'],
"process": producto['search__process_id__name'], "process": producto['search__process_id__name'],
...@@ -195,8 +216,8 @@ def Reports(request): ...@@ -195,8 +216,8 @@ def Reports(request):
"purchase_id": producto['id'], "purchase_id": producto['id'],
"progress": progress, "progress": progress,
"log_info": log, "log_info": log,
"initial_folder" :initial_folder, "initial_folder": initial_folder,
"zip" : zip, "zip": zip,
"polygon": polygon['wkt'], "polygon": polygon['wkt'],
}) })
size = 0 size = 0
...@@ -204,9 +225,8 @@ def Reports(request): ...@@ -204,9 +225,8 @@ def Reports(request):
log_info = "" log_info = ""
progress = 0 progress = 0
initial_folder = "" initial_folder = ""
zip ="" zip = ""
wkt ="" wkt = ""
return render(request, 'Reports.html', {"productList": productList}) return render(request, 'Reports.html', {"productList": productList})
...@@ -218,7 +238,8 @@ def wsProcessProgress(request): ...@@ -218,7 +238,8 @@ def wsProcessProgress(request):
productList2 = [] productList2 = []
product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds',
'search__startDate', 'search__endDate', 'search__startDate', 'search__endDate',
'search__process_id__name', 'progress').filter(user_id=request.user.id, purchased=1) 'search__process_id__name', 'progress').filter(user_id=request.user.id,
purchased=1)
for producto in product_list: for producto in product_list:
log_info = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log" log_info = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log"
...@@ -239,9 +260,9 @@ def wsProcessProgress(request): ...@@ -239,9 +260,9 @@ def wsProcessProgress(request):
if 'Finalizing...' in open(log_info).read(): if 'Finalizing...' in open(log_info).read():
progress = 100 progress = 100
#item = Purchase.objects.get(pk=producto['id']) # item = Purchase.objects.get(pk=producto['id'])
#item.progress = progress # item.progress = progress
#item.save() # item.save()
productList2.append({ productList2.append({
"purchase_id": producto['id'], "purchase_id": producto['id'],
...@@ -313,3 +334,64 @@ def tileinfo(request): ...@@ -313,3 +334,64 @@ def tileinfo(request):
# result = add.apply_async((2, 1), countdown=3) # result = add.apply_async((2, 1), countdown=3)
# result.get() # result.get()
# return render_to_response('reports_table.html', {"result": 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')
\ No newline at end of file
...@@ -320,13 +320,13 @@ def to_if(name): ...@@ -320,13 +320,13 @@ def to_if(name):
# ----------------------------------------------- # -----------------------------------------------
def best_unit_size(bytes_size): def best_unit_size(bytes_size):
""" """
Obtenga un tamaño en bytes y conviértalo en el mejor prefijo IEC para facilitar la lectura. Obtenga un tamano en bytes y conviertalo en el mejor prefijo IEC para facilitar la lectura.
Devuelva un diccionario con tres pares de claves / valores: Devuelva un diccionario con tres pares de claves / valores:
"s" - (flotador) Tamaño del camino convertido a la mejor unidad para una fácil lectura "s" - (flotador) Tamano del camino convertido a la mejor unidad para una facil lectura
"u" - (str) El prefijo (IEC) para s (de bytes (2 ^ 0) a YiB (2 ^ 80)) "u" - (str) El prefijo (IEC) para s (de bytes (2 ^ 0) a YiB (2 ^ 80))
"b" - (int / long) El tamaño original en bytes "b" - (int / long) El tamano original en bytes
""" """
for exp in range(0, 90, 10): for exp in range(0, 90, 10):
......
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