Get nearest roads to a given location, or all roads within a bounding box.
npm install nearest-roadsTherefore, this update now returns an array of objects - one for each road. Each road object contains the following fields:
* name: Name of the road (yes, would you believe it.)
* type: If the road is a [residential, tertiary, secondary, service, ...] road
oneway: true if the road is a oneway
lit: true if the road has lighting
lanes: No. of lanes the road has
maxspeed: The maximum permitted speed limit as an integer
N.B. Some of the fields of the road objects have been converted to a more programmatically consumable type when compared to OSM data.
I have also removed the array-unique dependency that this module used to have, as it is no longer relevant.
Finally, this completes the intended requirements that were laid out when I aimed to create this module. Hence due to breaking backwards compatibility, and _completing_ the intended functionality of this module, this is officially version 1.x
Now, there is support for getting all the roads inside a Bounding box.
npm install nearest-roads --save
const nearestRoads = require('nearest-roads');#### Nearest roads from a location: fromLocation(lat, long, distance, callback)
Returns an array containing the names of the roads that are within distance metres radius of lat long location.
```
nearestRoads.fromLocation(51.42, -0.148, 100, (err, data) => {
if (err) console.log(err);
else console.log(data);
});
#### Roads within a Bounding Box: boundingBox(northLat, eastLong, southLat, westLong, callback)
``
nearestRoads.boundingBox(51.5707755427, 0.922651543, 51.5046221724, 0.6790402342, (err, data) => {
if (err) console.log(err);
else console.log(data);
});
#### Example Return:
```
[ { name: 'Cuckoo Corner',
type: 'trunk',
oneway: true,
lit: true,
lanes: 2,
maxspeed: 40 },
{ name: 'Prince Avenue',
type: 'trunk',
oneway: true,
lit: true,
lanes: 2,
maxspeed: 40 },
{ name: 'Queensway',
type: 'primary',
oneway: true,
lit: true,
maxspeed: 40 },
{ name: 'Southchurch Avenue',
type: 'primary',
oneway: true,
lit: true,
maxspeed: 30 },
{ name: 'Prince Avenue',
type: 'trunk',
oneway: true,
lit: true,
lanes: 2,
maxspeed: 40 },
...
{ name: 'Eastern Avenue',
type: 'primary',
maxspeed: 30 },
... 1526 more items ]
This project adheres to the Airbnb JavaScript Style Guide.
Add unit tests for any new or changed functionality. Lint and test your code.