From 153dbb71b8fe632c3cbda3834b012bf9db77d365 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 17 Feb 2021 22:25:23 +0100 Subject: [PATCH] remove unused code --- lib-php/DB.php | 10 ---------- lib-php/lib.php | 33 --------------------------------- lib-php/website/details.php | 1 - test/php/Nominatim/DBTest.php | 12 ------------ test/php/Nominatim/LibTest.php | 28 ---------------------------- 5 files changed, 84 deletions(-) diff --git a/lib-php/DB.php b/lib-php/DB.php index 0454a0ff..c25c5ca9 100644 --- a/lib-php/DB.php +++ b/lib-php/DB.php @@ -240,16 +240,6 @@ class DB return ($this->getOne($sSQL, array(':tablename' => $sTableName)) == 1); } - /** - * Returns a list of table names in the database - * - * @return array[] - */ - public function getListOfTables() - { - return $this->getCol("SELECT tablename FROM pg_tables WHERE schemaname='public'"); - } - /** * Deletes a table. Returns true if deleted or didn't exist. * diff --git a/lib-php/lib.php b/lib-php/lib.php index 6798e749..89b54363 100644 --- a/lib-php/lib.php +++ b/lib-php/lib.php @@ -226,17 +226,6 @@ function parseLatLon($sQuery) return array($sFound, $fQueryLat, $fQueryLon); } -function createPointsAroundCenter($fLon, $fLat, $fRadius) -{ - $iSteps = max(8, min(100, ($fRadius * 40000)^2)); - $fStepSize = (2*pi())/$iSteps; - $aPolyPoints = array(); - for ($f = 0; $f < 2*pi(); $f += $fStepSize) { - $aPolyPoints[] = array('', $fLon+($fRadius*sin($f)), $fLat+($fRadius*cos($f)) ); - } - return $aPolyPoints; -} - function closestHouseNumber($aRow) { $fHouse = $aRow['startnumber'] @@ -256,25 +245,3 @@ function closestHouseNumber($aRow) return max(min($aRow['endnumber'], $iHn), $aRow['startnumber']); } - -function getSearchRankLabel($iRank) -{ - if (!isset($iRank)) return 'unknown'; - if ($iRank < 2) return 'continent'; - if ($iRank < 4) return 'sea'; - if ($iRank < 8) return 'country'; - if ($iRank < 12) return 'state'; - if ($iRank < 16) return 'county'; - if ($iRank == 16) return 'city'; - if ($iRank == 17) return 'town / island'; - if ($iRank == 18) return 'village / hamlet'; - if ($iRank == 20) return 'suburb'; - if ($iRank == 21) return 'postcode area'; - if ($iRank == 22) return 'croft / farm / locality / islet'; - if ($iRank == 23) return 'postcode area'; - if ($iRank == 25) return 'postcode point'; - if ($iRank == 26) return 'street / major landmark'; - if ($iRank == 27) return 'minory street / path'; - if ($iRank == 28) return 'house / building'; - return 'other: ' . $iRank; -} diff --git a/lib-php/website/details.php b/lib-php/website/details.php index 91440b54..8e350a8c 100644 --- a/lib-php/website/details.php +++ b/lib-php/website/details.php @@ -144,7 +144,6 @@ if (!$aPointDetails) { } $aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber']; -$aPointDetails['rank_search_label'] = getSearchRankLabel($aPointDetails['rank_search']); // only used in HTML format // Get all alternative names (languages, etc) $sSQL = 'SELECT (each(name)).key,(each(name)).value FROM placex '; diff --git a/test/php/Nominatim/DBTest.php b/test/php/Nominatim/DBTest.php index 8a3157a8..c5f4f395 100644 --- a/test/php/Nominatim/DBTest.php +++ b/test/php/Nominatim/DBTest.php @@ -159,19 +159,7 @@ class DBTest extends \PHPUnit\Framework\TestCase # Tables, Indices { - $this->assertEmpty($oDB->getListOfTables()); $oDB->exec('CREATE TABLE table1 (id integer, city varchar, country varchar)'); - $oDB->exec('CREATE TABLE table2 (id integer, city varchar, country varchar)'); - $this->assertEquals( - array('table1', 'table2'), - $oDB->getListOfTables() - ); - $this->assertTrue($oDB->deleteTable('table2')); - $this->assertTrue($oDB->deleteTable('table99')); - $this->assertEquals( - array('table1'), - $oDB->getListOfTables() - ); $this->assertTrue($oDB->tableExists('table1')); $this->assertFalse($oDB->tableExists('table99')); diff --git a/test/php/Nominatim/LibTest.php b/test/php/Nominatim/LibTest.php index 6e9038ee..5111b326 100644 --- a/test/php/Nominatim/LibTest.php +++ b/test/php/Nominatim/LibTest.php @@ -15,26 +15,6 @@ class LibTest extends \PHPUnit\Framework\TestCase $this->assertSame("''", addQuotes('')); } - - public function testCreatePointsAroundCenter() - { - // you might say we're creating a circle - $aPoints = createPointsAroundCenter(0, 0, 2); - - $this->assertEquals( - 101, - count($aPoints) - ); - $this->assertEquals( - array( - array('', 0, 2), - array('', 0.12558103905863, 1.9960534568565), - array('', 0.25066646712861, 1.984229402629) - ), - array_splice($aPoints, 0, 3) - ); - } - public function testParseLatLon() { // no coordinates expected @@ -132,12 +112,4 @@ class LibTest extends \PHPUnit\Framework\TestCase // start == end $this->closestHouseNumberEvenOddOther(50, 50, 0.5, array('even' => 50, 'odd' => 50, 'other' => 50)); } - - public function testGetSearchRankLabel() - { - $this->assertEquals('unknown', getSearchRankLabel(null)); - $this->assertEquals('continent', getSearchRankLabel(0)); - $this->assertEquals('continent', getSearchRankLabel(1)); - $this->assertEquals('other: 30', getSearchRankLabel(30)); - } } -- 2.39.5