1

Getting Geofences

Topic: Getting Geofences

Hello,

I want to know the best SDK method to use to get the list of registered Geofences (Core/Search Item By Property or Resources/Get_Zone_Data) under a certain resource. In addition, it will be great if it is possible to register a geofence under a certain geofence group via SDK and get list of geofences registered under a certain group.

Looking forward !

2

Getting Geofences

(edited by deal 13/05/2016 18:38:59)

Re: Getting Geofences

nasnew, do you use remote api or javascript api?
remote api
You can get all geofences from all resources using such request:

https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_resource","propName":"zones_library","propType":"propitemname","propValueMask":"!","sortType":"sys_name"},"force":1,"flags":0x00001001,"from":0,"to":0}&sid=sid

If you need to get geofences only under certain resources you can use such request:

https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_resource","propName":"zones_library,sys_id","propType":"propitemname","propValueMask":"!,your_res1_id,your_res2_id","sortType":"sys_name"},"force":1,"flags":0x00001001,"from":0,"to":0}&sid=sid

You can get all geofence groups including their geofences ids  for certain resource using such request:

https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_resource","propName":"zone_groups,sys_id","propType":"propitemname","propValueMask":"!,your_res_id","sortType":"sys_name"},"force":1,"flags":0x00100001,"from":0,"to":0}&sid=sid

To create/update geofence group and add geofences to it you can use such request:

https://hst-api.wialon.com/wialon/ajax.html?svc=resource/update_zones_group&params={"itemId":<your_res_id>, "id":<id_of_group_if_exists>,
                      "callMode":<create/update>,
                      "n":GROUP_NAME,
                      "d":DESCRIPTION,
                      "zns":[<zone_id1,zone_id2,zone_id3>],
                      "f":0}&sid=sid

More details and examples here:
http://sdk.wialon.com/wiki/en/sidebar/r … arch_items
http://sdk.wialon.com/wiki/en/sidebar/r … les/search
http://sdk.wialon.com/wiki/en/sidebar/r … t/resource
http://sdk.wialon.com/wiki/en/sidebar/r … ones_group

Also you can find useful examples and try your code on our playground http://sdk.wialon.com/playground/

Head of Wialon Local Department
Gurtam
3

Getting Geofences

(edited by nasnew 14/05/2016 13:43:38)

Re: Getting Geofences

Thanks a lot

4

Getting Geofences

Re: Getting Geofences

Hi,

I have system that fetch data from wialon and we use to have report in wialon generated and then fetched them with API calls to our custom app. It was working fine untill we have change in user. It appears wialon has complex structure in index and it got changed with user.

Any one please bail out as we are stuck as all api calls are falling deaf and we are not getting desired data.

Please have a look at attached file where we are getting unit name instead geofence and which is havoc in our existing system.

Regards,
Shah

5

Getting Geofences

(edited by nasnew 24/08/2016 14:40:31)

Re: Getting Geofences

Please make sure you have created the proper access token for your new user, please refer the documentation regarding token http://sdk.wialon.com/wiki/en/sidebar/r … oken/token

6

Getting Geofences

Re: Getting Geofences

Thanks for your reply,

I have checked my credentials.
it is fine still getting unit name instead of geofence name.
Please help me out..
I have attached screenshot for reference.

7

Getting Geofences

Re: Getting Geofences

shah007, in Your report template final data in Geofences table there is Geofences/Units section.
Almost all geofences and all units are selected. Units in this section act as virtual geofences with specified radius (100 by default).
If You don't need to see visited units in report (only geofences) just uncheck units in this section.

Head of Wialon Local Department
Gurtam
8

Getting Geofences

Re: Getting Geofences

Hi, Looking in to your attached screen shot, it seems like you have selected vehicles rather than Geofences when you create your Geofence report template.  please see the attached to better understand what I am referring to.

In addition when you create your user please make sure you have assigned your user with the privilege to create, read and update Geofence resource. (please check the second attachment ) or the user has the privilege to have access to the resource consisting the Geofences.

If all are ok i think it is better to check the API request you are making.

9

Getting Geofences

Re: Getting Geofences

Thanks  for reply.

I have checked both the things. They are accessible but I can't get the geofence name in report.

Here I have attached screenshot for your reference

10

Getting Geofences

Re: Getting Geofences

shah007, do You need only geofences in report result? As I wrote just uncheck units in report template.

Head of Wialon Local Department
Gurtam
11

Getting Geofences

Re: Getting Geofences

Thanks @deal,

I have unchecked all units and checked the same but still displays unit names.

I have attached screenshots

12

Getting Geofences

(edited by deal 30/08/2016 18:23:29)

Re: Getting Geofences

shah007, I've created copy of Your report template (final data) and unchecked all units in Geofences table and got only geofences in resulting report. Try it.

Head of Wialon Local Department
Gurtam
13

Getting Geofences

Re: Getting Geofences

Hello,
Now,I am trying geofences report(area report) with custom template.But I can not data when execute report.
When I check with original template not custom template,data are receive.
My custom template is the following:

var template = {// fill template object
    "id": 0,
    "n": "unit_zones_visit",
    "ct": "avl_unit",
    "p":"",
    "tbl": [{
        "n": "unit_zones_visit",
        "l": "unit_zones_visit",
        "c": "",
        "cl": "",
        "s": "",
        "sl": "",
        "p": "",
        "sch": {
   
      "f1": 0,
          "f2": 0,
          "t1": 0,
          "t2": 0,
          "m": 0,
          "y": 0,
          "w": 0
        },
        "f": 0
      }
     
      ]
  };