public function test2() { echo "<pre>"; $latlng = new LatLng(21.827688, 90.279838); print_r($latlng->toUTMRef()); $latlng = new LatLng(49.004931, 114.269914); print_r($latlng->toUTMRef()); $latlng = new LatLng(36.251841, 126.780075); print_r($latlng->toUTMRef()); $latlng = new LatLng(9.739644, 128.546216); print_r($latlng->toUTMRef()); $latlng = new LatLng(39.915, 116.404); print_r($latlng->toUTMRef()); echo "</pre>"; }
<?php $utm1 = new UTMRef(456463.99, 3335334.05, "E", 12); echo "UTM Reference: " . $utm1->toString() . "<br />"; $ll3 = $utm1->toLatLng(); echo "Converted to Lat/Long: " . $ll3->toString(); ?> </p> <h2>Convert Latitude/Longitude to UTM Reference</h2> <p> <pre>$ll4 = new LatLng(-60.1167, -111.7833); echo "Latitude/Longitude: " . $ll4->toString() . "<br />"; $utm2 = $ll4->toUTMRef(); echo "Converted to UTM Ref: " . $utm2->toString() ;</pre> <?php $ll4 = new LatLng(-60.1167, -111.7833); echo "Latitude/Longitude: " . $ll4->toString() . "<br />"; $utm2 = $ll4->toUTMRef(); echo "Converted to UTM Ref: " . $utm2->toString(); ?> </p> <p> (c) 2005, Jonathan Stott </p> </body> </html>
/** * @expectedException \OutOfRangeException */ public function testUTMRefAntartic() { $LatLng = new LatLng(-80.00001, 123, RefEll::WGS84()); $UTMRef = $LatLng->toUTMRef(); }
function toUTM($coordsIn, $from = "") { // UTM converter - assume comma separator $temp = explode(",", $coordsIn); $coords = new LatLng(trim($temp[0]), trim($temp[1])); $utm = $coords->toUTMRef(); $temp = $utm->toString(); $temp1 = explode(" ", $temp); // parse by space $temp2 = explode(".", $temp1[1]); // parse by period $temp3 = explode(".", $temp1[2]); return $temp1[0] . " " . $temp2[0] . " " . $temp3[0]; }