Table of Contents

Geofences: create, edit, delete

To create, edit or delete geofences, use the command resource/update_zone:

svc=resource/update_zone&params={"itemId":<long>,
				 "id":<long>,
				 "callMode":<text>,
				 "n":<text>,
				 "d":<text>,
				 "t":<int>,
				 "w":<int>,
				 "f":<uint>,
				 "c":<int>,
				 "tc":<uint>,
				 "ts":<uint>,
				 "min":<uint>,
				 "max":<uint>,
				 "path":<text>,
				 "libId":<long>,
				 "oldItemId":<uint>,
				 "oldZoneId":<uint>,
				 "jp":<JSON>,
				 "p":[				
					{
						"x":<double>,
						"y":<double>,
						"r":<int>
					}
				 ]}

Parameters

Name Description
itemId resource ID
id geofence ID (0 to create)
callMode action: create, update, delete, reset_image
oldItemId resource id from where geofence is to be copied
oldZoneId geofence id which is to be copied

:!: To copy (and also edit) geofence please use *oldItemId* and *oldZoneId* options in order to state desired geofence.
Other parameters are required only for creating and updating, you can see them in the chapter Geofences: detailed information.

Response

On create and edit:

[
	<long>,		/* geofence ID */
	{
		"n":<text>,	/* name */
		"d":<text>,	/* description */
		"id":<long>,	/* geofence ID */
		"f":<uint>,	/* flags */
		"t":<int>,	/* type: 1 - line, 2 - polygon, 3 - circle */
		"e":<ushort>	/* check sum (CRC16) */
		"c":<uint>,	/* color RGB */
		"i":<ushort>,	/* check sum of image (CRC16) */
		"path":<text>,	/* short path to default icon */
		"libId":<long>,	/* id of icon library , 0 - id for default icon library */
		"b":{		/* configuration for rendering */
			"min_x":<double>,	/* minimal longitude */
			"min_y":<double>,	/* minimal latitude */
			"max_x":<double>,	/* maximal longitude */
			"max_y":<double>,	/* maximal latitude */
			"cen_x":<double>,	/* longitude of center */
			"cen_y":<double>	/* latitude of center */
		},
		"ct":<uint>,    /* creation time */  
		"mt":<uint>,     /* last modification time */
		"jp":<JSON>     /* custom JSON */
	}
]

Geofences flags are described in the chapter Geofences: detailed information.

On delete:

[
	<long>,		/* geofence ID */
	null
]