代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
#
# Author: Liu xianyao
# Email: flashlxy@qq.com
# Update: 2017-04-06
# Copyright: ©江西省气象台 2017
# Version: 1.1.20170409
from __future__ import print_function
from datetime import datetime
import re
from matplotlib.path import Path
from ClipBorder import ClipBorder
from Projection import Projection
class Border:
"""
标题描述类
"""
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')
@staticmethod
def readPolygon(filename):
"""
从特定格式的文件中获取path
:param filename: 特定的数据文件全名
:return: path对象的一个实例
"""
try:
file_object = open(filename)
all_the_text = file_object.read().strip()
file_object.close()
poses = re.split('[,]+|[\s]+', all_the_text)
lon = [float(p) for p in poses[0::2]]
lat = [float(p) for p in poses[1::2]]
path = Path(zip(lon, lat))
return path
except Exception as err:
print(u'【{0}】{1}-{2}'.format(filename, err, datetime.now()))
return None
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。