Пример #1
0
def flatten():
    def get_vol_name(towerid, lines, codes):
        ret = ''
        for line in lines:
            if towerid in line['properties']['nodes']:
                c = line['properties']['voltage']
                if codes['voltage_level'].has_key(c):
                    ret = codes['voltage_level'][c]
                    break
        return ret    
        
    db_util.init_global()
    towers = db_util.mongo_find('kmgd', 'features', conditions={"properties.webgis_type":"point_tower", "geometry2d.type":"Point"})
    lines = db_util.mongo_find('kmgd', 'network', conditions={"properties.webgis_type":"polyline_line"})
    codes = db_util.mongo_find_one('kmgd', 'codes', {})
    ll = []
    #print(len(l))
    for i in towers:
        o = {}
        tower_id = i['_id']
        
        o['_id'] = ObjectId(tower_id)
        o['lng'] = i['geometry']['coordinates'][0]
        o['lat'] = i['geometry']['coordinates'][1]
        o['name'] = i['properties']['name']
        o['voltage'] = get_vol_name(tower_id, lines, codes)
        ll.append(unicode(o).replace(' u', ''))
    s = '\n'.join(ll)
    with open(JSONFILE1, 'w') as f:
        f.write(s)
Пример #2
0
def flatten2():
    db_util.init_global()
    l = db_util.mongo_find('kmgd', 'network', conditions={"properties.webgis_type":"polyline_line"})
    
    ll = []
    print(len(l))
    for i in l:
        o = {}
        o['nodes'] = i['properties']['nodes']
        lll = [ObjectId(ii) for ii in o['nodes']]
        o['nodes'] = lll
        o['name'] = i['properties']['name']
        ll.append(unicode(o).replace(' u', ''))
    s = '\n'.join(ll)
    with open(JSONFILE2, 'w') as f:
        f.write(s)
Пример #3
0
            ftu_count = 10
        for i in range(1, ftu_count+1):
            if _.find_index(alist, {'switch_alias':i}) > -1:
                ws.write(0, i - 1, 1)
            else:
                ws.write(0, i - 1, 0)
        wb.save(filepath)

    for alg in ['ants', 'bayes']:
        for k in ['jfyk', 'pzz']:
            ftu_path = gConfig['webgis']['distribute_network']['mcr_path']['puer'][alg][k]['ftu_path']
            # ftu_path += '_test.xls'
            create_xls(ftu_path, k, data)



def build_data_ftu_xls(start_data, end_data):
    XLS_FILE = ur'data_ftu_report.xlsx'
    ret = get_ftu_fault_record(XLS_FILE, u'Sheet1', start_data, end_data)
    XLS_FILE = ur'data_tower_ftu_info.xls'
    ret = get_switch_alias_tower_id(XLS_FILE, u'Sheet3', ret)
    print(ret)
    print(len(ret))
    build_data_ftu(ret)


if __name__ == "__main__":
    init_global()
    # test14()