1

API for Geofence not working

Topic: API for Geofence not working

Hello,

I'm in a need of support as Im trying to validate if a coordinate is inside a geofence as your API promises will look up, when I make the call, it always returned empty.

According to the API, if not geofence id is provided then it will look it up inside all geofences. Can you pointing me to what Im doing wrong?

   params = {
            "spec": {
                "lon": 14.0884059,
                "lat": -90.8330623,
                "radius": 50.00,
                "zoneId":{}
        }
    }

    try:
        units = wialon_api.resource_get_zones_by_point(**params)
        #units = wialon_api.core_get_account_data(**params)
        #print(json.dumps(units, default=jdefault))
        print str(units)
#        print units
    except WialonError as e:
        print e
       
    wialon_api.core_logout()


The response Im getting is just an empty list even when I know for sure the point falls inside an geofence

2

API for Geofence not working

Re: API for Geofence not working

Hello

According to documentation

zoneId    list of geofences {“resource id”:[geofence id,…], …}

Since you did'n specify any resourceId - you get empty result. Just add resources you're interested in

params = {
            "spec": {
                "lon": 14.0884059,
                "lat": -90.8330623,
                "radius": 50.00,
                "zoneId":{
                    user.bact: []
                }
        }
    }
3

API for Geofence not working

Re: API for Geofence not working

Thanks for the help shmi!

Im lost in translation about the user.bact: [] as I though if I sent an empty array it will search on all the geofences and reply the one contains the point, am I right?

So what can I use as a parameter for user.bact, I mean can you send me an example?

Thanks again

4

API for Geofence not working

Re: API for Geofence not working

singleroot
zoneId array contains resources you want to check. Empty array means you're not interested in any resource

user.bact - it's user billing account (check login response) , I used it as an example.
In zoneId you should specify all resources you're interested in. Yon can send core/search_items request with itemsType=avl_resource to get all available resources first

5

API for Geofence not working

Re: API for Geofence not working

Thanks a lot Shmi, I think I got it.

I replaced user.bact for the ID of the user and left empty the geofence id (documentation says it should search over all geofences).

Im testing other functions and using below:
params = {
        "spec": {
            "itemsType": "avl_resource",
            "propName": "sys_id",
            "propValueMask": "*",
            "sortType": "sys_name"
        },
        "force": 1,
        "flags": 4097,
        "from": 0,
        "to": 0
    }

Im not able to get the column "RID" and "P", I want to do a get_zone_data but is not sure how to get the ID of the geofence...nothing working so far. Can you guide me again on this?

6

API for Geofence not working

Re: API for Geofence not working

Check this sample https://sdk.wialon.com/wiki/en/sidebar/ … y_property

In search_items response

{
    "searchSpec": {
        "itemsType": "avl_resource",
        "propName": "zones_library",
        "propValueMask": "*bing*",
        "sortType": "zones_library",
        "propType": "propitemname"
    },
    "dataFlags": 4097,
    "totalItemsCount": 1,
    "indexFrom": 0,
    "indexTo": 0,
    "items": [{
        "nm": "template_ru",
        "cls": 3,
        "id": 163266,
        "zl": {
            "1": {
                "n": "Ветютнев",
                "d": "",
                "id": 1,
                "f": 1,
                "t": 2,
                "e": 60774,
                "b": {
                    "min_x": 43.5271002776,
                    "min_y": 49.7636455785,
                    "max_x": 43.5622908598,
                    "max_y": 49.7794993012,
                    "cen_x": 43.5446955687,
                    "cen_y": 49.7715724398
                }
            },
///-------------------------------

items - list of resources
items(i) - resource
items(i).id - resource ID
items(i).zl - dict of geofences
items(i).zl(j).id - geofence ID

7

API for Geofence not working

Re: API for Geofence not working

shmi wrote:

{
    "searchSpec": {
        "itemsType": "avl_resource",
        "propName": "zones_library",
        "propValueMask": "*bing*",
        "sortType": "zones_library",
        "propType": "propitemname"
    },
    "dataFlags": 4097,
    "totalItemsCount": 1,
    "indexFrom": 0,
    "indexTo": 0,
    "items": [{
        "nm": "template_ru",
        "cls": 3,
        "id": 163266,
        "zl": {
            "1": {
                "n": "Ветютнев",
                "d": "",
                "id": 1,
                "f": 1,
                "t": 2,
                "e": 60774,
                "b": {
                    "min_x": 43.5271002776,
                    "min_y": 49.7636455785,
                    "max_x": 43.5622908598,
                    "max_y": 49.7794993012,
                    "cen_x": 43.5446955687,
                    "cen_y": 49.7715724398
                }
            },
///-------------------------------

Оригинально!
при -  "propValueMask": "*bing*"
имеем ответ - "n": "Ветютнев"