def stationData(request):
    if request.method == 'POST':
        received_json_data = json.loads(request.body)
        stationDataHandle(received_json_data)
        return ResponseJson('ok')
    else:
        return ResponseBad('error')
def POIDetail(request):
    if request.method == 'POST':
        received_json_data = json.loads(request.body)
        POIDetailHandle(received_json_data)
        return ResponseJson('ok')
    else:
        return ResponseBad('error')
def saveGateway(request):
    if request.method == 'POST':
        received_json_data = json.loads(request.body)
        GatewayHandle(received_json_data)
        return ResponseJson('ok')
    else:
        ResponseBad('error')
Beispiel #4
0
def savePoi2(request):
    if request.method == 'POST':
        received_json_data = json.loads(request.body)
        PoiHandle2(received_json_data)
        return ResponseJson('ok')
    else:
        return ResponseBad('error')
Beispiel #5
0
def globalCount(request):
    if request.method == 'POST':
        received_json_data = json.loads(request.body)
        globalCountHandle(received_json_data)
        return ResponseJson('ok')
    else:
        return ResponseBad('error')
Beispiel #6
0
def getbounds(request):
    if request.method == "GET":
        bounds = Bounds.objects.all().values('id', 'lng1', 'lat1', 'lng2', 'lat2', 'lng3', 'lat3', 'lng4', 'lat4')
        rsp = []
        for cur in bounds:
            cur['p1'] = {}
            cur['p1']['lng'] = float(cur['lng1'])
            cur['p1']['lat'] = float(cur['lat1'])
            cur.pop('lng1')
            cur.pop('lat1')
            cur['p2'] = {}
            cur['p2']['lng'] = float(cur['lng2'])
            cur['p2']['lat'] = float(cur['lat2'])
            cur.pop('lng2')
            cur.pop('lat2')
            cur['p3'] = {}
            cur['p3']['lng'] = float(cur['lng3'])
            cur['p3']['lat'] = float(cur['lat3'])
            cur.pop('lng3')
            cur.pop('lat3')
            cur['p4'] = {}
            cur['p4']['lng'] = float(cur['lng4'])
            cur['p4']['lat'] = float(cur['lat4'])
            cur.pop('lng4')
            cur.pop('lat4')
            rsp.append(cur)
        return ResponseJson(rsp)
    else:
        return ResponseBad("error")
Beispiel #7
0
def getRestPage(request):
    if request.method == "GET":
        SendInfo = []
        restpageinfo = CountCheck.objects.all().values("bound", "poitype", "count")
        for cur in restpageinfo:
            if cur['count'] == 0:
                continue
            cur["count"] = math.ceil(cur["count"] / 50)
            if cur["count"] == 1:
                maxpage = [1]
            else:
                maxpage = list(range(1, cur["count"] + 1))
            maxpage = set(maxpage)
            # 拿出curpage,是一个list
            curpage = BoundsPoi.objects.filter(bound_id=cur["bound"], poitype_id=cur["poitype"]).values("currentpage")
            if len(curpage) == 0:
                currentpage = set([])
            else:
                currentpage = []
                # 根据count和curpage的列表生成剩余的页码的列表
                for each in curpage:
                    currentpage.append(each["currentpage"])
                currentpage = set(currentpage)
            restpage = list(maxpage - currentpage)
            # 将bound,poitype和每一个restpage组合装入一个list中
            for i in restpage:
                restpagesend = []
                restpagesend.append(cur["bound"])
                restpagesend.append(cur["poitype"])
                restpagesend.append(i)
                restpagesend.append(cur["count"])
                SendInfo.append(restpagesend)
        return ResponseJson(SendInfo)
    else:
        return ResponseBad("error")
def lostStation(request):
    if request.method == 'GET':
        rsp = []
        lost_station = Station.objects.all().filter(state=0).values("id", "name")
        for cur in lost_station:
            rsp.append(cur)
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
def allStation(request):
    if request.method == 'GET':
        rsp = []
        all_station = Station.objects.values("id", "name")
        for cur in all_station:
            rsp.append(cur)
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
Beispiel #10
0
def stationPOITag(request):
    if request.method == 'GET':
        rsp = []
        Tagdata = Tag.objects.values('id', 'name')
        for cur in Tagdata:
            rsp.append(cur)
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
Beispiel #11
0
def stationName(request):
    if request.method == 'GET':
        rsp=[]
        stationname = Stationname.objects.values('id', 'name')
        for cur in stationname:
            rsp.append(cur['name'])
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
Beispiel #12
0
def AJK(request):
    if request.method == 'GET':
        rsp = []
        AJKdata = AnjukeData.objects.filter(origin_name='0').values('id', 'name')
        for cur in AJKdata:
            rsp.append([cur['id'], cur['name']])
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
Beispiel #13
0
def getroute(request):
    if request.method == 'GET':
        rsp = []
        all_route = RidingData.objects.values('id', 'orilng', 'orilat', 'detlng', 'detlat')
        for cur in all_route:
            rsp.append([cur['id'], cur['orilng'], cur['orilat'], cur['detlng'], cur['detlat']])
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
Beispiel #14
0
def pageNum(request):
    if request.method == 'GET':
        rsp = []
        staid = request.GET['station_id']
        tagid = request.GET['tag_id']
        try:
            page_data = DataCheck.objects.get(station_id=staid, tag_id=tagid)
        except:
            page_data = DataCheck.objects.get(id=476)
        page_dict = model_to_dict(page_data)
        return ResponseJson(page_dict)
    else:
        return ResponseBad('error')
Beispiel #15
0
def stationDetail(request):
    if request.method == 'GET':
        rsp = []
        station_info = Station.objects.filter(state=0).values('id', 'name', 'lng', 'lat')
        for cur in station_info:
            cur['point'] = {}
            cur['point']['lng'] = float(cur['lng'])
            cur['point']['lat'] = float(cur['lat'])
            cur.pop('lng')
            cur.pop('lat')
            rsp.append(cur)
        return ResponseJson(rsp)
    else:
        return ResponseBad('error')
Beispiel #16
0
def upload(request):
    if request.method == 'POST':
        received_json_data = json.loads(request.body)
        return ResponseJson('ok')
    else:
        return ResponseBad('error')