Go to the source code of this file.
Defines function to standardize and validate coordinates.
Definition in file standard_coord.inc.
◆ tpps_standard_coord()
tpps_standard_coord |
( |
|
$raw_coordinate | ) |
|
This function returns a standardized set of coordinates from raw coordinates.
If the raw coordinates provided are invalid, the function returns false.
- Parameters
-
string | $raw_coordinate | The non-standard coordinates to be evaluated and standardized. |
- Returns
- mixed The coordinates in standardized form. False if coordinates were not valid.
Definition at line 19 of file standard_coord.inc.
21 if(stripos($raw_coordinate,
'‐') !== FALSE) {
23 $raw_coordinate = str_ireplace(
'‐',
'-', $raw_coordinate);
28 if (preg_match(
'/(([0-9]+)° ?([0-9]+)\' ?([0-9|\.]+)" ?([N|S])),? ?(([0-9]+)° ?([0-9]+)\' ?([0-9|\.]+)" ?([E|W]))/', $raw_coordinate, $matches)) {
29 $lat = $matches[2] + ($matches[3] / 60) + ($matches[4] / 3600);
30 $long = $matches[7] + ($matches[8] / 60) + ($matches[9] / 3600);
32 elseif (preg_match(
'/(([0-9]+)° ?([0-9|\.]+)\' ?([N|S])),? ?(([0-9]+)° ?([0-9|\.]+)\' ?([E|W]))/', $raw_coordinate, $matches)) {
33 $lat = $matches[2] + ($matches[3] / 60);
34 $long = $matches[6] + ($matches[7] / 60);
36 elseif (preg_match(
'/([0-9|\.]+), ?[\+|-]?([0-9|\.]+)/', $raw_coordinate, $matches)) {
40 elseif (preg_match(
'/([0-9|\.]+)°? ?([N|S]),? ?([0-9|\.]+)°? ?([E|W])/', $raw_coordinate, $matches)) {
48 if ($lat > 180 or $long > 180) {
52 if (preg_match(
'/(-).+,/', $raw_coordinate, $matches)) {
55 if (preg_match(
'/,.*(-)/', $raw_coordinate, $matches)) {
59 if (preg_match(
'/([N|S]).+([E|W])/', $raw_coordinate, $matches)) {
60 if ($matches[1] ==
'S') {
63 if ($matches[2] ==
'W') {