def mgrs(request): """ Create mgrs grid in manner similar to usng above """ bbox = request.GET.get('bbox') if not bbox: return HttpResponse() bb = bbox.split(',') output = "" if not len(bb) == 4: output = json.dumps( dict( error=500, message= 'Need 4 corners of a bounding box passed in using EPSG 4386 lat/long format', grid=str(bb))) else: try: grid = Grid(bb[1], bb[0], bb[3], bb[2]) fc = grid.build_grid_fc() output = json.dumps(fc) except GridException: error = dict( error=500, details= "Can't create grids across longitudinal boundaries. Try creating a smaller bounding box", ) return HttpResponse(json.dumps(error), status=error.get('error'), mimetype="application/json") except GeoConvertException, e: error = dict( error=500, details="GeoConvert doesn't recognize those cooridnates", exception=str(e)) return HttpResponse(json.dumps(error), status=error.get('error'), mimetype="application/json") except ProgramException, e: error = dict( error=500, details= "Error executing external GeoConvert application. Make sure it is installed on the server", exception=str(e)) return HttpResponse(json.dumps(error), status=error.get('error'), mimetype="application/json")
def mgrs(request): """ Create mgrs grid in manner similar to usng above """ bbox = request.GET.get('bbox') if not bbox: return HttpResponse() bb = bbox.split(',') try: grid = Grid(bb[1], bb[0], bb[3], bb[2]) fc = grid.build_grid_fc() except GridException: error = dict( error=500, details= "Can't create grids across longitudinal boundaries. Try creating a smaller bounding box", ) return HttpResponse(json.dumps(error), status=error.get('error')) return HttpResponse(fc.__str__(), mimetype="application/json")