def getbounds(): # Init my variables that i am going to be using dbUtils = DbUtils() top = "" right = "" bottom = "" left = "" edges = [] # Get my bounds from the server boundData = dbUtils.getBounds() # parse my boundData and set each row to a longitute and latitude in a list of dictionaries. for r in boundData: # get longitude out tempStrings = str(r).split() tempStrings[0] = tempStrings[0][8:] # get latitude out index = tempStrings[1].find(")") tempStrings[1] = tempStrings[1][0:index] # add that to a dictionary a = {"lon": tempStrings[0], "lat": tempStrings[1]} # add the dictionary to a list edges.append(a) # Check the latitudes for a top and bottom if float(edges[0]["lat"]) > float(edges[1]["lat"]): top = edges[0]["lat"] bottom = edges[1]["lat"] else: top = edges[1]["lat"] bottom = edges[0]["lat"] # Check longitude for a left and right if float(edges[0]["lon"]) < float(edges[1]["lon"]): left = edges[0]["lon"] right = edges[1]["lon"] else: right = edges[0]["lon"] left = edges[1]["lon"] # Create my json dictionary bounds = {"top": top, "bottom": bottom, "left": left, "right": right} # return the json to the user return jsonify(bounds)