当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python ArcGIS HttpPoller用法及代码示例


本文简要介绍 python 语言中 arcgis.realtime.velocity.feeds.HttpPoller 的用法。

用法:

class arcgis.realtime.velocity.feeds.HttpPoller(label, description, url, http_method, http_auth_type, url_params=<factory>, http_headers=<factory>, enable_long_polling=False, data_format=None, track_id_field=None, geometry=None, time=None, run_interval=RunInterval(cron_expression='0 * * ? * * *', timezone='America/Los_Angeles'))

可选参数:

  • data_format: [ EsriJsonFormat GeoJsonFormat DelimitedFormat JsonFormat XMLFormat ]。包含此 feed 的数据格式配置的实例。仅配置允许的格式。如果在初始化期间未正确设置,则会自动检测格式并根据传入数据的样本进行设置。该示例将从 init 中迄今为止提供的配置中获取。
  • track_id_field: String 。应设置为轨道 ID 的传入数据的字段名称。
  • geometry: [XYZGeometrySingleFieldGeometry]。几何配置的实例,将用于从传入数据创建几何对象。
  • time: [TimeInstantTimeInterval]。时间配置实例,将用于根据传入数据创建时间信息。
  • run_interval: RunInterval 。调度程序配置的实例。默认为:RunInterval(cron_expression=”0 * * ? * * *”, timezone=”America/Los_Angeles”)

返回:

具有 Http poller feed 配置的数据类。

轮询 HTTP 端点以获取事件数据。该数据类可用于定义提要配置并创建提要。

Parameter

Description

label

String 。此 Feed 实例的唯一标签。

description

String 。饲料说明。

url

String 。提供数据的 HTTP 端点的 URL。

http_http_method

String 。 HTTP 方法。选项:GET 或 POST。

http_auth_type

[ NoAuth BasicAuth CertificateAuth 、OAuth]。包含此 feed 实例的身份验证信息的实例。

url_params

字典[str, str]。 URL 参数/值对的字典,包含用于访问 HTTP 资源的 HTTP 参数。

http_headers

字典[str,str]。 Name-Value 字典,其中包含用于连接到 HTTP 资源的 HTTP 标头。

enable_long_polling

布尔。默认值为:False。

例子:

# Usage Example

from arcgis.realtime.velocity.feeds import HttpPoller
from arcgis.realtime.velocity.http_authentication_type import (
    NoAuth,
    BasicAuth,
    CertificateAuth,
)
arcgis.realtime.velocity.input.format import DelimitedFormat
from arcgis.realtime.velocity.feeds.geometry import XYZGeometry, SingleFieldGeometry
from arcgis.realtime.velocity.feeds.time import TimeInterval, TimeInstant
from arcgis.realtime.velocity.feeds.run_interval import RunInterval

name = "http_poller_feed_name"
description = "http_poller_description_feed"
url = "http_poller_url"
http_auth = NoAuth()
# http_auth = BasicAuth(username="username", password="password")
# http_auth = CertificateAuth(pfx_file_http_location="http_auth_link", password="password")

http_headers = {"Content-Type": "application/json"}
url_params = {"f": "json"}

http_poller = HttpPoller(
    label=name,
    description=description,
    url=url,
    http_method="GET",
    http_auth_type=http_auth,
    url_params=url_params,
    http_headers=http_headers,
    enable_long_polling=False,
    data_format=None
)

# Set track id field
http_poller.set_track_id("track_id")

# Set time field
time = TimeInstant(time_field="time_field")
http_poller.set_time_config(time=time)

# Set geometry field
geometry = XYZGeometry(
    x_field="x",
    y_field="y",
    wkid=4326
)
http_poller.set_geometry_config(geometry=geometry)

# Set recurrence
http_poller.run_interval = RunInterval(
    cron_expression="0 * * ? * * *", timezone="America/Los_Angeles"
)

# use velocity object to get the FeedsManager instance
feeds = velocity.feeds

# use the FeedsManager object to create a feed from this feed configuration
http_poller_feed = feeds.create(http_poller)
http_poller_feed.start()
feeds.items

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 arcgis.realtime.velocity.feeds.HttpPoller。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。