return catalog

parent daf9f2ce
...@@ -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
...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment