get_zones_by_unit
The get_zones_by_unit request checks if the specified units are inside the specified geofences.
Endpoint
https://hst-api.wialon.com/wialon/ajax.html?svc=resource/get_zones_by_unit
Parameters
The following parameters are required:
Name | Type | Description |
sid | string | The session ID used for authentication. |
params | object | A JSON object containing request specifications. |
spec | object | Contains information about the geofences ( |
spec parameters
The following spec
parameters are required:
Name | Type | Description |
zoneId | object | A JSON object that maps resource IDs to arrays of geofence IDs. Each key is the resource ID, and the value is an array of corresponding geofence IDs for this resource. Example "zoneId": { In this example:
|
units | array of integers | A list of unit IDs for which presence in the geofences is checked. Example “units”: [917] In this example, the unit with ID 917 is checked. |
time | integer | Specifies the time for which the unit location inside the geofences is checked:
Example “time”: 0 In this example, the latest location of the unit is checked. |
Request example
https://hst-api.wialon.com/wialon/ajax.html?svc=resource/get_zones_by_unit&sid=0b149aca05cd00ee2c7658124f5248fe¶ms={"spec":{"zoneId":{"912":[4,5,6,7,8,9],"913":[1,2,3,4,5,76]},"units":[917],"time":0}}
In this example:
- The request checks if the unit with ID 917 is located within the specified geofences of two resources with IDs 912 and 913.
- time=0 specifies that the latest location of unit 917 is checked.
Returned result
The response indicates whether the specified unit or units were located within the specified geofences at the requested time.
{
"<text>": { /* resource ID */
"<text>": [ /* geofence IDs */
<long>, /* unit IDs */
...
]
},
...
}
Success response example
{"912":{"4":[917]}}
In this example, the unit with ID 917 is inside the geofence with ID 4. The geofence belongs to the resource with ID 912.
Empty response
If no units are found in the geofences at the specified time, an empty JSON is returned.
{ }
Possible error codes
If the request is not completed successfully, an error code is returned.
Error code | Description |
---|---|
4 | Invalid input parameters. |
6 | Unknown error. |