def record_to_dict(record):
# Encodes record title if it is not empty.
if record.title:
record.title = record.title.encode('ascii', 'ignore').decode('utf-8')
bbox = wkt2geom(record.wkt_geometry)
min_x, min_y, max_x, max_y = bbox[0], bbox[1], bbox[2], bbox[3]
record_dict = {
'title': record.title,
'abstract': record.abstract,
'title_alternate': record.title_alternate,
'checks_list': [],
'bbox': bbox,
'min_x': min_x,
'min_y': min_y,
'max_x': max_x,
'max_y': max_y,
'source': record.source,
'source_type': record.type,
'tile_url': '/layer/%s/wmts/%s/default_grid/{z}/{x}/{y}.png' % (record.identifier, record.title_alternate),
'layer_date': record.date_modified,
'layer_originator': record.creator,
'layer_identifier': record.identifier,
'links': {
'xml': '/'.join(['layer', record.identifier, 'xml']),
'yml': '/'.join(['layer', record.identifier, 'yml']),
'png': '/'.join(['layer', record.identifier, 'png'])
},
# 'rectangle': box(min_x, min_y, max_x, max_y),
'layer_geoshape': {
'type': 'envelope',
'coordinates': [
[min_x, max_y], [max_x, min_y]
]
}
}
if(record.format == 'OGC:WMS'):
legend_opts = {
'SERVICE': 'WMS',
'VERSION': '1.1.1',
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
'LAYER': record.title_alternate
}
record_dict['legend_url'] = '/layer/%s/service?' % record.identifier + urlencode(legend_opts)
record_dict = include_registry_tags(record_dict, record.xml)
if record.links:
record_dict['references'] = parse_references(record.links)
if record.source:
record_dict['source_host'] = urlparse(record.source).netloc
return record_dict
评论列表
文章目录