Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
f56c858f
Commit
f56c858f
authored
Mar 13, 2019
by
Emmanuel René Huchim Puc
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into images_map
parents
0ff150d6
41381b9b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
368 additions
and
209 deletions
+368
-209
views.py
administration/views.py
+4
-4
scldata.css
reports/static/reports/css/scldata.css
+25
-0
reportImg.js
reports/static/reports/js/reportImg.js
+44
-21
L2ASCL_data.html
reports/templates/L2ASCL_data.html
+152
-132
aside.html
reports/templates/aside.html
+9
-0
views.py
reports/views.py
+131
-49
views.py
users/views.py
+3
-3
No files found.
administration/views.py
View file @
f56c858f
...
...
@@ -231,13 +231,13 @@ def to_if(name):
#-----------------------------------------------
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 tama
no en bytes y convie
rtalo en el mejor prefijo IEC para facilitar la lectura.
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) Tama
no del camino convertido a la mejor unidad para una fa
cil lectura
"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 tama
n
o original en bytes
"""
for
exp
in
range
(
0
,
90
,
10
):
...
...
reports/static/reports/css/scldata.css
View file @
f56c858f
...
...
@@ -26,11 +26,36 @@ body
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
{
position
:
absolute
;
width
:
auto
;
height
:
auto
;
overflow
:
hidden
;
z-index
:
2
;
}
.img-comp-img
img
{
...
...
reports/static/reports/js/reportImg.js
View file @
f56c858f
...
...
@@ -13,9 +13,6 @@ var reportImg = activePoints[0];
// mostrar imagen al dar click en los puntos
document
.
getElementById
(
"myChart"
).
onclick
=
function
(
evt
)
{
if
(
slider
!=
false
)
{
deleteComparisons
()
}
stop
();
console
.
log
(
"on click"
)
...
...
@@ -45,8 +42,6 @@ document.getElementById("myChart").onclick = function (evt) {
});
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(firstPoint);
//alert("{{ IMAGE_PATH }}"+label+"_TCI_60m.jpg");
...
...
@@ -63,10 +58,6 @@ function play() {
// $(".next").hide();
// $(".prev").hide();
// $("#showImage").addClass('col-lg-offset-1');
if
(
slider
==
false
)
{
document
.
getElementById
(
"titleMap"
).
innerHTML
=
oldLabel
+
" vs "
+
oldLabel
;
initComparisons
()
}
playImages
=
setInterval
(
function
()
{
next
();
},
4000
);
}
...
...
@@ -129,11 +120,8 @@ function updateImage(imagePoint) {
label
=
imagePoint
;
reportImg
=
imagePoint
;
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
(
"titleSCL"
).
innerHTML
=
titleLabel
document
.
getElementById
(
"satImage"
).
src
=
"../../static/reports/tmpImages/repsat_test_dev/"
+
image_path
+
label
+
"_TCI_60m.jpg"
...
...
@@ -175,11 +163,11 @@ function change(newType) {
let
img
,
imgWidth
=
0
,
slider
=
false
,
clicked
=
0
;
function
initComparisons
()
{
$
(
"#showSecondImage"
).
show
()
setTimeout
(
function
()
{
//
$("#showSecondImage").show()
//
setTimeout(function() {
img
=
document
.
getElementsByClassName
(
"img-comp-overlay"
)[
0
];
compareImages
(
img
);
});
//
});
// setTimeout(function(){
// img = document.getElementsByClassName("img-comp-overlay")[0];
// compareImages(img);
...
...
@@ -195,7 +183,7 @@ function compareImages(img) {
img
.
style
.
width
=
((
imgWidth
/
2
))
+
15
+
"px"
;
/*create slider:*/
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*/
img
.
parentElement
.
insertBefore
(
slider
,
img
);
/*position the slider in the middle:*/
...
...
@@ -266,9 +254,44 @@ function deleteComparisons(){
window
.
removeEventListener
(
"mousemove"
,
slideMove
);
window
.
removeEventListener
(
"touchmove"
,
slideMove
);
$
(
".img-comp-slider"
).
remove
();
$
(
"#showSecondImage"
).
hide
()
slider
=
false
;
}
//deleteComparisons();
//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
();
}
});
reports/templates/L2ASCL_data.html
View file @
f56c858f
...
...
@@ -162,7 +162,7 @@
</div>
<div
class=
"box-body"
>
<div
id=
"openchart"
class=
"chart"
>
<canvas
id=
"myChart"
style=
"height: 5
7
4px"
></canvas>
<canvas
id=
"myChart"
style=
"height: 5
9
4px"
></canvas>
</div>
</div>
<!-- /.box-body -->
...
...
@@ -173,108 +173,125 @@
</div>
<!-- /.col (LEFT) -->
<div
class=
"col-md-4"
>
<!-- RIGHT IMAGES -->
<div
class=
"nav-tabs-custom"
id=
"tabs"
>
<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-header with-bord
er"
>
<div
class=
"box-header"
style=
"text-align: cent
er"
>
<div
class=
"pull-left"
>
<button
type=
"button"
id=
"play"
class=
"btn btn-block btn-primary btn-xs"
style=
""
onclick=
"play()"
>
<button
type=
"button"
id=
"play"
class=
"btn btn-block btn-primary btn-xs"
style=
""
onclick=
"play()"
>
<i
class=
"fa fa-play"
></i>
Play
</button>
<button
type=
"button"
id=
"stop"
class=
"btn btn-block btn-primary btn-xs
"
style=
"display: none; margin: 0px;"
onclick=
"stop()"
>
<button
type=
"button"
id=
"stop"
class=
"btn btn-block btn-primary btn-xs"
style=
"display: none; margin: 0px;
"
onclick=
"stop()"
>
<i
class=
"fa fa-stop"
></i>
Stop
</button>
</div>
<!-- <h3 class="box-title" id="titleMap">{{dafaultLabel}} - {{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
class=
"box-body"
>
<div
class=
"row img-comp-container"
>
<div
class=
"col-lg-1 col-md-1 col-xs-1 prev"
style=
"display: none"
>
<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 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;"> -->
<div
class=
"col-lg-10 col-md-9 col-xs-10 col-lg-offset-1 col-md-offset-1 col-xs-offset-2"
style=
"padding: 0px 0px 0px 42px;"
>
<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;"
>
</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>
<!-- /.box-body -->
</div>
<!-- *********************** FIN imagen satelital ******************-->
<!-- RIGHT MAP init -->
</div>
<!-- /.tab-pane -->
<div
class=
"tab-pane"
id=
"compared"
>
<div
class=
"box box-danger"
>
<div
class=
"box-header with-border"
>
<h3
class=
"box-title"
>
Map
</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>
<div
class=
"box-header"
style=
"text-align: center"
>
<h3
class=
"box-title"
id=
"titleImageFirst"
>
{{ defaultDataSet }}
</h3>
<h3
class=
"box-title"
>
vs
</h3>
<h3
class=
"box-title"
id=
"titleImageSecond"
>
{{ defaultDataSet }}
</h3>
</div>
<div
class=
"box-body"
>
<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
class=
"box-body"
style=
"max-height: 533px;"
>
<div
id=
"minimap"
style=
"height: 533px"
></div>
</div>
<!-- /.box-body -->
</div>
<!-- RIGHT MAP end -->
<!-- ************************ SCL **********************-->
</div>
<!-- /.tab-pane -->
<div
class=
"tab-pane"
id=
"classification"
>
<div
class=
"box box-danger"
>
<div
class=
"box-header with-border"
>
<h3
class=
"box-title"
id=
"titleMap"
>
Scene Classification Map - {{ defaultDataSet }}
</h3>
<div
class=
"box-header"
style=
"text-align: center"
>
<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
class="fa fa-minus"></i>
</button>
</div
>
</div> --
>
</div>
<div
class=
"box-body"
>
<div
class=
"row"
>
<div
class=
"col-lg-1 col-md-1 col-xs-1 prev"
style=
"display: none"
>
<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;"
>
<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;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
<img
onclick=
"window.open(this.src)"
class=
"img-responsive"
id=
"scl_water"
...
...
@@ -282,7 +299,7 @@
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"
width=
"400px
"
width=
"375
"
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"
...
...
@@ -290,28 +307,31 @@
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"
width=
"400px
"
width=
"375
"
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;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
<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"
style=
"position: absolute; top: 0; z-index:1;"
>
</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>
<!-- /.box-body -->
</div>
<!-- ****************************** FIN SCL *********************** -->
<!-- /.box -->
</div>
<!-- /.tab-pane -->
<div
class=
"tab-pane"
id=
"map"
>
</div>
<!-- /.tab-pane -->
</div>
<!-- /.tab-content -->
</div>
</div>
</div>
<!-- /.row -->
...
...
reports/templates/aside.html
View file @
f56c858f
...
...
@@ -135,6 +135,15 @@
</span>
</a>
</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>
</li>
<li>
...
...
reports/views.py
View file @
f56c858f
...
...
@@ -10,6 +10,7 @@ from collections import OrderedDict
from
django.core.paginator
import
Paginator
from
django.http
import
HttpResponse
,
Http404
,
JsonResponse
from
django.shortcuts
import
render
,
render_to_response
from
fpdf
import
FPDF
from
django.views.decorators.csrf
import
csrf_exempt
...
...
@@ -33,35 +34,47 @@ USERS_PATH = config['PATHS']['PATH_USERS']
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"
folders
=
os
.
listdir
(
path
=
absolute_path
)
json_route
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
purchase_id
+
"/"
folders
=
os
.
listdir
(
absolute_path
)
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"
):
with
open
(
USERS_PATH
+
request
.
user
.
email
+
"/"
+
purchase_id
+
"/"
+
file
)
as
f
:
json_data
=
OrderedDict
(
json
.
load
(
f
))
if
len
(
json_data
)
==
0
:
if
len
(
json_data
)
==
0
:
if
file
[:
6
]
in
folders
:
folders
.
remove
(
file
[:
6
])
with
open
(
USERS_PATH
+
request
.
user
.
email
+
"/"
+
purchase_id
+
"/findProducts.json"
)
as
p
:
dataProduct
=
json
.
load
(
p
)
startDate
=
str
(
dataProduct
[
'startDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'startDate'
])[
4
:
6
]
+
'-'
+
str
(
dataProduct
[
'startDate'
])[
6
:
8
]
endDate
=
str
(
dataProduct
[
'endDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'endDate'
])[
4
:
6
]
+
'-'
+
str
(
dataProduct
[
'endDate'
])[
6
:
8
]
startDate
=
str
(
dataProduct
[
'startDate'
])[:
4
]
+
'-'
+
str
(
dataProduct
[
'startDate'
])[
4
:
6
]
+
'-'
+
str
(
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
:
json_data
=
OrderedDict
(
json
.
load
(
f
))
if
len
(
json_data
)
==
0
:
if
len
(
json_data
)
==
0
:
graphData
=
""
defaultLabel
=
""
defaultDataset
=
""
defaultLabel
=
""
defaultDataset
=
""
folders
.
remove
(
reporteDir
)
else
:
...
...
@@ -104,24 +117,32 @@ def report_L2ASCL(request, report, purchase_id):
graphData
[
'data'
]
=
data
label
=
graphData
[
'data'
][
'labels'
][
0
]
defaultLabel
=
graphData
[
'data'
][
'labels'
][
0
]
defaultDataset
=
label
[
0
:
4
]
+
"/"
+
label
[
4
:
6
]
+
"/"
+
label
[
6
:]
#
defaultDataset = graphData['data']['datasets'][0]['label']
defaultDataset
=
label
[
0
:
4
]
+
"/"
+
label
[
4
:
6
]
+
"/"
+
label
[
6
:]
#
defaultDataset = graphData['data']['datasets'][0]['label']
# print(settings.BASE_URL)
# graphData['options']['responsive']=True
# graphData['options']['maintainAspectRatio']=False
# 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
):
progress
=
0
productList
=
[]
size
=
0
folders
=
[]
zip
=
""
folders
=
[]
zip
=
""
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'search__startDate'
,
'search__endDate'
,
'search__process_id__name'
,
'search__search_name'
)
.
filter
(
user_id
=
request
.
user
.
id
,
purchased
=
1
)
...
...
@@ -161,29 +182,29 @@ def Reports(request):
final_size
=
str
(
round
(
size
,
2
))
+
" MB"
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
):
print
(
"folder out noes not exists"
)
else
:
folders
=
os
.
listdir
(
path
=
absolute_path
)
print
(
folders
)
if
len
(
folders
)
==
0
:
initial_folder
=
"../#"
folders
=
os
.
listdir
(
absolute_path
)
if
len
(
folders
)
==
0
:
initial_folder
=
"../#"
else
:
initial_folder
=
folders
.
pop
(
0
)
+
"_sclData"
initial_folder
=
folders
.
pop
(
0
)
+
"_sclData"
zip_path
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
#print(zip_path)
zip_path
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
#
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"
with
open
(
wkt
,
'r'
)
as
jsonfile
:
polygon
=
json
.
load
(
jsonfile
)
for
file
in
os
.
listdir
(
path
=
zip_path
):
for
file
in
os
.
listdir
(
zip_path
):
if
file
.
endswith
(
".zip"
):
zip
=
zip_path
+
"/"
+
file
zip
=
zip_path
+
"/"
+
file
productList
.
append
({
"search_name"
:
producto
[
'search__search_name'
],
"process"
:
producto
[
'search__process_id__name'
],
...
...
@@ -195,8 +216,8 @@ def Reports(request):
"purchase_id"
:
producto
[
'id'
],
"progress"
:
progress
,
"log_info"
:
log
,
"initial_folder"
:
initial_folder
,
"zip"
:
zip
,
"initial_folder"
:
initial_folder
,
"zip"
:
zip
,
"polygon"
:
polygon
[
'wkt'
],
})
size
=
0
...
...
@@ -204,9 +225,8 @@ def Reports(request):
log_info
=
""
progress
=
0
initial_folder
=
""
zip
=
""
wkt
=
""
zip
=
""
wkt
=
""
return
render
(
request
,
'Reports.html'
,
{
"productList"
:
productList
})
...
...
@@ -218,7 +238,8 @@ def wsProcessProgress(request):
productList2
=
[]
product_list
=
Purchase
.
objects
.
values
(
'id'
,
'productList'
,
'aggreg_date'
,
'search__clouds'
,
'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
:
log_info
=
USERS_PATH
+
request
.
user
.
email
+
"/"
+
str
(
producto
[
'id'
])
+
"/L2ASCL_AreaProcessing.log"
...
...
@@ -239,9 +260,9 @@ def wsProcessProgress(request):
if
'Finalizing...'
in
open
(
log_info
)
.
read
():
progress
=
100
#item = Purchase.objects.get(pk=producto['id'])
#item.progress = progress
#item.save()
#
item = Purchase.objects.get(pk=producto['id'])
#
item.progress = progress
#
item.save()
productList2
.
append
({
"purchase_id"
:
producto
[
'id'
],
...
...
@@ -313,3 +334,64 @@ def tileinfo(request):
# 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'
)
\ No newline at end of file
users/views.py
View file @
f56c858f
...
...
@@ -320,13 +320,13 @@ def to_if(name):
# -----------------------------------------------
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 tama
no en bytes y convie
rtalo en el mejor prefijo IEC para facilitar la lectura.
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) Tama
no del camino convertido a la mejor unidad para una fa
cil lectura
"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 tama
n
o original en bytes
"""
for
exp
in
range
(
0
,
90
,
10
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment