예제 #1
0
파일: views.py 프로젝트: iMuYi/si
def lablink(startTime, endTime, idValue, signal):
        data_tmp = []
        db = Mongolink()
        collection = db.Msignal
        user = collection.find({"U_ID": idValue, 'GetTime': {'$gt':startTime, '$lt': endTime}})
        #print 'user'
        #print user
        finalmap = mapdis.getFinalMap()
        for each in user:
            lng = each['Longitude']
            #print lng
            lat = each['Latitude']
            #print lat
            if signal == "Tx":
                RSRP = each['TX']
            elif signal == "Rx":
                RSRP = each['RX']
            else:
                RSRP = each['SS_3G']
            #print RSRP
            GetTime = each['GetTime']
            #print GetTime
            for every in finalmap:
                if every[2] == 'S':
                    if (lat <= every[0] + 0.00011) and (lat >= every[0] - 0.00022) and (lng >= every[1]) and (lng <= every[1]+0.00015):
                        tmp = {
                                'Longitude': every[1],
                                'Latitude': every[0],
                                'RSRP': RSRP,
                                'time': GetTime,
                              }
                        data_tmp.append(tmp)
                        break
                elif every[2] == 'R':
                    if (lat <= every[0]) and (lat >= every[0] - 0.00011) and (lng >= every[1] - 0.00015) and (lng <= every[1]+0.0003):
                        tmp = {
                                'Longitude': every[1],
                                'Latitude': every[0],
                                'RSRP': RSRP,
                                'time': GetTime,
                              }
                        data_tmp.append(tmp)
                        break
                elif every[2] =='X':
                    if (lat <= every[0]) and (lat >= every[0] - 0.00011) and (lng >= every[1]) and (lng <= every[1]+0.00015):
                        tmp = {
                                'Longitude': every[1],
                                'Latitude': every[0],
                                'RSRP': RSRP,
                                'time': GetTime,
                              }
                        data_tmp.append(tmp)
        return data_tmp
예제 #2
0
파일: views.py 프로젝트: leafxm/si
def eachMap(operator, signal, zoom, lng1, lat1, lng2, lat2, startTime, endTime,
            flag):
    d_tmp = []
    db = Mongolink()
    collection = db.Msignal
    #print 'Mongo Ready'
    siganlInfo = collection.find({
        'NetworkType': {
            '$in': operator
        },
        'Longitude': {
            '$gt': lng1,
            '$lt': lng2
        },
        'Latitude': {
            '$gt': lat2,
            '$lt': lat1
        },
        'GetTime': {
            '$gt': startTime,
            '$lt': endTime
        }
    })
    usefulInfo = []
    ChinaMobile = ['GPRS', 'EDGE', 'HSDPA', 'LTE']
    Unicom = ['EHRPD', 'HSPA', 'HSPAP', 'HSUPA', 'IDEN', 'UMTS']
    Telcom = ['CDMA', '1xRTT', 'EVDO_0', 'EVDO_A', 'EVDO_B']

    # pre-coding
    for each in siganlInfo:
        if each['NetworkType'] in ChinaMobile:
            tmp = {
                'IMEI': each['U_ID'],
                'Operator': 'ChinaMobile',
                'RSRP': each['SS_3G'],
                'TX': each['TX'],
                'RX': each['RX'],
                'GetTime': each['GetTime'],
                'Longitude': each['Longitude'],
                'Latitude': each['Latitude'],
            }
        elif each['NetworkType'] in Unicom:
            tmp = {
                'IMEI': each['U_ID'],
                'Operator': 'Unicom',
                'RSRP': each['SS_3G'],
                'TX': each['TX'],
                'RX': each['RX'],
                'GetTime': each['GetTime'],
                'Longitude': each['Longitude'],
                'Latitude': each['Latitude'],
            }
        else:
            tmp = {
                'IMEI': each['U_ID'],
                'Operator': 'Telcom',
                'RSRP': each['SS_3G'],
                'TX': each['TX'],
                'RX': each['RX'],
                'GetTime': each['GetTime'],
                'Longitude': each['Longitude'],
                'Latitude': each['Latitude'],
            }
        usefulInfo.append(tmp)
    #print len(usefulInfo)
    timeArray = timedis(startTime, endTime, 300)
    usefulInfo_tmp = []
    for each in timeArray:
        for every in usefulInfo:
            if (every['GetTime'] >= each[0]) and (every['GetTime'] <= each[1]):
                usefulInfo_tmp.append(every)
                usefulInfo.remove(every)
        #get map infomation
        finalmap = mapdis.getFinalMap()
        meanRSRP = [0, 0, 0]
        meanTx = [0, 0, 0]
        meanRx = [0, 0, 0]
        userNum = [0, 0, 0]
        for each in usefulInfo_tmp:
            tmpFlag = 0
            # calculate the means
            if each['Operator'] == 'ChinaMobile':
                meanRSRP[0] += each['RSRP']
                meanTx[0] += each['TX']
                meanRx[0] += each['RX']
                userNum[0] += 1
            elif each['Operator'] in Unicom:
                meanRSRP[1] += each['RSRP']
                meanTx[1] += each['TX']
                meanRx[1] += each['RX']
                userNum[1] += 1
            else:
                meanRSRP[2] += each['RSRP']
                meanTx[2] += each['TX']
                meanRx[2] += each['RX']
                userNum[2] += 1
            #alocate the user into block
            for every in finalmap:
                if every[2] == 'S':
                    if (each['Latitude'] <= every[0] + 0.00011) and (
                            each['Latitude'] >= every[0] - 0.00022) and (
                                each['Longitude'] >= every[1]) and (
                                    each['Longitude'] <= every[1] + 0.00015):
                        every[4] = every[4] + 1
                        every[5] = every[5] + each['RSRP']
                        tmpFlag = 1
                elif every[2] == 'R':
                    if (each['Latitude'] <= every[0]) and (
                            each['Latitude'] >= every[0] - 0.00011) and (
                                each['Longitude'] >= every[1] - 0.00015) and (
                                    each['Longitude'] <= every[1] + 0.0003):
                        every[4] = every[4] + 1
                        every[5] = every[5] + each['RSRP']
                        tmpFlag = 1
                elif every[2] == 'X':
                    if (each['Latitude'] <= every[0]) and (
                            each['Latitude'] >= every[0] - 0.00011) and (
                                each['Longitude'] >= every[1]) and (
                                    each['Longitude'] <= every[1] + 0.00015):
                        every[4] = every[4] + 1
                        every[5] = every[5] + each['RSRP']
                        tmpFlag = 1
                if tmpFlag == 1:
                    break
        ##print finalmap

        #calculate the mean of each block
        data_tmp = []
        for each in finalmap:
            if each[4] != 0:
                #print 'Not zero'
                tmp = {
                    'Latitude': each[0],
                    'Longitude': each[1],
                    'RSRP': each[5] / each[4],
                }
                #print each[5]/each[4]
            else:
                tmp = {
                    'Latitude': each[0],
                    'Longitude': each[1],
                    'RSRP': -100,
                }
            data_tmp.append(tmp)
        ##print data_tmp

        #calculate the mean of each operator
        for i in range(0, 3):
            if userNum[i] != 0:
                meanRSRP[i] = meanRSRP[i] / userNum[i]
                meanRSRP[i] = float('%0.5f' % meanRSRP[i])
                meanRx[i] = meanRx[i] / userNum[i]
                meanRx[i] = float('%0.5f' % meanRx[i])
                meanTx[i] = meanTx[i] / userNum[i]
                meanTx[i] = float('%0.5f' % meanTx[i])
        dd_tmp = {
            'data': data_tmp,
            'meanRSRP': meanRSRP,
            'meanTx': meanTx,
            'meanRx': meanRx,
        }
        d_tmp.append(dd_tmp)
    finaldata = {'data': d_tmp}
    return finaldata
예제 #3
0
파일: views.py 프로젝트: leafxm/si
def lablink(startTime, endTime, idValue, signal):
    data_tmp = []
    db = Mongolink()
    collection = db.Msignal
    user = collection.find({
        "U_ID": idValue,
        'GetTime': {
            '$gt': startTime,
            '$lt': endTime
        }
    })
    #print 'user'
    #print user
    finalmap = mapdis.getFinalMap()
    for each in user:
        lng = each['Longitude']
        #print lng
        lat = each['Latitude']
        #print lat
        if signal == "Tx":
            RSRP = each['TX']
        elif signal == "Rx":
            RSRP = each['RX']
        else:
            RSRP = each['SS_3G']
        #print RSRP
        GetTime = each['GetTime']
        #print GetTime
        for every in finalmap:
            if every[2] == 'S':
                if (lat <= every[0] + 0.00011) and (
                        lat >= every[0] - 0.00022) and (lng >= every[1]) and (
                            lng <= every[1] + 0.00015):
                    tmp = {
                        'Longitude': every[1],
                        'Latitude': every[0],
                        'RSRP': RSRP,
                        'time': GetTime,
                    }
                    data_tmp.append(tmp)
                    break
            elif every[2] == 'R':
                if (lat <= every[0]) and (lat >= every[0] - 0.00011) and (
                        lng >= every[1] - 0.00015) and (lng <=
                                                        every[1] + 0.0003):
                    tmp = {
                        'Longitude': every[1],
                        'Latitude': every[0],
                        'RSRP': RSRP,
                        'time': GetTime,
                    }
                    data_tmp.append(tmp)
                    break
            elif every[2] == 'X':
                if (lat <= every[0]) and (lat >= every[0] - 0.00011) and (
                        lng >= every[1]) and (lng <= every[1] + 0.00015):
                    tmp = {
                        'Longitude': every[1],
                        'Latitude': every[0],
                        'RSRP': RSRP,
                        'time': GetTime,
                    }
                    data_tmp.append(tmp)
    return data_tmp
예제 #4
0
파일: views.py 프로젝트: iMuYi/si
def eachMap(operator, signal, zoom, lng1, lat1, lng2, lat2, startTime, endTime, flag):
    d_tmp = []
    db = Mongolink()
    collection = db.Msignal
    #print 'Mongo Ready'
    siganlInfo = collection.find({'NetworkType':{'$in':operator}, 'Longitude': {'$gt': lng1, '$lt': lng2}, 'Latitude': {'$gt': lat2, '$lt': lat1}, 'GetTime': {'$gt': startTime, '$lt': endTime}})
    usefulInfo = []
    ChinaMobile = ['GPRS','EDGE','HSDPA','LTE']
    Unicom = ['EHRPD','HSPA','HSPAP','HSUPA','IDEN','UMTS']
    Telcom = ['CDMA','1xRTT','EVDO_0','EVDO_A','EVDO_B']

    # pre-coding
    for each in siganlInfo:
        if each['NetworkType'] in ChinaMobile:
            tmp = {'IMEI':each['U_ID'],
                   'Operator':'ChinaMobile',
                   'RSRP':each['SS_3G'],
                   'TX':each['TX'],
                   'RX':each['RX'],
                   'GetTime':each['GetTime'],
                   'Longitude':each['Longitude'],
                   'Latitude':each['Latitude'],
               }
        elif each['NetworkType'] in Unicom:
            tmp = {'IMEI':each['U_ID'],
                   'Operator':'Unicom',
                   'RSRP':each['SS_3G'],
                   'TX':each['TX'],
                   'RX':each['RX'],
                   'GetTime':each['GetTime'],
                   'Longitude':each['Longitude'],
                   'Latitude':each['Latitude'],
               }
        else:
            tmp = {'IMEI':each['U_ID'],
                   'Operator':'Telcom',
                   'RSRP':each['SS_3G'],
                   'TX':each['TX'],
                   'RX':each['RX'],
                   'GetTime':each['GetTime'],
                   'Longitude':each['Longitude'],
                   'Latitude':each['Latitude'],
               }
        usefulInfo.append(tmp)
    #print len(usefulInfo)
    timeArray = timedis(startTime,endTime,300)
    usefulInfo_tmp = []
    for each in timeArray:
        for every in usefulInfo:
            if (every['GetTime']>=each[0]) and (every['GetTime']<=each[1]):
                usefulInfo_tmp.append(every)
                usefulInfo.remove(every)
        #get map infomation
        finalmap = mapdis.getFinalMap()
        meanRSRP =[0,0,0]
        meanTx = [0,0,0]
        meanRx = [0,0,0]
        userNum = [0,0,0]
        for each in usefulInfo_tmp:
            tmpFlag = 0
            # calculate the means
            if each['Operator']=='ChinaMobile':
                meanRSRP[0] += each['RSRP']
                meanTx[0] += each['TX']
                meanRx[0] += each['RX']
                userNum[0] += 1
            elif each['Operator'] in Unicom:
                meanRSRP[1] += each['RSRP']
                meanTx[1] += each['TX']
                meanRx[1] += each['RX']
                userNum[1] +=1
            else:
                meanRSRP[2] += each['RSRP']
                meanTx[2] += each['TX']
                meanRx[2] += each['RX']
                userNum[2] +=1
            #alocate the user into block
            for every in finalmap:
                if every[2] == 'S':
                    if (each['Latitude'] <= every[0] + 0.00011) and (each['Latitude'] >= every[0] - 0.00022) and (each['Longitude'] >= every[1]) and (each['Longitude'] <= every[1]+0.00015):
                        every[4] = every[4] + 1
                        every[5] = every[5] + each['RSRP']
                        tmpFlag = 1
                elif every[2] == 'R':
                    if (each['Latitude'] <= every[0]) and (each['Latitude'] >= every[0] - 0.00011) and (each['Longitude'] >= every[1] - 0.00015) and (each['Longitude'] <= every[1]+0.0003):
                        every[4] = every[4] + 1
                        every[5] = every[5] + each['RSRP']
                        tmpFlag = 1
                elif every[2] =='X':
                    if (each['Latitude'] <= every[0]) and (each['Latitude'] >= every[0] - 0.00011) and (each['Longitude'] >= every[1]) and (each['Longitude'] <= every[1]+0.00015):
                        every[4] = every[4] + 1
                        every[5] = every[5] + each['RSRP']
                        tmpFlag = 1
                if tmpFlag == 1:
                    break
        ##print finalmap

        #calculate the mean of each block
        data_tmp = []
        for each in finalmap:
            if each[4] != 0:
                #print 'Not zero'
                tmp = {'Latitude':each[0],
                       'Longitude':each[1],
                       'RSRP':each[5]/each[4],
                       }
                #print each[5]/each[4]
            else:
                tmp = {'Latitude':each[0],
                       'Longitude':each[1],
                       'RSRP':-100,
                       }
            data_tmp.append(tmp)
        ##print data_tmp

        #calculate the mean of each operator
        for i in range(0,3):
            if userNum[i] != 0:
                meanRSRP[i] = meanRSRP[i]/userNum[i]
                meanRSRP[i] = float('%0.5f'%meanRSRP[i])
                meanRx[i] = meanRx[i]/userNum[i]
                meanRx[i] = float('%0.5f'%meanRx[i])
                meanTx[i] = meanTx[i]/userNum[i]
                meanTx[i] = float('%0.5f'%meanTx[i])
        dd_tmp = {'data': data_tmp,
                 'meanRSRP': meanRSRP,
                 'meanTx': meanTx,
                 'meanRx': meanRx,
                 }
        d_tmp.append(dd_tmp)
    finaldata = {'data':d_tmp}
    return finaldata