dcfemtech / hackforgood-waba-map

DCFemTech Hack for Good 2016 - WABA Bike Map Project
MIT License
10 stars 9 forks source link

Remove Moco sharrows #56

Closed sara4844 closed 8 years ago

sara4844 commented 8 years ago

Moco bike lanes include sharrow paths. Need to remove it.

alulsh commented 8 years ago

From the Montgomery County BikeWays page:

Separated and marked bike lanes, bike-friendly shoulders, signed and sharrowed on-road routes, paved and natural surface trails in Montgomery County.

Looks like we should only include "separated and marked bike lanes" and "paved and natural surface trails" in our map. We don't want bike-friendly shoulders or sharrows.

We can write a JavaScript function to filter the GeoJSON file to only get trails and bike lanes and display these on the map.

sara4844 commented 8 years ago

I discovered that https://data.montgomerycountymd.gov/Transportation/Bikeways/icc2-ppee has an api that is well documented. I was able to send a query 'category=Bike Lanes' and the response was an accurate geoJson file.

var webUrl = "https://data.montgomerycountymd.gov/resource/972w-rnvw.json?";
var category = "category=Bike Lanes"; //Paved Off-Road Trail || Separated Bike Lanes || Natural Surface
var url = webUrl + category;

var xhr = new XMLHttpRequest();
xhr.addEventListener("load", getResponse);
xhr.open("Get", url, false);
xhr.send();
function getResponse() {
    console.log(this.response);
    var geoJson = this.response;
}

Is there a function through which I can add geoJson objects on a L.mapbox.featureLayer object? I tried doing it this way

`var mocoBikeLanes= L.mapbox.featureLayer(geoJson)
    .addTo(map);`

But i get this error image

@alulsh

alulsh commented 8 years ago

@sara4844 - mind pushing what you have in the comment above as a WIP (work in progress) branch to this repo? I can then take a look at the code and see what's going on!

Taking a look at sites.js on line 37, looks like you'd use loadURL() instead. I'd try something like:

var webUrl = "https://data.montgomerycountymd.gov/resource/972w-rnvw.json?";
var category = "category=Bike Lanes"; //Paved Off-Road Trail || Separated Bike Lanes || Natural Surface
var url = webUrl + category;

mocoBikeLanes.loadURL(url)
    .on('ready', loadBikeLanes);

We should change the webUrl and category variable names to be more specific so that we know they are for Montgomery County.

alulsh commented 8 years ago

@alongthepike - you filtered out the MoCo sharrows in https://github.com/dcfemtech/hackforgood-waba-map/pull/62/files but this was closed in favor of https://github.com/dcfemtech/hackforgood-waba-map/pull/71, which was a cleaner PR. https://github.com/dcfemtech/hackforgood-waba-map/pull/71 instead only added the PG county data.

Can you open a new, separate PR that filters out the sharrows from the MoCo bike lane data?

Though it would be nice to eventually fetch this data live from MoCo's website using AJAX calls, the mvp would be to have a static GeoJSON file with accurate data first.