diff --git a/readme.md b/readme.md
index bb9235165d..d09cd39ea0 100644
--- a/readme.md
+++ b/readme.md
@@ -106,21 +106,21 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle
### `Faker\Provider\en_US\Address`
- cityPrefix // 'Lake'
- secondaryAddress // 'Suite 961'
- state // 'NewMexico'
- stateAbbr // 'OH'
- citySuffix // 'borough'
- streetSuffix // 'Keys'
- buildingNumber // '484'
- city // 'West Judge'
- streetName // 'Keegan Trail'
- streetAddress // '439 Karley Loaf Suite 897'
- postcode // '17916'
- address // '8888 Cummings Vista Apt. 101, Susanbury, NY 95473'
- country // 'Falkland Islands (Malvinas)'
- latitude // 77.147489
- longitude // 86.211205
+ cityPrefix // 'Lake'
+ secondaryAddress // 'Suite 961'
+ state // 'NewMexico'
+ stateAbbr // 'OH'
+ citySuffix // 'borough'
+ streetSuffix // 'Keys'
+ buildingNumber // '484'
+ city // 'West Judge'
+ streetName // 'Keegan Trail'
+ streetAddress // '439 Karley Loaf Suite 897'
+ postcode // '17916'
+ address // '8888 Cummings Vista Apt. 101, Susanbury, NY 95473'
+ country // 'Falkland Islands (Malvinas)'
+ latitude($min = -90, $max = 90) // 77.147489
+ longitude($min = -180, $max = 180) // 86.211205
### `Faker\Provider\en_US\PhoneNumber`
diff --git a/src/Faker/Provider/Address.php b/src/Faker/Provider/Address.php
index c11b5b1ed9..6300ade106 100644
--- a/src/Faker/Provider/Address.php
+++ b/src/Faker/Provider/Address.php
@@ -104,20 +104,36 @@ public static function country()
}
/**
- * @example 77.147489
+ * @example '77.147489'
+ * @param float|int $min
+ * @param float|int $max
* @return float Uses signed degrees format (returns a float number between -90 and 90)
*/
- public static function latitude()
+ public static function latitude($min = -90, $max = 90)
{
- return static::randomFloat(6, 0, 180) - 90;
+ return static::randomFloat(6, $min, $max);
}
/**
- * @example 86.211205
+ * @example '86.211205'
+ * @param float|int $min
+ * @param float|int $max
* @return float Uses signed degrees format (returns a float number between -180 and 180)
*/
- public static function longitude()
+ public static function longitude($min = -180, $max = 180)
{
- return static::randomFloat(6, 0, 360) - 180;
+ return static::randomFloat(6, $min, $max);
+ }
+
+ /**
+ * @example array('77.147489', '86.211205')
+ * @return array | latitude, longitude
+ */
+ public static function localCoordinates()
+ {
+ return array(
+ 'latitude' => static::latitude(),
+ 'longitude' => static::longitude()
+ );
}
}
diff --git a/src/Faker/Provider/me_ME/Address.php b/src/Faker/Provider/me_ME/Address.php
index 5b9caf14f3..422207ea2b 100644
--- a/src/Faker/Provider/me_ME/Address.php
+++ b/src/Faker/Provider/me_ME/Address.php
@@ -109,19 +109,11 @@ public function cityName()
return static::randomElement(static::$cityNames);
}
- /**
- * @example '77.147489'
- */
- public static function latitude()
- {
- return number_format(mt_rand(42430000, 42450000)/1000000, 6);
- }
-
- /**
- * @example '86.211205'
- */
- public static function longitude()
+ public static function localCoordinates()
{
- return number_format(mt_rand(19260000, 19270000)/1000000, 6);
+ return array(
+ 'latitude' => static::latitude(42.43, 42.45),
+ 'longitude' => static::longitude(19.16, 19.27)
+ );
}
}
diff --git a/test/Faker/Provider/AddressTest.php b/test/Faker/Provider/AddressTest.php
index cbabce566d..5a5f66d4cc 100644
--- a/test/Faker/Provider/AddressTest.php
+++ b/test/Faker/Provider/AddressTest.php
@@ -31,4 +31,16 @@ public function testLongitude()
$this->assertGreaterThanOrEqual(-180, $longitude);
$this->assertLessThanOrEqual(180, $longitude);
}
+
+ public function testCoordinate()
+ {
+ $coordinate = $this->faker->localCoordinates();
+ $this->assertInternalType('array', $coordinate);
+ $this->assertInternalType('float', $coordinate['latitude']);
+ $this->assertGreaterThanOrEqual(-90, $coordinate['latitude']);
+ $this->assertLessThanOrEqual(90, $coordinate['latitude']);
+ $this->assertInternalType('float', $coordinate['longitude']);
+ $this->assertGreaterThanOrEqual(-180, $coordinate['longitude']);
+ $this->assertLessThanOrEqual(180, $coordinate['longitude']);
+ }
}
diff --git a/test/test.php b/test/test.php
index c238ab7192..9ca2c8ae56 100644
--- a/test/test.php
+++ b/test/test.php
@@ -1,6 +1,6 @@
seed(5);
@@ -18,6 +18,7 @@
city ?>
postcode ?>
state ?>
+ localCoordinates['latitude'].','.$faker->localCoordinates['longitude'] ?>
boolean(33)): ?>