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
86ec3834
Commit
86ec3834
authored
Mar 14, 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 dev
parents
a7086234
7e0995c5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
93 deletions
+109
-93
reportImg.js
reports/static/reports/js/reportImg.js
+10
-12
L2ASCL_data.html
reports/templates/L2ASCL_data.html
+6
-4
aside.html
reports/templates/aside.html
+1
-1
views.py
reports/views.py
+92
-76
No files found.
reports/static/reports/js/reportImg.js
View file @
86ec3834
...
...
@@ -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"
}
...
...
reports/templates/L2ASCL_data.html
View file @
86ec3834
...
...
@@ -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) {
...
...
reports/templates/aside.html
View file @
86ec3834
...
...
@@ -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"
>
...
...
reports/views.py
View file @
86ec3834
...
...
@@ -7,16 +7,13 @@ import xml.etree.ElementTree as ET
# Create your views here.
from
collections
import
OrderedDict
from
d
jango.core.paginator
import
Paginator
from
d
atetime
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,28 +339,10 @@ 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
(
request
,
ruta
,
reporteDir
,
datasets
):
thumbs
=
ruta
+
'out/'
+
reporteDir
+
'/TCI/thumbnails/'
SCL
=
ruta
+
'out/'
+
reporteDir
+
'/SCL/'
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 #
...
...
@@ -364,38 +351,67 @@ def PDFGenerator(path, reporteDir):
# 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'
)
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
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