1

Defining logic for when vehicle coords fall within geofence bounds

Тема: Defining logic for when vehicle coords fall within geofence bounds

Hi Wialon team,

I am defining logic in Python to understand when our moving assets have crossed into our defined  geofences. I am using get_zone_data method to get the coordinates of our geofences:

from urllib.parse import urlencode
import json

params = {
    "itemId": 6776, # not sure why I have to specify ids of our moving assets for details about geofences, where is the relation?
    "col": [1],
    "flags":  7 
}

encoded_params = urlencode({"params": json.dumps(params)}, doseq=True)
geofence_url = f"https://ls2a.locationsolutions.com/wialon/ajax.html?svc=resource/get_zone_data&{encoded_params}&sid={sid}"

print(geofence_url)

I am getting the following sample data:

[{"id":1,"ar":57066.8398603,"pr":974.44449707,"b":{"min_x":55.6299445629,"min_y":24.6950722587,"max_x":55.6340762805,"max_y":24.6990892958,"cen_x":55.6320104217,"cen_y":24.6970807773},"ct":1578920042,"mt":1584510923}]

My main concern is that if I relying on min and max x and y, and saying that vehicle coordinates should fall within these values, that I am not capturing the full shape of the geofence and I missing out on data as a result. Can you please provide us with support on how we can ensure we are capturing all data related to vehicles entering geofence areas? If there are additional parameters that can help in plotting the geofence that I am not getting through this get_zone_data API call for example. Thanks and regards.

2

Defining logic for when vehicle coords fall within geofence bounds

Re: Defining logic for when vehicle coords fall within geofence bounds

Hello Omar Salem ,
If I understand your requirements correctly, you may try to use resource/get_zones_by_point request. In this case, you need to get unit's last known location and use the coordinates to see if any geofences are within the indicated radius.

If you need different information, please, let us know.

Anton Zinovyev
Technical Care Engineer (L2)
Wialon
3

Defining logic for when vehicle coords fall within geofence bounds

Re: Defining logic for when vehicle coords fall within geofence bounds

Hi, thanks for the prompt reply. I am looking for more detailed information on coordinates of our geofences. With min and max, we only have two points which is insufficient for plotting the full shape of the actual geofence. While appreciated, the get zones by point request will not work since we are trying to understand this for past data as well.

4

Defining logic for when vehicle coords fall within geofence bounds

Re: Defining logic for when vehicle coords fall within geofence bounds

Dear Omar Salem, in this case, you may use resource/get_zone_data request without "flags" parameter at all. In this case, you need to check parameter "p" that contains array of all points that were used to render the geofence on map in Wialon.
If you mean something, else, you may write to support@wialon.com with full details of your task.

Anton Zinovyev
Technical Care Engineer (L2)
Wialon