Skip to content

Location Data Schema

Chris Scott edited this page Aug 24, 2015 · 8 revisions

Javascript Callback Schema

The schema of the Location-object sent to your successFn takes the same form as the standard Cordova plugin cordova-plugin-geolocation.

Android has some added meta-data in the activity key. This describes the nature of the last reported activity from Android's Activity Recognition System, including a probability between 0-100%.

bgGeo.configure(function(location, taskId) {
    console.log(location);       // <-- See detailed Schema below
    bgGeo.finish(taskId);
}, errorCallback, config);
{
    "timestamp":     [Date],     // <-- Javascript Date instance
    "is_moving":     [Boolean]   // <-- The motion-state when location was recorded.
    "coords": {
        "latitude":  [Float],
        "longitude": [Float],
        "accuracy":  [Float],
        "speed":     [Float],
        "heading":   [Float],
        "altitude":  [Float]
    },
    "activity": {                // <-- Android Only
        "type": [still|on_foot|walking|running|in_vehicle|on_bicycle],
        "confidence": [0-100%]
    },
    "battery": {
        "level": [Float],
        "is_charging": [Boolean]
    }
}

HTTP POST Schema

The location-data schema POSTed to your server takes the following form:

{
    "location": {
        "coords": {
            "latitude":   [Float],
            "longitude":  [Float]
            "accuracy":   [Float]
            "speed":      [Float],
            "heading":    [Float],
            "altitude":   [Float]
        },
        "activity": {                // <-- Android Only
            "type": [still|on_foot|walking|running|in_vehicle|on_bicycle],
            "confidence": [0-100%]
        },
        "battery": {
            "level": [Float],
            "is_charging": [Boolean]
        },
        "timestamp": [ISO-8601 UTC], // eg:  "2015-05-05T04:31:54Z"
        "is_moving": [Boolean]       // <-- The motion-state when location was recorded.
    },
    "device_id": [Device UUID]       // eg:  "39dbac67e2c9d80"
}