本文整理汇总了Python中owslib.wms.WebMapService.gettile方法的典型用法代码示例。如果您正苦于以下问题:Python WebMapService.gettile方法的具体用法?Python WebMapService.gettile怎么用?Python WebMapService.gettile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类owslib.wms.WebMapService
的用法示例。
在下文中一共展示了WebMapService.gettile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_thumbnail
# 需要导入模块: from owslib.wms import WebMapService [as 别名]
# 或者: from owslib.wms.WebMapService import gettile [as 别名]
def update_thumbnail(self):
print 'Generating thumbnail for layer id %s' % self.id
if not self.has_valid_bbox():
raise ValueError('Extent for this layer is invalid, cannot generate thumbnail')
return None
format_error_message = 'This layer does not expose valid formats (png, jpeg) to generate the thumbnail'
img = None
if self.service.type == 'OGC_WMS':
ows = WebMapService(self.service.url)
op_getmap = ows.getOperationByName('GetMap')
image_format = 'image/png'
if image_format not in op_getmap.formatOptions:
if 'image/jpeg' in op_getmap.formatOptions:
image_format = 'image/jpeg'
else:
raise NotImplementedError(format_error_message)
img = ows.getmap(
layers=[self.name],
srs='EPSG:4326',
bbox=(
float(self.bbox_x0),
float(self.bbox_y0),
float(self.bbox_x1),
float(self.bbox_y1)
),
size=(50, 50),
format=image_format,
transparent=True
)
if 'ogc.se_xml' in img.info()['Content-Type']:
raise ValueError(img.read())
img = None
elif self.service.type == 'OGC_WMTS':
ows = WebMapTileService(self.service.url)
ows_layer = ows.contents[self.name]
image_format = 'image/png'
if image_format not in ows_layer.formats:
if 'image/jpeg' in ows_layer.formats:
image_format = 'image/jpeg'
else:
raise NotImplementedError(format_error_message)
img = ows.gettile(
layer=self.name,
tilematrixset=ows_layer.tilematrixsets[0],
tilematrix='0',
row='0',
column='0',
format=image_format
)
elif self.service.type == 'WM':
ows = WebMapService(self.url, username=settings.WM_USERNAME, password=settings.WM_PASSWORD)
op_getmap = ows.getOperationByName('GetMap')
image_format = 'image/png'
if image_format not in op_getmap.formatOptions:
if 'image/jpeg' in op_getmap.formatOptions:
image_format = 'image/jpeg'
else:
raise NotImplementedError(format_error_message)
img = ows.getmap(
layers=[self.name],
srs='EPSG:4326',
bbox=(
float(self.bbox_x0),
float(self.bbox_y0),
float(self.bbox_x1),
float(self.bbox_y1)
),
size=(50, 50),
format=image_format,
transparent=True
)
if 'ogc.se_xml' in img.info()['Content-Type']:
raise ValueError(img.read())
img = None
elif self.service.type == 'WARPER':
ows = WebMapService(self.url)
op_getmap = ows.getOperationByName('GetMap')
image_format = 'image/png'
if image_format not in op_getmap.formatOptions:
if 'image/jpeg' in op_getmap.formatOptions:
image_format = 'image/jpeg'
else:
raise NotImplementedError(format_error_message)
img = ows.getmap(
layers=[self.name],
srs='EPSG:4326',
bbox=(
float(self.bbox_x0),
float(self.bbox_y0),
float(self.bbox_x1),
float(self.bbox_y1)
),
size=(50, 50),
format=image_format,
transparent=True
)
if 'ogc.se_xml' in img.info()['Content-Type']:
raise ValueError(img.read())
img = None
#.........这里部分代码省略.........