New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select nearby assets based on your current location #30
Comments
@johnclary Where are we in the workflow when we would want a list of assets near our current location? In creating a new work order? That didn't seem exactly right. |
This needs to happen when a new work order is being created, immediately after the user selects the asset type. The asset type will be used to lookup (from a static object) the socrata resource ID of the corresponding asset. The two parameters of the call to the Socrata API will be the resource ID (aka, the dataset identifier), and the user location (x/y). |
@mateoclarke some rough sample code: // Query Socrata by search radius to find nearby records
// static lookup
var assets = {
'hazard_flasher' : {
'socrata_resource_id' : 'fs3c-45ge',
'label_field' : 'location_name',
'value_field' : 'camera_id',
'search_distance' : 1000, // meters
},
'signal' : {
'socrata_resource_id' : 'xwqn-2f78',
'label_field' : 'location_name',
'value_field' : 'signal_id',
'search_distance' : 100, // meters
}
'camera' : {
'socrata_resource_id' : 'fs3c-45ge',
'label_field' : 'location_name',
'value_field' : 'camera_id',
'search_distance' : 100, // meters
}
}
function buildRequestParams(url, lat, lon, search_distance=2000) {
// Format request parameters accoring to Socrata Query Language Spec
// As defined here: https://dev.socrata.com/docs/queries/
return url + '?$where=within_circle(location, ' + lat + ', ' + lon + ', ' + search_distance + ')';
}
function getAsset(location, asset_type) {
// get assets that are near location lat/lon
// location = {'latitude' : 30.30304, 'longitude': -97.1}
var resource = assets[asset_type];
var url = 'https://data.austintexas.gov/resource/' + resource.socrata_resource_id + '.json';
var options = buildRequestParams(
url,
location['latitude'],
location['longitude'],
search_distance=search_distance)
;
return make_some_ajax_call(options);
}
|
@johnclary @mateoclarke I ran into a blocker on this issue. Not all types of assets have Knack ids in the open dataset tables. within_circle works great for Signals, though! The asset types below do not have Knack ids in the open dataset. Traffic Cameras I thought about changing direction and grabbing data from both Socrata and Knack and then matching things up but I didn't want to go too far before getting some more input. I'm going to put this on hold until next week. |
Good news—we have datasets for all of these. Bad news—these datasets do not have a column for the Knack record ID. That's not too much effort, though. Just need to find some time to do it. |
I'm updating these datasets with a "Source DB" column (API name = DONE:
TODO:
|
Traffic Cameras and DMS are bugging out in the Socrata wizard. Opening an issue with Socrata. |
@mddilley i was able to get this resolved. so you're good to proceed with all datasets, with the known issue the School Beacon selections will be out of date until we set up ETL. |
Thanks @johnclary! I'll finish out the nearby suggestions for the rest of the datasets this week. |
Populate a list of potential assets via Socrata point in radius API
The text was updated successfully, but these errors were encountered: