用于incf数字地图册基础设施的python api
incf.dai的Python项目详细描述
发现和访问集线器
简而言之,印加国防部的DAI由一个所谓的网络组成 中心 提供管理中心的集团决定的任何服务 分享。要发现可用的集线器,有一个实用功能
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']
这提供了当前已知集线器名称的列表。(注:ATM列表 由包提供,因为管理 注册表仍然是一个快速移动的目标。)
知道可用集线器的名称可以选择代理对象 通过调用特定的集线器
>>> from incf.dai.utils import get_hub_by_name >>> whs = get_hub_by_name('whs') >>> whs # doctest: +ELLIPSIS <incf.dai.hub.HubProxy object at ...>
如果您呼叫未知集线器(或输入错误),您将收到一个 键错误
>>> foo = get_hub_by_name('foo') Traceback (most recent call last): KeyError
对于内省,此集线器的服务控制器的url是 可用作
>>> whs.base_url 'http://incf-dev-local.crbs.ucsd.edu/whs/atlas?service=WPS'
所有集线器都应提供两种方法:
>>> whs.GetCapabilities # doctest: +ELLIPSIS <bound method HubProxy.GetCapabilities of ...>
>>> whs.DescribeProcess # doctest: +ELLIPSIS <bound method HubProxy.DescribeProcess of ...>
调用这些方法中的任何一个都将返回自定义响应对象
>>> response = whs.GetCapabilities() >>> response # doctest: +ELLIPSIS <incf.dai.response.Response object at 0x...>
>>> response = whs.DescribeProcess() >>> response # doctest: +ELLIPSIS <incf.dai.response.Response object at 0x...>
通常,不需要调用上述两个方法中的任何一个 以上是他们返回的主要信息,可通过
>>> sorted(whs.capabilities) [u'DescribeSRS', u'GetStructureNamesByPOI', u'ListSRSs', u'ListTransformations', u'TransformPOI']
所有列出的方法都可以立即在hub代理上使用
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']0
喜欢in
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']1
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']2
为了进一步方便,响应对象还支持如下属性 访问数据,如
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']3
请注意如何将命名空间保留为键和属性名称的前缀。
省略必需的参数会引发 applicationerror
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']4
而正确地调用一个方法会给出适当的响应(希望如此)
>>> from incf.dai.utils import list_hub_names >>> sorted(list_hub_names()) ['aba', 'central', 'emap', 'ucsd', 'whs']5
这里的 格式=无 http://code.google.com/p/incf-dai/issues/detail?id=14