Created
April 11, 2014 09:43
-
-
Save anonymous/10454111 to your computer and use it in GitHub Desktop.
Validate geo coordinate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Checks given coordinate for errors | |
| * @param float $coordinate coordinate | |
| * | |
| * @return bool result | |
| */ | |
| public function checkCoordinate($coordinate) { | |
| if(preg_match('/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?);[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/', $coordinate)) { | |
| return true; | |
| } | |
| else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment