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
69c31a50
Commit
69c31a50
authored
Aug 31, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
performance improvement
parent
6394ede9
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
178 additions
and
135 deletions
+178
-135
populate_products_l1c.py
catalog/management/commands/populate_products_l1c.py
+24
-14
populate_products_l2a.py
catalog/management/commands/populate_products_l2a.py
+21
-10
models.py
catalog/models.py
+0
-5
body.css
catalog/static/css/body.css
+6
-0
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+117
-99
map.html
catalog/templates/map.html
+1
-1
templates.html
catalog/templates/templates.html
+9
-6
No files found.
catalog/management/commands/populate_products_l1c.py
View file @
69c31a50
...
@@ -44,8 +44,13 @@ class Command(BaseCommand):
...
@@ -44,8 +44,13 @@ class Command(BaseCommand):
uri
=
"https://scihub.copernicus.eu/dhus/odata/v1/Products?$filter=Name eq '"
+
product_name
+
"'"
uri
=
"https://scihub.copernicus.eu/dhus/odata/v1/Products?$filter=Name eq '"
+
product_name
+
"'"
r
=
requests
.
get
(
uri
,
auth
=
(
usr
,
pwd
))
r
=
requests
.
get
(
uri
,
auth
=
(
usr
,
pwd
))
root
=
ET
.
fromstring
(
r
.
content
)
root
=
ET
.
fromstring
(
r
.
content
)
print
root
# base_link = root[5][0].text
# base_link = root[5][0].text
uuid
=
root
[
5
][
11
][
0
]
.
text
try
:
uuid
=
root
[
5
][
11
][
0
]
.
text
except
:
print
root
print
"
\n
"
data_dict
=
apiSentinel
.
get_product_odata
(
uuid
,
full
=
True
)
data_dict
=
apiSentinel
.
get_product_odata
(
uuid
,
full
=
True
)
...
@@ -68,18 +73,23 @@ class Command(BaseCommand):
...
@@ -68,18 +73,23 @@ class Command(BaseCommand):
PRODUCT_EXISTS
=
Product_l1c
.
objects
.
filter
(
identifier
=
file_name
)
.
exists
()
PRODUCT_EXISTS
=
Product_l1c
.
objects
.
filter
(
identifier
=
file_name
)
.
exists
()
if
not
PRODUCT_EXISTS
:
if
not
PRODUCT_EXISTS
:
data_dict
=
self
.
generate_json
(
file_name
)
try
:
# print json.dumps(data_dict, indent=3, sort_keys=True, default=str)
data_dict
=
self
.
generate_json
(
file_name
)
# print json.dumps(data_dict, indent=3, sort_keys=True, default=str)
product_l1c
=
Product_l1c
(
uuid
=
data_dict
[
'id'
],
product_l1c
=
Product_l1c
(
identifier
=
data_dict
[
'Identifier'
],
uuid
=
data_dict
[
'id'
],
file_path
=
path
,
identifier
=
data_dict
[
'Identifier'
],
json
=
json
.
dumps
(
data_dict
,
indent
=
3
,
sort_keys
=
True
,
ensure_ascii
=
True
,
default
=
str
)
file_path
=
path
,
)
json
=
json
.
dumps
(
data_dict
,
indent
=
3
,
sort_keys
=
True
,
ensure_ascii
=
True
,
default
=
str
)
)
product_l1c
.
save
()
print
"Id: "
+
data_dict
[
'id'
]
product_l1c
.
save
()
print
"Id: "
+
data_dict
[
'id'
]
except
:
print
"Error con el archivo "
+
file_name
else
:
else
:
print
"Product "
+
file_name
+
"is already in DB."
# print "Product " + file_name + " is already in DB."
pass
catalog/management/commands/populate_products_l2a.py
View file @
69c31a50
...
@@ -33,13 +33,24 @@ class Command(BaseCommand):
...
@@ -33,13 +33,24 @@ class Command(BaseCommand):
for
file
in
file_list
:
for
file
in
file_list
:
file_name
=
file
.
replace
(
".zip"
,
''
)
file_name
=
file
.
replace
(
".zip"
,
''
)
prod_l1c
=
Product_l1c
.
objects
.
all
()
.
filter
(
identifier
=
file_name
)[
0
]
try
:
PRODUCT_EXISTS
=
Product_l2a
.
objects
.
filter
(
identifier
=
file_name
)
.
exists
()
product_l2a
=
Product_l2a
(
prod_l1c
=
prod_l1c
,
if
not
PRODUCT_EXISTS
:
identifier
=
prod_l1c
.
identifier
,
prod_l1c
=
Product_l1c
.
objects
.
filter
(
identifier
=
file_name
)[
0
]
file_path
=
path
)
product_l2a
=
Product_l2a
(
prod_l1c
=
prod_l1c
,
product_l2a
.
save
()
identifier
=
prod_l1c
.
identifier
,
print
prod_l1c
.
identifier
file_path
=
path
)
product_l2a
.
save
()
print
prod_l1c
.
identifier
else
:
"Existe"
except
:
print
"Error con archivo "
+
file_name
catalog/models.py
View file @
69c31a50
...
@@ -27,11 +27,6 @@ class Polygon(models.Model):
...
@@ -27,11 +27,6 @@ class Polygon(models.Model):
wkt_polygon
=
models
.
TextField
(
null
=
True
)
wkt_polygon
=
models
.
TextField
(
null
=
True
)
class
KeyNameTable
(
models
.
Model
):
id
=
models
.
CharField
(
max_length
=
10
,
primary_key
=
True
,
unique
=
True
)
name
=
models
.
CharField
(
max_length
=
65
)
class
Product_l1c
(
models
.
Model
):
class
Product_l1c
(
models
.
Model
):
uuid
=
models
.
CharField
(
max_length
=
50
)
uuid
=
models
.
CharField
(
max_length
=
50
)
identifier
=
models
.
CharField
(
max_length
=
50
)
identifier
=
models
.
CharField
(
max_length
=
50
)
...
...
catalog/static/css/body.css
View file @
69c31a50
...
@@ -361,6 +361,12 @@ div .sidebar-button button {
...
@@ -361,6 +361,12 @@ div .sidebar-button button {
bottom
:
30px
;
bottom
:
30px
;
}
}
.single-product-input
input
[
type
=
checkbox
]
{
float
:
right
;
margin-right
:
5%
;
margin-top
:
8%
;
}
/*ul.control-sidebar-menu input[type=checkbox] {*/
/*ul.control-sidebar-menu input[type=checkbox] {*/
/*position: absolute;*/
/*position: absolute;*/
/*right: 20px;*/
/*right: 20px;*/
...
...
catalog/static/js/dataRetrieval.js
View file @
69c31a50
This diff is collapsed.
Click to expand it.
catalog/templates/map.html
View file @
69c31a50
...
@@ -243,7 +243,7 @@
...
@@ -243,7 +243,7 @@
{% endblock %}
{% endblock %}
{% block templates %}{% include "templates.html" %}{% endblock %}
{% block templates %}{% include "templates.html" %}{% endblock %}
{% block modal1 %}{% include "
noProducts
Modal.html" %}{% endblock %}
{% block modal1 %}{% include "
mssg
Modal.html" %}{% endblock %}
{% block scripts %}
{% block scripts %}
<script>
<script>
...
...
catalog/templates/templates.html
View file @
69c31a50
...
@@ -22,14 +22,17 @@
...
@@ -22,14 +22,17 @@
<!-- product list template -->
<!-- product list template -->
<template
id=
"product_list_template"
>
<template
id=
"product_list_template"
>
<div
id=
""
class=
"single-product-input"
>
<input
type=
"checkbox"
name=
"product_selected"
value=
""
checked
>
</div>
<li
id=
""
onclick=
"drawApiResponse(this);"
>
<li
id=
""
onclick=
"drawApiResponse(this);"
>
<a
href=
"javascript:void(0)"
>
<a
href=
"javascript:void(0)"
>
<i
class=
"menu-icon glyphicon glyphicon-bookmark bg-red"
></i>
<i
class=
"menu-icon glyphicon glyphicon-bookmark bg-red"
></i>
<div
class=
"menu-info"
>
<div
class=
"menu-info"
>
<h4
id=
""
class=
"control-sidebar-subheading"
></h4>
<h4
id=
""
class=
"control-sidebar-subheading"
></h4>
<p></p>
<p></p>
<input
type=
"checkbox"
name=
"product_selected"
value=
""
checked
>
<!-- <input type="checkbox" name="product_selected" value="" checked> --
>
</div>
</div>
</a>
</a>
<div
class=
"info-product-box bg-geo"
>
<div
class=
"info-product-box bg-geo"
>
<span
class=
"info-product-box-img"
>
<span
class=
"info-product-box-img"
>
...
...
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