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
ced6890c
Commit
ced6890c
authored
May 29, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change in call to sentinel API
parent
44a74f0e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
29 deletions
+35
-29
__init__.py
catalog/apis/__init__.py
+0
-0
sentinel.py
catalog/apis/sentinel.py
+0
-23
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+13
-0
map.html
catalog/templates/map.html
+1
-0
urls.py
catalog/urls.py
+2
-1
views.py
catalog/views.py
+19
-5
No files found.
catalog/apis/__init__.py
deleted
100644 → 0
View file @
44a74f0e
catalog/apis/sentinel.py
deleted
100644 → 0
View file @
44a74f0e
import
imp
class
APISentinel
():
# area example:
# POLYGON((-89.62543487548828 21.068482340502072,-89.51351165771484 20.918472761430806,
# -89.72705841064453 20.9203969139719,-89.62543487548828 21.068482340502072))
# dates example:
# '2018-01-01'
# cloudPercentage example:
# "[0 TO 10]" or 95
def
getProducts
(
this
,
area
,
initDate
,
endDate
,
cloudPercentage
):
GeoSentinel_path
=
"/home/geointdev/sidt-env/GeoSentinel/geosentinel/APISentinel.py"
# GeoSentinel_path = "/home/emmanuelhp/Documentos/GeoSentinel/geosentinel/APISentinel.py"
api
=
imp
.
load_source
(
'geosentinel'
,
GeoSentinel_path
)
sentinel
=
api
.
APISentinel
(
'emmhp'
,
'geoemm29'
)
products
=
sentinel
.
getProducts
(
area
,
(
""
.
join
(
initDate
.
split
(
'-'
)),
""
.
join
(
endDate
.
split
(
'-'
))),
{
"platformname"
:
"Sentinel-2"
,
"cloudcoverpercentage"
:
cloudPercentage
})
return
products
catalog/static/js/dataRetrieval.js
View file @
ced6890c
...
...
@@ -213,6 +213,19 @@ $(document).ready(function () {
data
.
catalog
.
forEach
(
function
(
data
)
{
console
.
log
(
"DD: "
,
data
);
$
.
ajax
({
type
:
"POST"
,
url
:
img_req_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'value'
:
data
.
product
.
link_icon
},
dataType
:
'text'
,
success
:
function
(
response
)
{
// console.log("from img response: ", response);
}
});
var
product_html
=
'<li id="'
+
data
.
id
+
' class="hover-me">'
+
'<a href="javascript:void(0)">'
+
'<i class="menu-icon glyphicon glyphicon-bookmark bg-red"></i>'
+
...
...
catalog/templates/map.html
View file @
ced6890c
...
...
@@ -268,5 +268,6 @@
osmap
.
addInteraction
();
var
req_url
=
"{% url 'search-submit' %}"
;
// url for requesting polygon data
var
prod_req_url
=
"{% url 'productList' %}"
// url for requesting product data
var
img_req_url
=
"{% url 'img-rqst' %}"
// url for requestim preview image
</script>
{% endblock %}
catalog/urls.py
View file @
ced6890c
...
...
@@ -7,6 +7,7 @@ urlpatterns = [
url
(
r'^$'
,
views
.
map
,
name
=
'map'
),
url
(
r'^productlist/$'
,
views
.
productList
,
name
=
'productList'
),
url
(
r'^regionsearched/$'
,
views
.
regionSearched
,
name
=
'regionSearched'
),
url
(
r'^searchsubmit/$'
,
views
.
SearchSubmitView
.
as_view
(),
name
=
'search-submit'
)
url
(
r'^searchsubmit/$'
,
views
.
SearchSubmitView
.
as_view
(),
name
=
'search-submit'
),
url
(
r'^imgrequest/$'
,
views
.
requestToImage
,
name
=
'img-rqst'
)
]
catalog/views.py
View file @
ced6890c
...
...
@@ -10,8 +10,12 @@ from django.views.generic.base import View
from
django.template
import
loader
from
urllib
import
urlencode
import
requests
,
json
,
unicodedata
from
apis.sentinel
import
APISentinel
import
random
import
random
,
sys
,
imp
sys
.
path
.
append
(
'../'
)
from
geosentinel
import
APISentinel
sentinel
=
APISentinel
.
APISentinel
(
'emmhp'
,
'geoemm29'
)
# Create your views here.
#-------------------------------------------------------------------------------
...
...
@@ -33,6 +37,16 @@ def map(request):
# Render the HTML template index.html with the data in the context variable
return
render
(
request
,
'map.html'
,
{
"searchForm"
:
form
})
#-------------------------------------------------------------------------------
def
requestToImage
(
request
):
# print("REQUEST: ", request.POST['value'])
img_link
=
request
.
POST
[
'value'
]
# img_link = img_link[:img_link.find("/") + 2] + "emmhp:geoemm29@" + img_link[img_link.find("/") + 2:]
r
=
requests
.
get
(
img_link
,
auth
=
(
"emmhp"
,
"geoemm29"
))
return
JsonResponse
({
'img'
:
r
.
content
})
#-------------------------------------------------------------------------------
def
productList
(
request
):
"""
...
...
@@ -45,13 +59,13 @@ def productList(request):
area
=
req
[
'polygon'
][
0
]
init_date
=
req
[
'start'
][
0
][:
10
]
end_date
=
req
[
'end'
][
0
][:
10
]
cloud_percentage
=
req
[
'cloudPercentage'
][
0
]
cloud_percentage
=
"[0 TO "
+
req
[
'cloudPercentage'
][
0
]
+
"]"
## ----- aqui llamada a api sentinel
## ----- antes consultar en DB si no se tiene ya el producto
sentinel
=
APISentinel
()
products
=
sentinel
.
getProducts
(
area
,
init_date
,
end_date
,
cloud_percentage
)
products
=
sentinel
.
getProducts
(
area
,
(
""
.
join
(
init_date
.
split
(
'-'
)),
""
.
join
(
end_date
.
split
(
'-'
))),
{
"platformname"
:
"Sentinel-2"
,
"cloudcoverpercentage"
:
cloud_percentage
}
)
## 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)])
...
...
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