1 Star 2 Fork 2

cnxd365 / 气象数据可视化

forked from 谢磊 / 气象数据可视化 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Border.py 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
非对称 提交于 2019-11-19 08:51 . Update README.md
# -*- 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(r'[,]+|[\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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cnxd365/qixiangshujukeshihua.git
git@gitee.com:cnxd365/qixiangshujukeshihua.git
cnxd365
qixiangshujukeshihua
气象数据可视化
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891