Skip to content
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

Closed
mateoclarke opened this issue Oct 1, 2018 · 9 comments · Fixed by #141
Closed

Select nearby assets based on your current location #30

mateoclarke opened this issue Oct 1, 2018 · 9 comments · Fixed by #141
Assignees
Labels
Project: Mobile Signal Work Order Service: Dev Infrastructure and engineering Type: Feature Request for new functionality in an existing application Workgroup: AMD Arterial Management Division
Milestone

Comments

@mateoclarke
Copy link
Contributor

mateoclarke commented Oct 1, 2018

Populate a list of potential assets via Socrata point in radius API

@mateoclarke mateoclarke created this issue from a note in React-Knack Mobile MVP (To do) Oct 1, 2018
@mateoclarke
Copy link
Contributor Author

@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.

@johnclary
Copy link
Member

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).

@johnclary
Copy link
Member

johnclary commented Oct 2, 2018

@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);
}

@mateoclarke mateoclarke added this to the Sprint 1 milestone Oct 9, 2018
@mateoclarke mateoclarke modified the milestones: Sprint 1, Sprint 2 Oct 24, 2018
@mateoclarke mateoclarke modified the milestones: Sprint 3, Sprint 4 Mar 5, 2019
@mateoclarke mateoclarke removed this from the Sprint 4 milestone Mar 21, 2019
@amenity amenity added Service: Dev Infrastructure and engineering Workgroup: AMD Arterial Management Division Type: Feature Request for new functionality in an existing application labels Jun 3, 2019
@mddilley mddilley self-assigned this Jul 24, 2019
@mddilley
Copy link
Contributor

mddilley commented Jul 26, 2019

@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
School Zone Beacons
Hazard Flashers
Digital Messaging Signs (small list so may not need this feature)
Sensors (also a smaller list)

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.

@johnclary
Copy link
Member

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.

Hazard Flashers

Traffic Cameras

School Zone Beacons

Dynamic Messaging Signs (DMS)

Travel Sensors

@mateoclarke mateoclarke added this to the Sprint 4 milestone Jul 29, 2019
@johnclary
Copy link
Member

johnclary commented Jul 29, 2019

I'm updating these datasets with a "Source DB" column (API name = id). Once this is done we'll need to force a refresh of the data from Knack.

DONE:

TODO:

@johnclary
Copy link
Member

Traffic Cameras and DMS are bugging out in the Socrata wizard. Opening an issue with Socrata.

@johnclary
Copy link
Member

@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.

@mddilley
Copy link
Contributor

mddilley commented Aug 5, 2019

Thanks @johnclary! I'll finish out the nearby suggestions for the rest of the datasets this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Project: Mobile Signal Work Order Service: Dev Infrastructure and engineering Type: Feature Request for new functionality in an existing application Workgroup: AMD Arterial Management Division
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants