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.
*
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']
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;
-}
}
$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 ';
# 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'));
$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
// 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));
- }
}