Ejemplo n.º 1
0
 /**
  * @group unit-tests
  * @covers       \coordinate::getDecimalMinutes
  * @dataProvider formatProvider
  *
  * @return void
  */
 public function testFormatConversions($lat, $lon, $expectedMin, $expectedMinSec)
 {
     $coord = new \coordinate($lat, $lon);
     self::assertEquals($expectedMin, $coord->getDecimalMinutes());
     self::assertEquals($expectedMinSec, $coord->getDecimalMinutesSeconds());
 }
Ejemplo n.º 2
0
$tpl->name = 'coordinates';
$tpl->popup = true;
$lat_float = 0;
if (isset($_REQUEST['lat'])) {
    $lat_float += $_REQUEST['lat'];
}
$lon_float = 0;
if (isset($_REQUEST['lon'])) {
    $lon_float += $_REQUEST['lon'];
}
$cache_country = isset($_REQUEST['country']) ? $_REQUEST['country'] : false;
$cache_desclang = isset($_REQUEST['desclang']) ? $_REQUEST['desclang'] : false;
$coord = new coordinate($lat_float, $lon_float);
$tpl->assign('coordDeg', $coord->getDecimal());
$tpl->assign('coordDegMin', $coord->getDecimalMinutes());
$tpl->assign('coordDegMinSec', $coord->getDecimalMinutesSeconds());
$tpl->assign('coordUTM', $coord->getUTM());
$tpl->assign('coordGK', $coord->getGK());
$tpl->assign('coordRD', $coord->getRD());
$tpl->assign('showRD', $coord->nLat >= 45 && $coord->nLat <= 57 && $coord->nLon >= 0 && $coord->nLon <= 15);
$tpl->assign('coordQTH', $coord->getQTH());
$tpl->assign('coordSwissGrid', $coord->getSwissGrid());
// build priority list of W3W languages to display
// 1. current page locale
$w3w_langs = array();
if ($opt['locale'][$opt['template']['locale']]['what3words']) {
    $w3w_langs[] = $opt['template']['locale'];
}
// 2. language of the cache description
if ($cache_desclang && !in_array($cache_desclang, $w3w_langs)) {
    $w3w_langs[] = $cache_desclang;
Ejemplo n.º 3
0
 public function testFormatConversions()
 {
     $coord = new coordinate(51.52775, -120.8972);
     $decimalMin = $coord->getDecimalMinutes();
     $this->assertEquals("N 51° 31.665'", $decimalMin['lat']);
     $this->assertEquals("W 120° 53.832'", $decimalMin['lon']);
     $decimalMinSec = $coord->getDecimalMinutesSeconds();
     $this->assertEquals("N 51° 31' 39''", $decimalMinSec['lat']);
     $this->assertEquals("W 120° 53' 49''", $decimalMinSec['lon']);
     $coord = new coordinate(-8.81687, 13.24057);
     $decimalMin = $coord->getDecimalMinutes();
     $this->assertEquals("S 08° 49.012'", $decimalMin['lat']);
     $this->assertEquals("E 013° 14.434'", $decimalMin['lon']);
     $decimalMinSec = $coord->getDecimalMinutesSeconds();
     $this->assertEquals("S 08° 49' 00''", $decimalMinSec['lat']);
     $this->assertEquals("E 013° 14' 26''", $decimalMinSec['lon']);
     $coord = new coordinate(52.67578, 6.773);
     $decimalMin = $coord->getDecimalMinutes();
     $this->assertEquals("N 52° 40.547'", $decimalMin['lat']);
     $this->assertEquals("E 006° 46.380'", $decimalMin['lon']);
     $decimalMinSec = $coord->getDecimalMinutesSeconds();
     $this->assertEquals("N 52° 40' 32''", $decimalMinSec['lat']);
     $this->assertEquals("E 006° 46' 22''", $decimalMinSec['lon']);
     $coord = new coordinate(60.63367, 4.81313);
     $decimalMin = $coord->getDecimalMinutes();
     $this->assertEquals("N 60° 38.020'", $decimalMin['lat']);
     $this->assertEquals("E 004° 48.788'", $decimalMin['lon']);
     $decimalMinSec = $coord->getDecimalMinutesSeconds();
     $this->assertEquals("N 60° 38' 01''", $decimalMinSec['lat']);
     $this->assertEquals("E 004° 48' 47''", $decimalMinSec['lon']);
 }