/** * @group unit-tests * @covers \coordinate::getSwissGrid() * @dataProvider swissGridProvider * * @return void */ public function testSwissGrid($lat, $lon, $expectedSG) { $coord = new \coordinate($lat, $lon); $swissGrid = $coord->getSwissGrid(); self::assertEquals($expectedSG, $swissGrid['coord']); }
$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; } // 3. primary language of the cache's country if ($cache_country) { foreach ($opt['locale'] as $l => $data) { if ($data['what3words'] && in_array($cache_country, $data['primary_lang_of']) && !in_array($l, $w3w_langs)) { $w3w_langs[] = $l;
public function testSwissGrid() { $coord = new coordinate(51.52775, -120.8972); $swissGrid = $coord->getSwissGrid(); $this->assertEquals('-3944504 / 8019927', $swissGrid['coord']); $coord = new coordinate(-8.81687, 13.24057); $swissGrid = $coord->getSwissGrid(); $this->assertEquals('1499586 / -6904936', $swissGrid['coord']); $coord = new coordinate(52.67578, 6.773); $swissGrid = $coord->getSwissGrid(); $this->assertEquals('554738 / 837985', $swissGrid['coord']); $coord = new coordinate(60.63367, 4.81313); $swissGrid = $coord->getSwissGrid(); $this->assertEquals('451121 / 1739767', $swissGrid['coord']); }