aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorLeyla Jähnig <[email protected]>2022-10-15 00:01:49 +0200
committerGitHub <[email protected]>2022-10-14 22:01:49 +0000
commit476533697141f0e88c9eca300d0b5040dd8a09d7 (patch)
tree9122bc048b23bcb5ee2091c29b041e189e00e96e /src/modules
parenta90f2fe65c705a5593215b0a35945b77c1d575f1 (diff)
downloadfaker-476533697141f0e88c9eca300d0b5040dd8a09d7.tar.xz
faker-476533697141f0e88c9eca300d0b5040dd8a09d7.zip
feat(location)!: `nearbyGPSCoordinate` returns number tuple (#1061)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/address/index.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/modules/address/index.ts b/src/modules/address/index.ts
index f0ad8644..6221b551 100644
--- a/src/modules/address/index.ts
+++ b/src/modules/address/index.ts
@@ -383,9 +383,9 @@ export class AddressModule {
* @param isMetric If `true` assume the radius to be in kilometers. If `false` for miles. Defaults to `false`.
*
* @example
- * faker.address.nearbyGPSCoordinate() // [ '33.8475', '-170.5953' ]
- * faker.address.nearbyGPSCoordinate([33, -170]) // [ '33.0165', '-170.0636' ]
- * faker.address.nearbyGPSCoordinate([33, -170], 1000, true) // [ '37.9163', '-179.2408' ]
+ * faker.address.nearbyGPSCoordinate() // [ 33.8475, -170.5953 ]
+ * faker.address.nearbyGPSCoordinate([33, -170]) // [ 33.0165, -170.0636 ]
+ * faker.address.nearbyGPSCoordinate([33, -170], 1000, true) // [ 37.9163, -179.2408 ]
*
* @since 5.0.0
*/
@@ -393,10 +393,10 @@ export class AddressModule {
coordinate?: [latitude: number, longitude: number],
radius: number = 10,
isMetric: boolean = false
- ): [latitude: string, longitude: string] {
+ ): [latitude: number, longitude: number] {
// If there is no coordinate, the best we can do is return a random GPS coordinate.
if (coordinate === undefined) {
- return [this.latitude(), this.longitude()];
+ return [parseFloat(this.latitude()), parseFloat(this.longitude())];
}
const angleRadians = this.faker.datatype.float({
@@ -436,7 +436,7 @@ export class AddressModule {
// Box longitude [-180°, 180°]
newCoordinate[1] = (((newCoordinate[1] % 360) + 540) % 360) - 180;
- return [newCoordinate[0].toFixed(4), newCoordinate[1].toFixed(4)];
+ return [newCoordinate[0], newCoordinate[1]];
}
/**