How to determine start and end point of Unit using Geofence

(edited by harshad.p 09/06/2016 13:12:15)

Topic: How to determine start and end point of Unit using Geofence

Hi Fellows,
I hope this is right place to post this query.
I am totally new and developing wialon hosted app and using remote app.
I wonder how we can determine if unit started or reached end point, I am using geofence.
Also, is there any way how to determine unit progress in terms of % etc.

Help would boost my development.



How to determine start and end point of Unit using Geofence

Re: How to determine start and end point of Unit using Geofence

harshad.p, hello!

This answer for Wialon Hosting or Local.

If You are looking for simple solution and don't want to explore routes (http://sdk.wialon.com/wiki/en/sidebar/r … oute/route) - You can do it in such way:

1. For example You have one unit and 2 geofences (Start and Finish).
2. Create 2 notifications with trigger Geofence. One of type Outside geofence with Start geofence selected, the second - Inside geofence with Finish geofence selected. Set action Show online notification.
3. Subscribe to units' and resources' messages (http://sdk.wialon.com/wiki/en/sidebar/r … data_flags) using such request:

                        "data":[<resource_id>, <unit_id>],
                        "flags":0x21, // messages + base (at least)    

4. Then Your app should send avl_evts requests (http://sdk.wialon.com/wiki/en/sidebar/r … s/avl_evts) every 3 - 10 seconds and process response if it contains triggered notifications (look parameter "tp": "unm"). Triggered notification's json will look like this:

    "tm": 1465557949,
    "events": [
            "i": 763661,
            "t": "m",
            "d": {
                "t": 1465557947,
                "f": 896,
                "tp": "unm",
                "name": "Notification Start",
                "txt": "TestUnit  left Start. At 2016-06-10 14:25:47 it moved with speed 30 mph near 'Morgan St, Everett, MA 02149, USA'",
                "color": "",
                "url": "",
                "unit": 974873,
                "blink": 0,
                "x": -71.0588824233,
                "y": 42.4117158806,
                "nid": 13,
                "p": {}

You will be able to distinguish notification of started unit and notification of finished unit.

Also it may be useful for You to try notification action Send request.
When notification triggers - get or post request can be sent to Your server with some data.
And Your server can handle such requests.

As for percentage of unit progress between geofences - here is some simple draft method:
1. You can calculate distance between 2 geofences (according to routing).
2. When Notification Start triggered You can save unit's mileage counter's value to some variable.
3. On every unit's new message (or better every 10th message if they are often) increase some virtual mileage counter by adding difference between current mileage counter value and saved value at start.
4. Then percentage of unit's progress can be calculated: (virtual mileage counter value / full distance between geofences) * 100%

Head of Wialon Local Department