-
Notifications
You must be signed in to change notification settings - Fork 3.6k
min / max for lat long values #570
Changes from 1 commit
b9f056d
321204f
f13d640
4a764d5
c3c586d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,20 +104,24 @@ public static function country() | |
} | ||
|
||
/** | ||
* @example 77.147489 | ||
* @return float Uses signed degrees format (returns a float number between -90 and 90) | ||
* @example '77.147489' | ||
* @param int $min | ||
* @param int $max | ||
* @return string | ||
*/ | ||
public static function latitude() | ||
public static function latitude($min = -90, $max = 90) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're changing the results of existing calls. Please use 0 and 180 as min and max values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. He isn't. Look again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad, you're right. |
||
{ | ||
return static::randomFloat(6, 0, 180) - 90; | ||
return number_format(mt_rand($min * 1000000, $max * 1000000)/1000000, 6); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why don't you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a coordinate, not a "just" float number. So I decided to update lat lng functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still, // not that clear
return mt_rand($min * 1000000, $max * 1000000)/1000000;
// better
return static::randomFloat(6, $min, $max); |
||
} | ||
|
||
/** | ||
* @example 86.211205 | ||
* @return float Uses signed degrees format (returns a float number between -180 and 180) | ||
* @example '86.211205' | ||
* @param int $min | ||
* @param int $max | ||
* @return string | ||
*/ | ||
public static function longitude() | ||
public static function longitude($min = -180, $max = 180) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're changing the results of existing calls. Please use 0 and 360 as min and max values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disregard. |
||
{ | ||
return static::randomFloat(6, 0, 360) - 180; | ||
return number_format(mt_rand($min * 1000000, $max * 1000000)/1000000, 6); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a
float
, not anint
, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing that, Phpstorm decided it, not me :)