Convert decimals coordinates to wgs84 using PHP

Enjoy!

function wgs84($n) {

	$one = substr($n, 0, 2);

	list($first, $second) = explode('.', $n);

		list($two, $none) = explode('.', (('0.' . $second) * 60));
		$tworaw = ('0.' . $second) * 60;

	list($first, $second) = explode('.', $tworaw);

		list($three, $none) = explode('.', (('0.' . $second) * 60));

	return $one . '° ' . $two . '′ ' . $three . '″';
}

$decimal = '59.2943';

print wgs84($decimal); // 59° 17′ 39″
Det här inlägget postades i Okategoriserade. Bokmärk permalänken.

Ett svar till Convert decimals coordinates to wgs84 using PHP

  1. pharmacy tech skriver:

    Wow this is a great resource.. I’m enjoying it.. good article

Lämna ett svar

E-postadressen publiceras inte. Obligatoriska fält är märkta *

*

Följande HTML-taggar och attribut är tillåtna: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>