Create Circular Geofence

Last Updated on : 2023-06-20 14:52:23download

Create a circular geofence. The binding types include private geofences and public geofences. A private geofence is used to monitor a single object, and up to 100 private geofences can be created for an object. The total number of private geofences under an account is unlimited.
A public geofence can be used to monitor multiple objects, and up to 1,000 public geofences can be created for an account.

API address

POST: /v2.0/iot-01/fences/circle

Request parameter

Description of body

Parameter name Type IN Required Description
tag String false The custom dimension tag to classify the geofences. The geofences can be filtered by the dimension tags.
fence_name String true The name of the geofence.
bind_type Integer true Indicates the binding type of the geofence. Valid values:
  • 1: private geofence.
  • 2: public geofence.
entity_id String false The ID of a monitored object. The field is required when it is a private geofence, and the field is invalid for a public geofence.
radius Integer true The radius of a geofence. Unit: meters. Valid values: (0,5000].
lon Double true The longitude of a geofence center point.
lat Double true The latitude of a geofence center point.
coord_type String true Indicates the type of the longitude and latitude positioning coordinate system. Valid values:
  • WGS84: Google Coordinate System.
  • GCJ02: AutoNavi.
  • BD09LL: Baidu.
warn_rule Integer true Indicates the alert rules. Valid values:
  • 1: triggers an alert when someone enters the geofence.
  • 2: triggers an alert when someone exits the geofence.
  • 3: triggers an alert when someone enters or exits the geofence.

Return parameter

Parameter name Type Description
result FenceIdRes

Description of result

Parameter name Type Description
fence_id Long The geofence ID.

Request example

POST: /v2.0/iot-01/fences/circle
{ "tag": "family", "fence_name": "Public Geofence", "bind_type": 1, "entity_id": "vdevo16245017293****", "radius": 200, "lon": "31.218093093844786", "lat": "121.36040929664465", "coord_type": "WGS84", "warn_rule": 1 }

Return example

{ "result": { "fence_id": 51000 }, "t": 1625210821631, "success": true }

Error code

For more information, see error code.