Esempio n. 1
0
def chuli_serial_file(png, mapserver_ip, uu, wroot):
    print(png)
    rrxlsx_file = os.path.join(wroot, png)

    map_mata = helper.xlsx2dict(rrxlsx_file)

    data_apth = ''
    for x in map_mata:
        for key in x:

            if key == 'data':
                data_apth = x[key]
    if '[' in data_apth:
        print('-' * 40)

        print(data_apth)
        qq = data_apth.index('[')
        hh = data_apth.index(']')
        sig_q = data_apth[:qq]
        sig_h = data_apth[hh + 1:]
        print(sig_q)
        print(sig_h)
        for wwfile in os.listdir(wroot):
            if wwfile.startswith(sig_q) and wwfile.endswith(sig_h):
                print(wwfile)

                the_sig = wwfile[qq:hh - 1]
                print(the_sig)
                shp = os.path.join(wroot, wwfile)
                npng = png.replace('[sig]', the_sig)
                print(npng)
                gen_imagery4d(npng, mapserver_ip, uu, wroot)
Esempio n. 2
0
def get_lyr_mapfile(map_dir, wfile, wroot):
    '''
    得到图层的 Mapfile
    '''

    # ToDo: 参数 wroot 是否有必要?

    rrxlsx_file = os.path.join(wroot, wfile)
    print(rrxlsx_file)

    t_mts = helper.get_mts(rrxlsx_file)

    map_mata = helper.xlsx2dict(rrxlsx_file)

    data_apth = ''
    for x in map_mata:
        for key in x:
            if key == 'data':
                data_apth = x[key]
    lyrs_file = []
    if '[' in data_apth:
        # print('-' * 40)

        print(data_apth)
        qq = data_apth.index('[')
        hh = data_apth.index(']')
        sig_q = data_apth[:qq]
        sig_h = data_apth[hh + 1:]
        # print(sig_q)
        # print(sig_h)
        for wwfile in os.listdir(wroot):
            if wwfile.startswith(sig_q) and wwfile.endswith(sig_h):
                print(wwfile)

                the_sig = wwfile[qq:hh - 1]
                shp = os.path.join(wroot, wwfile)

                lyr_file = generate_lyr_mapfile(map_dir,
                                                map_mata,
                                                shp,
                                                wfile,
                                                t_mts,
                                                sig=the_sig)
                lyrs_file.append(lyr_file)

    else:
        shp = os.path.join(wroot, data_apth)
        lyr_file = generate_lyr_mapfile(map_dir, map_mata, shp, wfile, t_mts)
        lyrs_file.append(lyr_file)

    # pprint(new_layer)

    # print(yaml.dump(new_layer))
    return lyrs_file
Esempio n. 3
0
def parse_serial_filename(rrxlsx_file):
    '''
    对于批量的使用变量的,获取路径,以及位置。
    '''
    map_mata = helper.xlsx2dict(rrxlsx_file)
    data_apth = ''
    for mata in map_mata:
        for key in mata:
            if key == 'data':
                data_apth = mata[key]

    q_place = data_apth.index('[')
    h_place = data_apth.index(']')
    return data_apth, h_place, q_place
Esempio n. 4
0
def method_name(rrxlsx_file):
    '''
    对于批量的使用变量的,获取路径,以及位置。
    '''
    map_mata = helper.xlsx2dict(rrxlsx_file)
    data_apth = ''
    for x in map_mata:
        for key in x:
            if key == 'data':
                data_apth = x[key]
    print('-' * 40)
    print(data_apth)
    qq = data_apth.index('[')
    hh = data_apth.index(']')
    return data_apth, hh, qq
Esempio n. 5
0
def get_lyrs_name(category_dir, xlsxfile_name, wroot):
    '''
    在分类的文件夹下,得到所有图层的名称。
    '''
    rrxlsx_file = os.path.join(wroot, xlsxfile_name)
    print(rrxlsx_file)

    map_mata = helper.xlsx2dict(rrxlsx_file)

    data_path = ''
    for mata in map_mata:
        for key in mata:
            if key == 'data':
                data_path = mata[key]
    lyrs_file = []
    if '[' in data_path:
        # print('-' * 40)

        print(data_path)
        q_place = data_path.index('[')
        h_place = data_path.index(']')
        sig_q = data_path[:q_place]
        sig_h = data_path[h_place + 1:]

        for wwfile in os.listdir(wroot):
            if wwfile.startswith(sig_q) and wwfile.endswith(sig_h):
                print(wwfile)

                the_sig = wwfile[q_place:h_place - 1]
                shp = os.path.join(wroot, wwfile)

                lyr_file = generate_lyr_mapfile(category_dir,
                                                map_mata,
                                                shp,
                                                xlsxfile_name,
                                                sig=the_sig)
                lyrs_file.append(lyr_file)

    else:
        shp = os.path.join(wroot, data_path)

        lyr_file = generate_lyr_mapfile(category_dir, map_mata, shp,
                                        xlsxfile_name)
        lyrs_file.append(lyr_file)

    return lyrs_file
Esempio n. 6
0
def dispose_serial_file(file_name, mapserver_ip, mapproxy_mold, wroot):
    """
    处理系列文件的方法
    """

    data_apth = ''
    for meta in helper.xlsx2dict(os.path.join(wroot, file_name)):
        for key in meta:
            if key == 'data':
                data_apth = meta[key]

    if '[' in data_apth:

        meta_q = data_apth.index('[')
        meta_h = data_apth.index(']')
        sig_q = data_apth[:meta_q]
        sig_h = data_apth[meta_h + 1:]

        for wwfile in os.listdir(wroot):
            if wwfile.startswith(sig_q) and wwfile.endswith(sig_h):
                the_sig = wwfile[meta_q:meta_h - 1]

                gdata = file_name.replace('[sig]', the_sig)
                gen_imagery4d(gdata, mapserver_ip, mapproxy_mold, wroot)