Create Polygonal Geofence

Last Updated on : 2023-06-15 04:57:17

Create a polygonal 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/polygon

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.
vertexes String true The coordinates of the vertices of the polygon, including the latitude and longitude. The number of vertices ranges from 3 to 50.
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/polygon
{ "tag": "ceshi", "fence_name": "The Second Polygonal Geofence", "entity_id": "vdevo16245017293****", "bind_type": 1, "vertexes": "30,120;31,121;29,120", "coord_type": "WGS84", "warn_rule": 1 }

Return example

{ "result": { "fence_id": 51001 }, "t": 1625212527083, "success": true }

Error code

For more information, see error code.