Exemple #1
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
Exemple #2
0
# -*- coding: utf-8 -*-
'''
1. Parse XLSX file, and generate Mapfile for layers.
'''
import os
import mappyfile

import gislite.const
import gislite.helper as helper
from config import GIS_BASE

MTS = helper.get_mts()


def is_lyr_def(xlsfile):
    '''
    if the xlsx file is used to define layer.
    NOT for Multiple layers, or group layers.
    '''
    if xlsfile.endswith('.xlsx'):
        if '_mul' in xlsfile or '_grp' in xlsfile:
            return False
        else:
            return True
    else:
        return False


def do_for_map_category(category_dir):
    '''
    按分类进行处理,生成总的 Mapfile.