get_zones_by_point

The get_zones_by_point method is used to check if a point is inside certain geofences or to find the nearest geofence.

Endpoint

Copied!
svc=resource/get_zones_by_point&params={
  "spec": {
    "lat": <double>,
    "lon": <double>,
    "radius": <double>,
    "zoneId": {
      "<long>": [<long>, ...],
      ...
    }
  }
}

Parameters

Name Description
zoneId The list of geofences: {“resource ID”:[geofence ID,…], …}.
lat Latitude.
lon Longitude.
radius The geofences search radius, m. Optional field.

If the array of geofence IDs for the indicated “resource ID” is empty, all the resource geofences are taken.

Response

If the point is inside the geofence, the returned result is:

Copied!
{
  "<text>": {      /* resource ID */
    "<text>": 0,   /* geofence ID: the distance to the geofence, m (always 0 in this case) */
    ...
  },
  ...
}

If the point is outside the geofence, the returned result is:

Copied!
{
  "<text>": {          /* resource ID */
    "<text>": <double> /* geofence ID: distance to the geofence, m */
  }
}

If there is no radius field, the returned result is:

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

If there is no radius field and the point isn’t inside any of the specified geofences, an empty object ({}) is returned.

Error codes

Code Description
4 Wrong input parameters.
6 General error.

If you find a mistake in the text, please select it and press Ctrl+Enter.