本文整理汇总了Python中shapely.geometry.Polygon.split方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.split方法的具体用法?Python Polygon.split怎么用?Python Polygon.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Polygon
的用法示例。
在下文中一共展示了Polygon.split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CAPMessage
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import split [as 别名]
class CAPMessage(CommonMessage):
def __init__(self, dom):
# self.status = dom.find('{urn:oasis:names:tc:emergency:cap:1.1}status').text
# self.id = dom.find('{http://www.w3.org/2005/Atom}id').text
# self.published, self.updated = [
# iso8601.parse_date(self.__dom.find('{http://www.w3.org/2005/Atom}' + x).text).timestamp() for x in
# ('published', 'updated')]
k = None
for x in dom.iter():
if x.tag == '{http://www.w3.org/2005/Atom}valueName':
k = x.text.strip()
elif k is not None and x.tag == '{http://www.w3.org/2005/Atom}value':
self.__dict__[k] = CAPMessage.__parse_date_or_text(x.text)
elif x.tag not in ["{urn:oasis:names:tc:emergency:cap:1.1}geocode",
"{urn:oasis:names:tc:emergency:cap:1.1}parameter"]:
self.__dict__[x.tag[x.tag.find('}') + 1:]] = CAPMessage.__parse_date_or_text(x.text)
if self.FIPS6:
self.FIPS6 = re.sub("[\n\t ] +", " ", self.FIPS6.strip()).split(" ")
if self.polygon is not None and len(self.polygon.strip()) > 0:
self.polygon = re.sub("[\n\t ] +", " ", self.polygon)
self.polygon = Polygon([(float(x), float(y)) for x, y in [x.split(",") for x in self.polygon.split(" ")]])
else:
self.polygon = None
try:
if self.__dict__['VTEC'] and len(self.VTEC):
self.vtec = VTEC.VTEC(self.VTEC, self)
else:
self.vtec = (NOVTEC(dom, self),)
if len(self.vtec) == 0: # True if there was an invalid vtec code
self.vtec = (NOVTEC(dom, self),)
except KeyError:
self.vtec = (NOVTEC(dom, self),)
@staticmethod
def __parse_date_or_text(str):
try:
str = str.strip()
except AttributeError:
return str
try:
return iso8601.parse_date(str).timestamp()
except iso8601.iso8601.ParseError:
return str
def __str__(self):
return "CAP [ %s %s %s %s ]" % (
time.asctime(time.gmtime(self.published)), self.get_event_type(), self.vtec[-1], self.FIPS6)
def get_event_type(self):
return self.vtec[-1].get_event_type()
def get_start_time_sec(self):
return self.effective
def get_end_time_sec(self):
return self.expires
def get_event_id(self):
return self.id
def get_areas(self):
return self.FIPS6
def applies_to_fips(self, fips):
if not self.FIPS6:
return False
if fips.startswith('0'):
fips = '.' + fips[1:]
else:
fips = '[0' + fips[0] + ']' + fips[1:]
fips = '^' + fips + '$'
fp = re.compile(fips)
return len(list(filter(lambda c: fp.match(c), self.FIPS6))) > 0