def __init__(self, leaf): self.file = Projection.leaf_to_string(leaf, "File") self.filetype = str.upper(Projection.leaf_to_string(leaf, "Type", 'shp')) self.draw = Projection.leaf_to_bool(leaf, "Draw", False) # self.path = self.readPolygon(self.file) if self.filetype != 'SHP' else None # if self.draw: self.path = ClipBorder.readPath(self.file, 0) if self.filetype != 'SHP' else None self.polygon = str.upper(Projection.leaf_to_string(leaf, "Polygon", 'on')) # self.draw = Projection.leaf_to_bool(leaf, "Draw", False) self.linewidth = Projection.leaf_to_float(leaf, "LineWidth", 1) self.linecolor = Projection.leaf_to_string(leaf, "LineColor", 'k')
def __init__(self, root): leaf = root.find("File") if leaf is None: return self.type = Projection.leaf_to_string(leaf, 'Type', 'M4') self.filename = Projection.leaf_to_string(leaf, 'FileName', 'M4') if self.type == 'M4': self.micapsdata = Micaps4Data(self.filename) elif self.type == 'M3': self.micapsdata = Micaps3Data(self.filename) elif self.type == 'M11': self.micapsdata = Micaps11Data(self.filename) else: return
def __init__(self, root): leaf = root.find("Stations") self.file = Projection.leaf_to_string(leaf, 'File') self.visible = Projection.leaf_to_bool(leaf, 'Visible', False) self.markstyle = Projection.leaf_to_list(leaf, 'MarkStyle', ['o', 'full']) self.color = Projection.leaf_to_string(leaf, 'Color', 'k') self.edgecolors = Projection.leaf_to_string(leaf, 'EdgeColors', 'k') self.alpha = Projection.leaf_to_float(leaf, 'Alpha', 1.) self.radius = Projection.leaf_to_float(leaf, 'Radius', 5) self.font = Projection.leaf_to_list(leaf, 'Font', [18, 'myyh.ttc', 'bold', 'k']) self.detax = Projection.leaf_to_float(leaf, 'Detax', 0.03) self.micapsdata = Micaps17Data(self.file)
def __init__(self, leaf): self.file = Projection.leaf_to_string(leaf, "File") self.filetype = str.upper( Projection.leaf_to_string(leaf, "Type", 'shp')) self.draw = Projection.leaf_to_bool(leaf, "Draw", False) # self.path = self.readPolygon(self.file) if self.filetype != 'SHP' else None # if self.draw: self.path = ClipBorder.readPath(self.file, 0) if self.filetype != 'SHP' else None self.polygon = str.upper( Projection.leaf_to_string(leaf, "Polygon", 'on')) # self.draw = Projection.leaf_to_bool(leaf, "Draw", False) self.linewidth = Projection.leaf_to_float(leaf, "LineWidth", 1) self.linecolor = Projection.leaf_to_string(leaf, "LineColor", 'k')
def __init__(self, leaf): start_pos = 0 filehead = Projection.leaf_to_string(leaf, "File") filetype = Projection.leaf_to_string(leaf, "Type", 'shp') code = Projection.leaf_to_list(leaf, "Code", [360000]) drawswitch = str.upper(Projection.leaf_to_string(leaf, "Draw", 'off')) self.path = self.getPath(filehead=filehead, code=code, filetype=filetype, start_pos=start_pos) self.draw = str.upper(Projection.leaf_to_string(leaf, "Draw", 'off')) self.using = Projection.leaf_to_bool(leaf, "Using", True) self.linewidth = Projection.leaf_to_float(leaf, "LineWidth", 1) self.linecolor = Projection.leaf_to_string( leaf, "LineColor", 'k') if drawswitch == 'ON' else 'none'
def __init__(self, root): p = root.find("Contour") # 是否用彩色圆点标注格点或站点 self.scatter = Projection.leaf_to_bool(p, 'Scatter', False) # 圆点的透明度 self.alpha = Projection.leaf_to_float(p, 'Alpha', 1) # 圆点半径 default is 10 self.radius = Projection.leaf_to_float(p, 'Radius', 10) # 第三类数据等值线步长 self.step = Projection.leaf_to_float(p, 'Step', 2.) # 经纬方向上的插值格点数 self.grid = Projection.leaf_to_list(p, "Grid", [195, 216]) if len(self.grid) != 2: self.grid = [195, 216] else: self.grid = [parseInt(str(g)) for g in self.grid] # 等值线参数 contourleaf = p.find("Contour") if contourleaf is None: self.contour = {'visible': False, 'linewidth': 1.0, 'linecolor': 'k', 'colorline': False} else: self.contour = { 'visible': Projection.leaf_to_bool(contourleaf, "Visible", False, 'TRUE'), 'linewidth': Projection.leaf_to_float(contourleaf, 'LineWidth', 1.0), 'linecolor': Projection.leaf_to_string(contourleaf, 'LineColor', 'k'), 'colorline': Projection.leaf_to_bool(contourleaf, "ColorLine", False, 'TRUE') } # 是否显示色斑图 self.contourfvisible = Projection.leaf_to_bool(p, "ContourfVisible", False, 'TRUE') # 等值线标注参数 leaf = p.find("ContourLabel") if leaf is None: self.contourlabel = {'visible': False, 'fmt': '%1.0f', 'fontsize': 12, 'fontcolor': 'k', 'inlinespacing': 2} else: self.contourlabel = { 'visible': Projection.leaf_to_bool(leaf, "Visible", False, 'TRUE'), 'fmt': Projection.leaf_to_string(leaf, 'Fmt', '%1.0f'), 'fontsize': Projection.leaf_to_float(leaf, 'FontSize', 12), 'fontcolor': Projection.leaf_to_string(leaf, 'FontColor', 'k'), 'inlinespacing': Projection.leaf_to_float(leaf, 'InlineSpacing', 2) }
def __init__(self, root): p = root.find("Title") # 是否按Micaps数据的标题写产品描述 self.mtitleposition = Projection.leaf_to_list(p, "MTitlePosition", None) # 产品图片文字描述(可能多个) descs = p.find("Descs").getchildren() self.descs = [] for desc in descs: txt = Projection.leaf_to_string(desc, 'Text', u'测试数据') pos = Projection.leaf_to_list(desc, "Position", [113.2, 30.5]) fonts = desc.find("Font").text.strip().split(',') font = { 'family': 'monospace', 'weight': 'bold', 'fontsize': 12, 'color': 'k' } if len(fonts) == 4: font['fontsize'] = parseInt(fonts[0].strip()) font['family'] = fonts[1] font['weight'] = fonts[2] font['color'] = fonts[3] self.descs.append(HeadDesc(txt, pos, font))
def __init__(self, root): leaf = root.find("Stations") self.file = Projection.leaf_to_string(leaf, 'File') self.visible = Projection.leaf_to_bool(leaf, 'Visible', False) self.markstyle = Projection.leaf_to_list(leaf, 'MarkStyle', ['o', 'full']) self.color = Projection.leaf_to_string(leaf, 'Color', 'k') self.edgecolors = Projection.leaf_to_string(leaf, 'EdgeColors', 'k') self.alpha = Projection.leaf_to_float(leaf, 'Alpha', 1.) self.radius = Projection.leaf_to_float(leaf, 'Radius', 5) self.font = Projection.leaf_to_list(leaf, 'Font', [18, 'myyh.ttc', 'bold', 'k']) self.detax = Projection.leaf_to_float(leaf, 'Detax', 0.03) self.micapsdata = Micaps17Data(self.file)
def __init__(self, root, clipborders): p = root.find("Picture") # 生成的图片宽度 self.width = Projection.leaf_to_float(p, "PicWidth", 10) # 生成的图片高度 self.height = Projection.leaf_to_float(p, "PicHeight", 10) # dpi self.dpi = Projection.leaf_to_int(p, "Dpi", 72) # 高宽比 self.widthshrink = Projection.leaf_to_float(p, "WidthShrink", 1.0) # 绘图区外延 self.margin = Projection.leaf_to_list(p, "Margin", [0, 0, 0, 0]) # 绘图区内边距 self.pad = Projection.leaf_to_float(p, "Pad", 0.0) # 绘图区域 extents = p.find("Extents").text.strip() if extents is None or extents == '': if len(clipborders) < 1 or clipborders[0].path is None or ( not clipborders[0].using): self.extents = None else: jxextend = clipborders[0].path.get_extents() delta = self.margin xmax = jxextend.xmax + delta[2] xmin = jxextend.xmin - delta[0] ymax = jxextend.ymax + delta[1] ymin = jxextend.ymin - delta[3] self.extents = Bbox.from_extents(xmin, ymin, xmax, ymax) else: self.extents = Projection.leaf_to_list(p, "Extents", None) # 画布透明度 self.opacity = Projection.leaf_to_float(p, 'Opacity', 1) if self.opacity < 0 or self.opacity > 1: self.opacity = 1 # 生成的图片文件存放路径 self.picfile = Projection.leaf_to_string(p, 'PicFile', 'mytest.png') self.checkFilename() return
def __init__(self, root): leaf = root.find("UV") if leaf is None: return self.stream = Projection.leaf_to_bool(leaf, 'Stream', False) self.density = Projection.leaf_to_list(leaf, 'Density', [1, 1]) self.color = Projection.leaf_to_string(leaf, 'Color', 'k') self.onspeed = Projection.leaf_to_bool(leaf, 'OnSpeed', False) self.oncolor = Projection.leaf_to_bool(leaf, 'OnColor', False) self.linewidth = Projection.leaf_to_float(leaf, 'LineWidth', 1.) self.scale = Projection.leaf_to_int(leaf, 'Scale', 700) self.markscalelength = Projection.leaf_to_float(leaf, 'MarkScaleLength', 12.) self.barbs = Projection.leaf_to_bool(leaf, 'Barbs', False) self.length = Projection.leaf_to_int(leaf, 'Length', 1)
def __init__(self, root): leaf = root.find("UV") if leaf is None: return self.stream = Projection.leaf_to_bool(leaf, 'Stream', False) self.density = Projection.leaf_to_list(leaf, 'Density', [1, 1]) self.barbsgrid = Projection.leaf_to_list(leaf, 'BarbsGrid', [31, 31]) self.color = Projection.leaf_to_string(leaf, 'Color', 'k') self.onspeed = Projection.leaf_to_bool(leaf, 'OnSpeed', False) self.wholecilp = Projection.leaf_to_bool(leaf, 'WholeClip', False) self.oncolor = Projection.leaf_to_bool(leaf, 'OnColor', False) self.linewidth = Projection.leaf_to_float(leaf, 'LineWidth', 1.) self.scale = Projection.leaf_to_int(leaf, 'Scale', 700) self.markscalelength = Projection.leaf_to_float(leaf, 'MarkScaleLength', 12.) self.barbs = Projection.leaf_to_bool(leaf, 'Barbs', False) self.length = Projection.leaf_to_int(leaf, 'Length', 1)
def __init__(self, root): p = root.find("Title") # 是否按Micaps数据的标题写产品描述 self.mtitleposition = Projection.leaf_to_list(p, "MTitlePosition", None) # 产品图片文字描述(可能多个) descs = p.find("Descs").getchildren() self.descs = [] for desc in descs: txt = Projection.leaf_to_string(desc, 'Text', u'测试数据') pos = Projection.leaf_to_list(desc, "Position", [113.2, 30.5]) fonts = desc.find("Font").text.strip().split(',') font = {'family': 'monospace', 'weight': 'bold', 'fontsize': 12, 'color': 'k'} if len(fonts) == 4: font['fontsize'] = parseInt(fonts[0].strip()) font['family'] = fonts[1] font['weight'] = fonts[2] font['color'] = fonts[3] self.descs.append(HeadDesc(txt, pos, font))
def __init__(self, root): p = root.find("Legend") if p is None: print(u'没有图例节点') return # 图例图片文件路径,图例叠加到产品图上的位置,为空表示自行生成图例 legend_pic = p.find("LegendPic").text self.islegendpic = False self.legendpic = '' self.legendpos = [0, 0] self.legendopacity = 1 if not (legend_pic is None or legend_pic.strip() == ''): self.islegendpic = True legend_pics = legend_pic.strip().split(',') if 1 == len(legend_pics): self.legendpic = legend_pics[0].strip() elif 4 == len(legend_pics): self.legendpic = legend_pics[0].strip() self.legendpos = [float(legend_pics[1].strip()), float(legend_pics[2].strip())] self.legendopacity = float(legend_pics[3].strip()) else: self.legendpic = legend_pics[0].strip() # 图例的延展类型:neither,min,max default is neither self.extend = Projection.leaf_to_string(p, 'Extend', 'neither') # 是否取MICAPS数据本身的图例值 self.micapslegendvalue = Projection.leaf_to_bool(p, "MicapsLegendValue", True, 'TRUE') # When micapslegendvalue is true, the setting is working. # if pin the legend values, [begin value, stop value, step] is working.default is None # else use the data self legend values self.pinlegendvalue = Projection.leaf_to_list(p, "PinLegendValue", None) self.valid(self.pinlegendvalue) # NCL colorbar 的别名 self.micapslegendcolor = Projection.leaf_to_string(p, 'MicapsLegendColor', 'ncl_default') # 图例填充样式数组,一般和自定义的legend结合使用,如不够LegendValue数组的长度,则会用最后一个样式自动补齐 self.hatches = Projection.leaf_to_list(p, "Hatches", ['']) self.validhatches(self.hatches) # 图例等级值 self.legendvalue = Projection.leaf_to_list(p, "LegendValue", None) # 实际显示在图例上的值 self.legendvaluealias = Projection.leaf_to_list(p, "LegendValueAlias", None) # 图例颜色值 self.legendcolor = Projection.leaf_to_list(p, "LegendColor", None) # 图例抽稀间隔 self.thinning = Projection.leaf_to_int(p, "Thinning", 1) # 图例字体 self.font = Projection.leaf_to_dict(p, "Font", None) # 图例标题 self.title = Projection.leaf_to_string(p, 'Title', '') # 图例标题字体 self.titlefont = Projection.leaf_to_dict(p, "TitleFont", None) # 图例标题位置 self.titlepos = Projection.leaf_to_dict(p, "TitlePos", { 'rotation': 90, 'va': 'top', 'ha': 'center', 'ypercent': 0.5 }) # ---------- 无投影时的图例配置 start -------- # 图例放置方式 self.orientation = Projection.leaf_to_string(p, 'Orientation', 'vertical') # 图例离边框位置 self.anchor = Projection.leaf_to_list(p, "Anchor", [0, 0]) # 图例收缩系数 self.shrink = Projection.leaf_to_float(p, "Shrink", 1) self.fraction = Projection.leaf_to_float(p, 'Fraction', 0.15) # ---------- 有投影时的图例配置 start -------- # 图例收缩系数 self.size = Projection.leaf_to_string(leaf=p, code='Size', defvalue='5%') # 图例离边框位置 self.pad = Projection.leaf_to_string(leaf=p, code='Pad', defvalue='2%') # 图例放置位置 self.location = Projection.leaf_to_string(leaf=p, code='Location', defvalue='right')
def __init__(self, root): p = root.find("Legend") if p is None: print(u'没有图例节点') return # 图例图片文件路径,图例叠加到产品图上的位置,为空表示自行生成图例 legend_pic = p.find("LegendPic").text self.islegendpic = False self.legendpic = '' self.legendpos = [0, 0] self.legendopacity = 1 if not (legend_pic is None or legend_pic.strip() == ''): self.islegendpic = True legend_pics = legend_pic.strip().split(',') if 1 == len(legend_pics): self.legendpic = legend_pics[0].strip() elif 4 == len(legend_pics): self.legendpic = legend_pics[0].strip() self.legendpos = [float(legend_pics[1].strip()), float(legend_pics[2].strip())] self.legendopacity = float(legend_pics[3].strip()) else: self.legendpic = legend_pics[0].strip() # 图例的延展类型:neither,min,max default is neither self.extend = Projection.leaf_to_string(p, 'Extend', 'neither') # 是否取MICAPS数据本身的图例值 self.micapslegendvalue = Projection.leaf_to_bool(p, "MicapsLegendValue", True, 'TRUE') # When micapslegendvalue is true, the setting is working. # if pin the legend values, [begin value, stop value, step] is working.default is None # else use the data self legend values self.pinlegendvalue = Projection.leaf_to_list(p, "PinLegendValue", None) self.valid(self.pinlegendvalue) # NCL colorbar 的别名 self.micapslegendcolor = Projection.leaf_to_string(p, 'MicapsLegendColor', 'ncl_default') # 图例填充样式数组,一般和自定义的legend结合使用,如不够LegendValue数组的长度,则会用最后一个样式自动补齐 self.hatches = Projection.leaf_to_list(p, "Hatches", ['']) self.validhatches(self.hatches) # 图例等级值 self.legendvalue = Projection.leaf_to_list(p, "LegendValue", None) # 实际显示在图例上的值 self.legendvaluealias = Projection.leaf_to_list(p, "LegendValueAlias", None) # 图例颜色值 self.legendcolor = Projection.leaf_to_list(p, "LegendColor", None) # 图例抽稀间隔 self.thinning = Projection.leaf_to_int(p, "Thinning", 1) # 图例字体 self.font = Projection.leaf_to_dict(p, "Font", None) # 图例标题 self.title = Projection.leaf_to_string(p, 'Title', '') # 图例标题字体 self.titlefont = Projection.leaf_to_dict(p, "TitleFont", None) # 图例标题位置 self.titlepos = Projection.leaf_to_dict(p, "TitlePos", {'rotation': 90, 'va': 'top', 'ha': 'center', 'ypercent': 0.5}) # ---------- 无投影时的图例配置 start -------- # 图例放置方式 self.orientation = Projection.leaf_to_string(p, 'Orientation', 'vertical') # 图例离边框位置 self.anchor = Projection.leaf_to_list(p, "Anchor", [0, 0]) # 图例收缩系数 self.shrink = Projection.leaf_to_float(p, "Shrink", 1) self.fraction = Projection.leaf_to_float(p, 'Fraction', 0.15) # ---------- 有投影时的图例配置 start -------- # 图例收缩系数 self.size = Projection.leaf_to_string(leaf=p, code='Size', defvalue='5%') # 图例离边框位置 self.pad = Projection.leaf_to_string(leaf=p, code='Pad', defvalue='2%') # 图例放置位置 self.location = Projection.leaf_to_string(leaf=p, code='Location', defvalue='right')
def __init__(self, xmlfile): self.xmlfile = xmlfile if not os.path.exists(self.xmlfile): return try: tree = ElementTree.parse(self.xmlfile) root = tree.getroot() products = root.getchildren() p = products[0] # M1:站点数据,M4:第4类格点数据,M11:第11类UV数据 self.odatatype = Projection.leaf_to_string(p, "OriginalDataType") # 原始数据文件路径 self.ofile = Projection.leaf_to_string(p, "OriginalFile") if self.odatatype == 'M4': self.micapsdata = Micaps4Data(self.ofile) elif self.odatatype == 'M3': self.micapsdata = Micaps3Data(self.ofile) else: return # 地图投影 self.projection = Projection(p) # 地图边界文件路径,仅用于绘制边界 mapborders = p.find("MapBorders").getchildren() self.mapborders = [] for border in mapborders: mapfile = Projection.leaf_to_string(border, "File") filetype = str.upper( Projection.leaf_to_string(border, "Type", 'shp')) polygonswitch = str.upper( Projection.leaf_to_string(border, "Polygon", 'on')) mbdict = { 'file': mapfile, 'filetype': filetype, 'path': self.readPolygon(mapfile) if filetype != 'SHP' else None, 'polygon': polygonswitch, 'draw': Projection.leaf_to_bool(border, "Draw", False), 'linewidth': Projection.leaf_to_float(border, "LineWidth", 1), 'linecolor': Projection.leaf_to_string(border, "LineColor", 'k') } self.mapborders.append(mbdict) # 裁剪边界文件路径,用于对色斑图进行裁剪 cutborders = p.find("CutBorders").getchildren() self.cutborders = [] for border in cutborders: filehead = Projection.leaf_to_string(border, "File") filetype = Projection.leaf_to_string(border, "Type", 'shp') code = Projection.leaf_to_list(border, "Code", [360000]) drawswitch = str.upper( Projection.leaf_to_string(border, "Draw", 'off')) linecolor = Projection.leaf_to_string( border, "LineColor", 'k') if drawswitch == 'ON' else 'none' mbdict = { 'path': self.getPath(filehead=filehead, code=code, filetype=filetype), 'draw': drawswitch, 'using': Projection.leaf_to_bool(border, "Using", True), 'linewidth': Projection.leaf_to_float(border, "LineWidth", 1), 'linecolor': linecolor } self.cutborders.append(mbdict) # 生成的图片宽度 self.width = Projection.leaf_to_float(p, "PicWidth", 10) # 生成的图片高度 self.height = Projection.leaf_to_float(p, "PicHeight", 10) # dpi self.dpi = Projection.leaf_to_int(p, "Dpi", 72) # 高宽比 self.widthshrink = Projection.leaf_to_float(p, "WidthShrink", 1.0) # 绘图区外延 self.margin = Projection.leaf_to_float(p, "Margin", 0.0) # 绘图区内边距 self.pad = Projection.leaf_to_float(p, "Pad", 0.0) # 绘图区域 extents = p.find("Extents").text.strip() if extents is None or extents == '': if len(self.cutborders ) < 1 or self.cutborders[0]['path'] is None: self.extents = None else: jxextend = self.cutborders[0]['path'].get_extents() delta = self.margin xmax = jxextend.xmax + delta xmin = jxextend.xmin - delta ymax = jxextend.ymax + delta ymin = jxextend.ymin - delta self.extents = Bbox.from_extents(xmin, ymin, xmax, ymax) else: self.extents = Projection.leaf_to_list(p, "Extents", None) # 画布透明度 self.opacity = Projection.leaf_to_float(p, 'Opacity', 1) if self.opacity < 0 or self.opacity > 1: self.opacity = 1 # 生成的图片文件存放路径 self.picfile = Projection.leaf_to_string(p, 'PicFile', 'mytest.png') Products.checkFilename(self.picfile) # 图例图片文件路径,图例叠加到产品图上的位置,为空表示自行生成图例 legend_pic = p.find("LegendPic").text self.islegendpic = False self.legendpic = '' self.legendpos = [0, 0] self.legendopacity = 1 if not (legend_pic is None or legend_pic.strip() == ''): self.islegendpic = True legend_pics = legend_pic.strip().split(',') if 1 == len(legend_pics): self.legendpic = legend_pics[0].strip() elif 4 == len(legend_pics): self.legendpic = legend_pics[0].strip() self.legendpos = [ float(legend_pics[1].strip()), float(legend_pics[2].strip()) ] self.legendopacity = float(legend_pics[3].strip()) else: self.legendpic = legend_pics[0].strip() # 是否取MICAPS数据本身的图例值 self.micapslegendvalue = Projection.leaf_to_bool( p, "MicapsLegendValue", True, 'TRUE') # 第三类数据等值线步长 self.step = Projection.leaf_to_float(p, 'Step', 2.) # NCL colorbar 的别名 self.micapslegendcolor = Projection.leaf_to_string( p, 'MicapsLegendColor', 'ncl_default') # 图例等级值 self.legendvalue = Projection.leaf_to_list(p, "LegendValue", None) # 图例颜色值 self.legendcolor = Projection.leaf_to_list(p, "LegendColor", None) # 图例放置方式 self.orientation = Projection.leaf_to_string( p, 'Orientation', 'vertical') # 图例离边框位置 self.anchor = Projection.leaf_to_list(p, "Anchor", [0, 0]) # 图例收缩系数 self.shrink = Projection.leaf_to_float(p, "Shrink", 1) self.fraction = Projection.leaf_to_float(p, 'Fraction', 0.15) # 是否按Micaps数据的标题写产品描述 self.mtitleposition = Projection.leaf_to_list( p, "MTitlePosition", None) # 经纬方向上的插值格点数 self.grid = Projection.leaf_to_list(p, "Grid", [195, 216]) if len(self.grid) != 2: self.grid = [195, 216] else: self.grid = [parseInt(str(g)) for g in self.grid] # 等值线参数 # self.contourvisible = Projection.leaf_to_bool(p, "ContourVisible", False, 'TRUE') contourleaf = p.find("Contour") if contourleaf is None: self.contour = { 'visible': False, 'linewidth': 1.0, 'linecolor': 'k', 'colorline': False } else: self.contour = { 'visible': Projection.leaf_to_bool(contourleaf, "Visible", False, 'TRUE'), 'linewidth': Projection.leaf_to_float(contourleaf, 'LineWidth', 1.0), 'linecolor': Projection.leaf_to_string(contourleaf, 'LineColor', 'k'), 'colorline': Projection.leaf_to_bool(contourleaf, "ColorLine", False, 'TRUE') } # 是否显示色斑图 self.contourfvisible = Projection.leaf_to_bool( p, "ContourfVisible", False, 'TRUE') # 等值线标注参数 # self.contourlabelvisible = Projection.leaf_to_bool(p, "ContourLabelVisible", False, 'TRUE') leaf = p.find("ContourLabel") if leaf is None: self.contourlabel = { 'visible': False, 'fmt': '%1.0f', 'fontsize': 12, 'fontcolor': 'k' } else: self.contourlabel = { 'visible': Projection.leaf_to_bool(leaf, "Visible", False, 'TRUE'), 'fmt': Projection.leaf_to_string(leaf, 'Fmt', '%1.0f'), 'fontsize': Projection.leaf_to_float(leaf, 'FontSize', 12), 'fontcolor': Projection.leaf_to_string(leaf, 'FontColor', 'k') } # 产品图片文字描述(可能多个) descs = p.find("Descs").getchildren() self.descs = [] for desc in descs: txt = Projection.leaf_to_string(desc, 'Text', u'测试数据') pos = Projection.leaf_to_list(desc, "Position", [113.2, 30.5]) fonts = desc.find("Font").text.strip().split(',') font = { 'family': 'monospace', 'weight': 'bold', 'fontsize': 12, 'color': 'k' } if len(fonts) == 4: font['fontsize'] = parseInt(fonts[0].strip()) font['family'] = fonts[1] font['weight'] = fonts[2] font['color'] = fonts[3] self.descs.append(HeadDesc(txt, pos, font)) except Exception as err: print(u'【{0}】{1}-{2}'.format(self.xmlfile, err, datetime.now())) return None