-
Notifications
You must be signed in to change notification settings - Fork 25
Mobility Data Manipulation
Allows users to upload mobility data to the system. Mobility data is not attached to a campaign.
mobility/upload
Any authenticated ohmage user may upload mobility data.
- (r) user = A valid username.
- (r) password = The hashed password for the above user.
- (r) client = A short description of the software client performing the upload.
- (r) data = A JSON Array of mobility data points.
Mobility data points come in two flavors: mode_only
and sensor_data
. The former contains only a mobility mode while the latter contains the mobility mode and the sensor data belonging to that mode.
JSON Key | Usage/Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
time | The integer milliseconds since the UNIX epoch representing the time when this data point was created. | ||||||||||||
timezone | The timezone ID for the timezone on the device when this data point was created. | ||||||||||||
location_status | A string describing location status. Must be one of: unavailable, valid, inaccurate, stale. If the status is unavailable, it is an error to send a location object. | ||||||||||||
location | A JSON object for housing location data.
|
||||||||||||
subtype | Must be mode_only. | ||||||||||||
mode | A string defining a mobility mode. Must be one of: still, walk, run, bike, drive |
"data":[
{
"time":1328659200,
"timezone":"PT",
"subtype":"mode_only",
"location_status":"accurate"
"location": {
"latitude":41.891,
"longitude":-87.628,
"accuracy":10,
"provider":"GPS",
"time":1328659369,
"timezone":"PT"
},
"mode":"still"
},
...
]
JSON Key | Usage/Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
time | The integer milliseconds since the UNIX epoch representing the time when this data point was created. | ||||||||||||
timezone | The timezone ID for the timezone on the device when this data point was created. | ||||||||||||
location_status | A string describing location status. Must be one of: unavailable, valid, inaccurate, stale. If the status is unavailable, it is an error to send a location object. | ||||||||||||
location | A JSON object for housing location data.
|
||||||||||||
subtype | Must be sensor_data. | ||||||||||||
mode | A string defining a mobility mode. Must be one of: still, walk, run, bike, drive. | ||||||||||||
speed | A double representing device speed. | ||||||||||||
accel_data | A JSON Array of JSON Objects of the form [{"x":0.0,"y":0.0,"z":0.0}, ...]. | ||||||||||||
wifi_data | A JSON object for housing wi-fi scan data.
|
"data":[
{
"time":1328659200,
"timezone":"PT",
"subtype":"sensor_data",
"location_status":"accurate"
"location": {
"latitude":41.891,
"longitude":-87.628,
"accuracy":10,
"provider":"GPS",
"time":1328659369,
"timezone":"PT"
},
"mode":"still",
"speed":0.0,
"accel_data":[{"x":0.0,"y":0.0,"z":0.0},...],
"wifi_data":{
"time":1328660189,
"timezone":"PT",
"scan":[{"ssid":"ssid_name", "strength":0.0},...]
}
},
...
]
POST /app/mobility/upload HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
user=username
&password=hashed_password
&client=curl
&data=<A JSON Array of JSON Objects matching either the mode_only or sensor_data syntax.>
{
"result" : "success"
}
See the error page for a description of error codes and their associated descriptions.
Allows users to read mobility data.
mobility/read
Mobility data is private to the user uploading the data. There is a configuration flag in ohmage that allows privileged class users to view other user's mobility data provided that the two users have a class in common and the requesting user is privileged in the common class (or classes).
- (r) auth_token = A valid authentication token from user/auth_token
- (r) user = A username of the user attempting to login
- (r) password = A password for the above user.
- (r) client = A short description of the software client performing the upload.
- (r) date = An ISO8601-formatted date from which to retrieve mobility data points.
- (o) username = The username of the user whose data is desired. This is only applicable if the requesting user is an admin or if the server allows it (the "mobility_enabled" flag from config/read) and the requesting user is privileged in any class to which the desired user belongs.
- (o) with_sensor_data = true/false Indicates whether or not to return the sensor data with the regular data. The default is false.
POST /app/mobility/read HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
user=username
&password=hashed_password
&client=curl
&date=2012-02-29
The output is "minified" JSON due to the possible high frequency of mobility data collection. The typical number of points is 1440 per day (once per minute).
The output contains the standard result element along with a JSON Array of JSON Objects with the following schema.
Note: The mode may be "ERROR" meaning that any of the data in the sensor data fields may not be available. This is signified by having the key be missing from the JSON.
JSON Key | Usage/Description | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | The unique identifier for this mobility point. | ||||||||||||||||||||||
m | A string defining the mobility mode for this point. Not present if the data point represents a point with sensor data. | ||||||||||||||||||||||
t | An integer representing the milliseconds since the UNIX epoch when this data point was created. | ||||||||||||||||||||||
tz | A string timezone ID for the timezone on the device when this data point was created. | ||||||||||||||||||||||
ts | An ISO8601-formatted date-time string above the above time and timezone. | ||||||||||||||||||||||
ls | A string describing location status. Must be one of: unavailable, valid, inaccurate, stale. If the status is unavailable, the location object below will not be present. | ||||||||||||||||||||||
l | A JSON object for housing location data.
|
||||||||||||||||||||||
st | The subtype which must be one of "mode_only" or "sensor_data". This will only appear if "with_sensor_data" is true. | ||||||||||||||||||||||
data | This will only appear if "with_sensor_data" is true as a JSONObject with the following key-value pairs.
|
{
"result" : "success"
"data" : [
{
"id":"81DB3AE9-16CB-4B63-B2F6-9E30404B7C65",
"m":"still",
"ts":"2012-02-07 18:07:44",
"t":1328666862,
"tz":"PT",
"ls":"valid",
"l":{
"la":41.891,
"lo":-87.628,
"pr":"GPS",
"t":1328666862,
"tz":"PT"
"ac":30
},
"st":"sensor_data",
"data":{
"sp":83.4389,
"wd":{
"t":1328666321,
"tz":"America/Los_Angeles",
"sc":[
{
"ss":"72:3b:39:11:8a",
"st":-3.389289
},
...
]
},
"ad":[
{
"x":3982.3902,
"y":89.8928094,
"z":39.93092899
},
...
],
}
},
...
]
}
See the error page for a description of error codes and their associated descriptions.
Allows users to read a "chunked" version of mobility data over a date range. Mobility data is aggregated into ten-point chunks where the count of the mobility modes is returned in each chunk.
mobility/read/chunked
See access rules for mobility/read above.
- (r) auth_token = A valid authentication token from user/auth_token
- (r) user = A username of the user attempting to login
- (r) password = A password for the above user.
- (r) client = A short description of the software client performing the upload.
- (r) start_date = An ISO8601-formatted date indicating the start of a date range.
- (r) end_date = An ISO8601-formatted date indicating the end of a date range.
- (o) chunk_mins = The number of minutes per chunk. The default is 10.
POST /app/mobility/read/chunked HTTP/1.1
Host: dev.ohmage.org
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Content-Length: byte-length-of-content
Content-Type: application/x-www-form-urlencoded
user=username
&password=hashed_password
&client=curl
&start_date=2012-02-29
&end_date=2012-03-15
The output is "minified" JSON due to the possible high frequency of mobility data collection.
The output contains the standard result element along with a JSON Array of JSON Objects with the following schema.
JSON Key | Usage/Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mc | A JSON Object defining mobility modes and their counts in the format {"still:1,"walk":2,"run":7} TODO - need to verify the modes allowed in the object -- we used to have an INVALID mode indicating that for some portion of the chunk there was no data. | ||||||||||||
d | An integer representing the chunk duration in milliseconds. | ||||||||||||
tz | A string timezone ID for the timezone on the device when this data point was created. | ||||||||||||
ts | An ISO8601-formatted date-time string representing the time at which the earliest point in this chunk was generated. | ||||||||||||
ls | A string describing location status of the first point in the chunk. Must be one of: unavailable, valid, inaccurate, stale. If the status is unavailable, the location object below will not be present. | ||||||||||||
l | A JSON object for housing location data for the first point in the chunk. If the location status is "unavailable", this will not exist.
|
{
"result" : "success"
"data" : [
{
"mc":{"still:1,"walk":2,"run":7},
"d":600000,
"ts":"2012-02-07 18:07:44",
"tz":"PT",
"ls":"valid",
"l":{
"la":41.891,
"lo":-87.628,
"pr":"GPS",
"t":1328666862,
"tz":"PT",
"ac":30
},
},..
]
}
See the error page for a description of error codes and their associated descriptions.