def get_flowline(request): #If POST then generate the flowline if request.method == 'POST': print("Received!") print("Processing Flowline!") # process JSON xy points (Deserialize JSON) json_data = json.loads(request.body) long = json_data['long'] lat = json_data['lat'] distance = json_data['dist'] #Translator for lon,lat to x,y lonLatTrans = LonLatToProj([[long, lat]]) # create datasets; this is temporary until I find a way to store it myDatasetDict = createInitialDatasets() # put translated point into flowline initialFlowline = Flowline(lonLatTrans.xPoints[0], lonLatTrans.yPoints[0], myDatasetDict, distance) # Translate points back to lat,long xyTrans = ProjToLatLon(initialFlowline.flowLine) # dump flowline into JSONResponse (Serialize the dict) flowLinePoints = {'lon':xyTrans.lonPoints,'lat':xyTrans.latPoints} #Send the JSON back return JsonResponse(flowLinePoints) else: return(HttpResponse("This is not a POST Request"))
def get_point_data(request): if request.method == 'POST': json_data = json.loads(request.body) long = json_data['lon'] lat = json_data['lat'] lonLatTrans = LonLatToProj([[long, lat]]) datasetDict = createInitialDatasets() interp_point = Point(datasetDict, lonLatTrans.xPoints, lonLatTrans.yPoints) #Returns a JSON containing all the datasets for the point return JsonResponse(interp_point.dataValues) else: return HttpResponse("This is not a POST request")
self.flowLine = [] for x in range(0, self.distance): self.flowLine.append(None) self.flowLine[0] = [xStart, yStart] self.flowLine = myIntegrator.integrate(xStart, yStart, self.flowLine, 0, 1000) if (None in self.flowLine): print("Integration Error try again with new x, y") if __name__ == '__main__': latPoint = 69.87 longPoint = -47.01 from QSSICode.translation import LonLatToProj myTranslator = LonLatToProj([[longPoint, latPoint]]) from QSSICode.createDatasets import createInitialDatasets myDatasetDict = createInitialDatasets() myFlowline = Flowline(myTranslator.xPoints[0], myTranslator.yPoints[0], myDatasetDict, 100) print(myFlowline.flowLine) print(myFlowline.flowLine[0]) print(myFlowline.flowLine[1])
from QSSICode.getDataValues import Point from QSSICode.support.flow_model.modelRunner import ModelRunner from django.views.decorators.csrf import ensure_csrf_cookie, csrf_exempt import json from django.core.cache import caches from django.shortcuts import render from django.views.decorators.csrf import csrf_protect import numpy as np dataFileName = 'QSSICode/data/surtGreenland.h5' dataFileNameAnt = 'QSSICode/data/surtAntarctica.h5' #Code to set second dataset to GL for faster load times #dataFileNameAnt = 'QSSICode/data/surtGreenland.h5' datasetDict = createInitialDatasets(dataFileName) lcache = caches['default'] lcache.set('dict', datasetDict, None) datasetDictAnt = createInitialDatasets(dataFileNameAnt) lcache.set('dictAnt', datasetDictAnt, None) # Create your views here. # --------------------------- # This view sends the user to the landing/home page def display_home(request): #return render(request, 'UGP/index.bk.html', {}) return render(request, 'landing/index.html', {})
def main(argv): myDictionary = createInitialDatasets() myPoint = Point(myDictionary, -98998.55768989387, -2159531.8275367804) print(myPoint.dataValues)