diff options
| author | Vivek Seth <[email protected]> | 2016-05-05 14:52:13 -0400 |
|---|---|---|
| committer | Vivek Seth <[email protected]> | 2016-05-05 14:52:13 -0400 |
| commit | e8f51dcddd2586fcce12635850a6692b414869ef (patch) | |
| tree | 52e6ede794123b4f9aa2cae9011117127527f543 /lib | |
| parent | ec5e7ca44299c7e19721d0de8dde499cab7021e8 (diff) | |
| download | faker-e8f51dcddd2586fcce12635850a6692b414869ef.tar.xz faker-e8f51dcddd2586fcce12635850a6692b414869ef.zip | |
Use term 'coordinate' instead of 'location'
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/address.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/address.js b/lib/address.js index dec80d8f..6d9748fd 100644 --- a/lib/address.js +++ b/lib/address.js @@ -103,7 +103,7 @@ var address = { return (faker.random.number(360 * 10000) / 10000.0 - 180.0).toFixed(4); }, - nearbyLocation: function(location, radius, isMetric) { + nearbyGPSCoordinate: function(coordinate, radius, isMetric) { function randomFloat(min, max) { return Math.random() * (max-min) + min; } @@ -116,12 +116,12 @@ var address = { function kilometersToMiles(miles) { return miles * 0.621371; } - function boundaryLocation(location, bearing, distance, isMetric) { + function boundaryCoordinate(coordinate, bearing, distance, isMetric) { var R = 6378.137; // Radius of the Earth (http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html) var d = isMetric ? distance : kilometersToMiles(distance); // Distance in km - lat1 = degreesToRadians(location[0]); //Current lat point converted to radians - lon1 = degreesToRadians(location[1]); //Current long point converted to radians + lat1 = degreesToRadians(coordinate[0]); //Current lat point converted to radians + lon1 = degreesToRadians(coordinate[1]); //Current long point converted to radians lat2 = Math.asin(Math.sin(lat1) * Math.cos(d/R) + Math.cos(lat1) * Math.sin(d/R) * Math.cos(bearing)); @@ -137,9 +137,9 @@ var address = { radius = radius || 10.0; isMetric = isMetric || false; - // This is a heuristic to approximate the circular region defined by location and radius. - topLeftBoundary = boundaryLocation(location, degreesToRadians(45), radius, isMetric); - bottomRightBoundary = boundaryLocation(location, degreesToRadians(45), -radius, isMetric); + // This is a heuristic to approximate the circular region defined by coordinate and radius. + topLeftBoundary = boundaryCoordinate(coordinate, degreesToRadians(45), radius, isMetric); + bottomRightBoundary = boundaryCoordinate(coordinate, degreesToRadians(45), -radius, isMetric); randLat = randomFloat(topLeftBoundary[0], bottomRightBoundary[0]).toFixed(4); randLong = randomFloat(topLeftBoundary[1], bottomRightBoundary[1]).toFixed(4); |
