get_zones_by_unit

The get_zones_by_unit request checks if the specified units are inside the specified geofences.

Endpoint

Copied!
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 (zoneId), units (units), and time (time) for which the unit location inside the geofences is checked. See the description of these parameters below.

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": {

 “912”: [4, 5, 6, 7, 8, 9], 

 “913”: [1, 2, 3, 4, 5, 76]


In this example:

  • The resource with ID 912 includes the geofences with IDs 4, 5, 6, 7, 8, 9.
  • The resource with ID 913 includes the geofences with IDs 1, 2, 3, 4, 5, 76.

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:

  • If a timestamp value in the Unix format is specified, then the unit location at the specified time is checked.
  • If 0 is specified, the latest known location of the unit is checked.

Example

“time”: 0

In this example, the latest location of the unit is checked.

Request example

Copied!
https://hst-api.wialon.com/wialon/ajax.html?svc=resource/get_zones_by_unit&sid=0b149aca05cd00ee2c7658124f5248fe&params={"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.

Copied!
{
    "<text>": {   /* resource ID */
        "<text>": [   /* geofence IDs */
            <long>,   /* unit IDs */
            ...
        ]
    },
    ...
}


Success response example

Copied!
{"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.

Copied!
{ }

Possible error codes

If the request is not completed successfully, an error code is returned.

Error codeDescription
4Invalid input parameters.
6Unknown error.
Download PDF file
Download Word document

See also