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
d329c7a7
Commit
d329c7a7
authored
May 28, 2018
by
Emmanuel René Huchim Puc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return catalog
parent
daf9f2ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
sentinel.py
catalog/apis/sentinel.py
+7
-7
views.py
catalog/views.py
+11
-6
No files found.
catalog/apis/sentinel.py
View file @
d329c7a7
...
@@ -5,18 +5,18 @@ class APISentinel():
...
@@ -5,18 +5,18 @@ class APISentinel():
# area example:
# area example:
# POLYGON((-89.62543487548828 21.068482340502072,-89.51351165771484 20.918472761430806,
# POLYGON((-89.62543487548828 21.068482340502072,-89.51351165771484 20.918472761430806,
# -89.72705841064453 20.9203969139719,-89.62543487548828 21.068482340502072))
# -89.72705841064453 20.9203969139719,-89.62543487548828 21.068482340502072))
# date example:
# dates example:
# ('20180101', '20180517')
# '2018-01-01'
# cloudPercentage axample:
# cloudPercentage example:
# "[0 TO 10]"
# "[0 TO 10]" or 95
# 95
def
getProducts
(
this
,
area
,
initDate
,
endDate
,
cloudPercentage
):
def
getProducts
(
this
,
area
,
initDate
,
endDate
,
cloudPercentage
):
GeoSentinel_path
=
"/home/emmanuelhp/Documentos/
geo/
GeoSentinel/geosentinel/APISentinel.py"
GeoSentinel_path
=
"/home/emmanuelhp/Documentos/GeoSentinel/geosentinel/APISentinel.py"
api
=
imp
.
load_source
(
'geosentinel'
,
GeoSentinel_path
)
api
=
imp
.
load_source
(
'geosentinel'
,
GeoSentinel_path
)
sentinel
=
api
.
APISentinel
(
'emmhp'
,
'geoemm29'
)
sentinel
=
api
.
APISentinel
(
'emmhp'
,
'geoemm29'
)
products
=
sentinel
.
getProducts
(
area
,
(
initDate
,
endDate
),
products
=
sentinel
.
getProducts
(
area
,
(
""
.
join
(
initDate
.
split
(
'-'
)),
""
.
join
(
endDate
.
split
(
'-'
))),
{
"platformname"
:
"Sentinel-2"
,
"cloudcoverpercentage"
:
cloudPercentage
})
{
"platformname"
:
"Sentinel-2"
,
"cloudcoverpercentage"
:
cloudPercentage
})
return
products
return
products
catalog/views.py
View file @
d329c7a7
...
@@ -40,7 +40,6 @@ def productList(request):
...
@@ -40,7 +40,6 @@ def productList(request):
"""
"""
req
=
dict
(
request
.
POST
)
req
=
dict
(
request
.
POST
)
req
.
pop
(
'csrfmiddlewaretoken'
,
None
)
req
.
pop
(
'csrfmiddlewaretoken'
,
None
)
# s = APISentinel()
city_name
=
req
[
'city'
][
0
]
city_name
=
req
[
'city'
][
0
]
process
=
req
[
'platform'
][
0
]
process
=
req
[
'platform'
][
0
]
...
@@ -52,16 +51,15 @@ def productList(request):
...
@@ -52,16 +51,15 @@ def productList(request):
## ----- aqui llamada a api sentinel
## ----- aqui llamada a api sentinel
## ----- antes consultar en DB si no se tiene ya el producto
## ----- antes consultar en DB si no se tiene ya el producto
# sentinel_result = s.getProducts(area, init_date, end_date, cloud_percentage)
sentinel
=
APISentinel
()
products
=
sentinel
.
getProducts
(
area
,
init_date
,
end_date
,
cloud_percentage
)
## simulation of 6-digit random id, this will be obtain from sentinel(?)
## simulation of 6-digit random id, this will be obtain from sentinel(?)
random_id
=
''
.
join
([
"
%
s"
%
random
.
randint
(
0
,
9
)
for
i
in
range
(
0
,
6
)])
# random_id = ''.join(["%s" % random.randint(0, 9) for i in range(0, 6)])
## path from image preview storage location
## path from image preview storage location
img_preview
=
'/static/images/sat_preview/sat_test.jpg'
img_preview
=
'/static/images/sat_preview/sat_test.jpg'
item_data
=
{
item_data
=
{
'id'
:
random_id
,
'img'
:
img_preview
,
'img'
:
img_preview
,
'city_name'
:
city_name
,
'city_name'
:
city_name
,
'process'
:
process
,
'process'
:
process
,
...
@@ -70,7 +68,14 @@ def productList(request):
...
@@ -70,7 +68,14 @@ def productList(request):
'cloud_percentage'
:
cloud_percentage
'cloud_percentage'
:
cloud_percentage
}
}
return
JsonResponse
(
item_data
);
# se crea una lista de objetos del catalogo
catalog
=
[]
for
p
in
products
:
item_data
[
'id'
]
=
products
[
p
][
'uuid'
]
item_data
[
'product'
]
=
products
[
p
]
catalog
.
append
(
item_data
)
return
JsonResponse
({
'catalog'
:
catalog
});
# r2 = dict(request.POST)
# r2 = dict(request.POST)
# r2.pop('csrfmiddlewaretoken', None)
# r2.pop('csrfmiddlewaretoken', None)
...
...
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