in analysis/webservice/algorithms/doms/fetchedgeimpl.py [0:0]
def __doQuery(endpoint, startTime, endTime, bbox, depth_min=None, depth_max=None, itemsPerPage=10, startIndex=0,
platforms=None,
pageCallback=None):
params = {"startTime": startTime, "endTime": endTime, "bbox": bbox, "itemsPerPage": itemsPerPage,
"startIndex": startIndex, "stats": "true"}
if depth_min is not None:
params['minDepth'] = depth_min
if depth_max is not None:
params['maxDepth'] = depth_max
if platforms is not None:
params["platform"] = platforms.split(",")
resultsRaw = __fetchJson(endpoint["url"], params)
boundsConstrainer = geo.BoundsConstrainer(north=-90, south=90, west=180, east=-180)
if resultsRaw["totalResults"] == 0 or len(resultsRaw["results"]) == 0: # Double-sanity check
return [], resultsRaw["totalResults"], startIndex, itemsPerPage, boundsConstrainer
try:
results = []
for resultdict in resultsRaw["results"]:
result = __resultRawToUsable(resultdict)
result["source"] = endpoint["name"]
boundsConstrainer.testCoords(north=result["y"], south=result["y"], west=result["x"], east=result["x"])
results.append(result)
if "stats_fields" in resultsRaw and len(resultsRaw["results"]) == 0:
stats = resultsRaw["stats_fields"]
if "lat" in stats and "lon" in stats:
boundsConstrainer.testCoords(north=stats['lat']['max'], south=stats['lat']['min'],
west=stats['lon']['min'], east=stats['lon']['max'])
if pageCallback is not None:
pageCallback(results)
'''
If pageCallback was supplied, we assume this call to be asynchronous. Otherwise combine all the results data and return it.
'''
if pageCallback is None:
return results, int(resultsRaw["totalResults"]), int(resultsRaw["startIndex"]), int(
resultsRaw["itemsPerPage"]), boundsConstrainer
else:
return [], int(resultsRaw["totalResults"]), int(resultsRaw["startIndex"]), int(
resultsRaw["itemsPerPage"]), boundsConstrainer
except:
print("Invalid or missing JSON in response.")
traceback.print_exc()
raise NexusProcessingException(reason="Invalid or missing JSON in response.")