Created
April 22, 2012 21:04
-
-
Save raytiley/2466931 to your computer and use it in GitHub Desktop.
Design Phase 4 - Routes Controller Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// api/routes?start=300 main st boston&end=550 elm st boston&cost_table=popularity&route_type=cycle | |
app.get('api/routes', function(req,res){ | |
//Parse Request for parameters | |
var start = req.params.start, | |
end = req.params.end, | |
costTable = req.params.cost_table, | |
routeType = req.params.route_type; | |
//Geocode Start and End | |
geoCoder.geocode([start,end], function(geoCodedResponse){ | |
//Get Route from routingService | |
routingService.getRoute(geoCodedResponse[0].lat, | |
geoCodedResponse[0].lon, | |
geoCodedResponse[1].lat, | |
geoCodedResponse[1].lon, | |
routeType, | |
costTable, | |
function(route) { | |
//Send route as response to request | |
res.send(route); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment