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


Python ArcGIS MQTT用法及代码示例


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

用法:

class arcgis.realtime.velocity.feeds.MQTT(label, description, host, port, topic, qos_level=0, username=None, password=None, client_id=None, data_format=None, track_id_field=None, geometry=None, time=None)

可选参数:

  • username: String 。用于基本身份验证的用户名。
  • password: String 。基本身份验证的密码。
  • client_id: String 。客户端 ID ArcGIS Velocity 将用于连接到 MQTT 代理。
  • data_format: [ EsriJsonFormat GeoJsonFormat DelimitedFormat JsonFormat XMLFormat ]。包含此 feed 的数据格式配置的实例。仅配置允许的格式。如果在初始化期间未正确设置,则会自动检测格式并根据传入数据的样本进行设置。该示例将从 init 中迄今为止提供的配置中获取。
  • track_id_field: String 。应设置为轨道 ID 的传入数据字段的名称。
  • geometry: [XYZGeometrySingleFieldGeometry]。几何配置的实例,将用于从传入数据创建几何对象。
  • time: [TimeInstantTimeInterval]。时间配置实例,将用于根据传入数据创建时间信息。

返回:

具有 MQTT 提要配置的数据类。

从 MQTT 代理接收事件。该数据类可用于定义提要配置并创建提要。

Parameter

Description

label

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

description

String 。饲料说明。

host

String 。代理的主机名,前缀为“tcp://”(对于非 SSL)或“ssl://”(对于 SSL 连接)。

port

国际。可访问 MQTT 代理的端口。

topic

String 。事件消息流的主题。

qos_level

国际。服务质量 (QoS) 级别定义了特定消息的传送保证。在 MQTT 3.1.1 中,QoS 为 0 表示消息最多传送一次,QoS 为 1 表示至少传送一次,QoS 为 2 则恰好传送一次。默认值为:0。

例子:

# Usage Example

from arcgis.realtime.velocity.feeds import MQTT
from arcgis.realtime.velocity.feeds.geometry import XYZGeometry, SingleFieldGeometry
from arcgis.realtime.velocity.feeds.time import TimeInterval, TimeInstant

mqtt_config = MQTT(
    label="feed_name",
    description="feed_description",
    host="Mqtt host",
    port=8883,
    topic="Mqtt topic",
    qos_level=0,
    username="Mqtt_username",
    password="Mqtt_password",
    client_id="Mqtt_client_id",
    data_format=None
)

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

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

相关用法


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