forked from hans/Nominatim
fix indentation and misc errors according to PSR2 coding style guide
This commit is contained in:
@@ -48,6 +48,7 @@ class Geocode
|
|||||||
protected $sQuery = false;
|
protected $sQuery = false;
|
||||||
protected $aStructuredQuery = false;
|
protected $aStructuredQuery = false;
|
||||||
|
|
||||||
|
|
||||||
function Geocode(&$oDB)
|
function Geocode(&$oDB)
|
||||||
{
|
{
|
||||||
$this->oDB =& $oDB;
|
$this->oDB =& $oDB;
|
||||||
@@ -476,7 +477,8 @@ class Geocode
|
|||||||
|
|
||||||
$sSQL .= " order by importance desc";
|
$sSQL .= " order by importance desc";
|
||||||
if (CONST_Debug) {
|
if (CONST_Debug) {
|
||||||
echo "<hr>"; var_dump($sSQL);
|
echo "<hr>";
|
||||||
|
var_dump($sSQL);
|
||||||
}
|
}
|
||||||
$aSearchResults = chksql(
|
$aSearchResults = chksql(
|
||||||
$this->oDB->getAll($sSQL),
|
$this->oDB->getAll($sSQL),
|
||||||
@@ -738,6 +740,8 @@ class Geocode
|
|||||||
name: full name (currently the same as langaddress)
|
name: full name (currently the same as langaddress)
|
||||||
foundorder: secondary ordering for places with same importance
|
foundorder: secondary ordering for places with same importance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function lookup()
|
function lookup()
|
||||||
{
|
{
|
||||||
if (!$this->sQuery && !$this->aStructuredQuery) return false;
|
if (!$this->sQuery && !$this->aStructuredQuery) return false;
|
||||||
@@ -1413,7 +1417,8 @@ class Geocode
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CONST_Debug) {
|
if (CONST_Debug) {
|
||||||
echo "<br><b>Place IDs:</b> "; var_Dump($aPlaceIDs);
|
echo "<br><b>Place IDs:</b> ";
|
||||||
|
var_Dump($aPlaceIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($aPlaceIDs as $iPlaceID) {
|
foreach ($aPlaceIDs as $iPlaceID) {
|
||||||
@@ -1495,7 +1500,8 @@ class Geocode
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CONST_Debug) {
|
if (CONST_Debug) {
|
||||||
echo '<i>Recheck words:<\i>'; var_dump($aRecheckWords);
|
echo '<i>Recheck words:<\i>';
|
||||||
|
var_dump($aRecheckWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oPlaceLookup = new PlaceLookup($this->oDB);
|
$oPlaceLookup = new PlaceLookup($this->oDB);
|
||||||
@@ -1625,9 +1631,5 @@ class Geocode
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $aSearchResults;
|
return $aSearchResults;
|
||||||
|
|
||||||
} // end lookup()
|
} // end lookup()
|
||||||
|
|
||||||
|
|
||||||
} // end class
|
} // end class
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ class ParameterParser
|
|||||||
{
|
{
|
||||||
private $aParams;
|
private $aParams;
|
||||||
|
|
||||||
function __construct($aParams = NULL)
|
|
||||||
|
function __construct($aParams = null)
|
||||||
{
|
{
|
||||||
$this->aParams = ($aParams === NULL) ? $_GET : $aParams;
|
$this->aParams = ($aParams === null) ? $_GET : $aParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBool($sName, $bDefault = false)
|
function getBool($sName, $bDefault = false)
|
||||||
@@ -77,9 +78,9 @@ class ParameterParser
|
|||||||
return $aDefault;
|
return $aDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreferredLanguages($sFallback = NULL)
|
function getPreferredLanguages($sFallback = null)
|
||||||
{
|
{
|
||||||
if ($sFallback === NULL && isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
|
if ($sFallback === null && isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
|
||||||
$sFallback = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
|
$sFallback = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,15 +237,18 @@ class PlaceLookup
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// returns an array which will contain the keys
|
/* returns an array which will contain the keys
|
||||||
// aBoundingBox
|
* aBoundingBox
|
||||||
// and may also contain one or more of the keys
|
* and may also contain one or more of the keys
|
||||||
// asgeojson
|
* asgeojson
|
||||||
// askml
|
* askml
|
||||||
// assvg
|
* assvg
|
||||||
// astext
|
* astext
|
||||||
// lat
|
* lat
|
||||||
// lon
|
* lon
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
function getOutlines($iPlaceID, $fLon = null, $fLat = null, $fRadius = null)
|
function getOutlines($iPlaceID, $fLon = null, $fLat = null, $fRadius = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -301,7 +304,7 @@ class PlaceLookup
|
|||||||
(string)$aPointPolygon['maxlon']
|
(string)$aPointPolygon['maxlon']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} // CONST_Search_AreaPolygons
|
}
|
||||||
|
|
||||||
// as a fallback we generate a bounding box without knowing the size of the geometry
|
// as a fallback we generate a bounding box without knowing the size of the geometry
|
||||||
if ((!isset($aOutlineResult['aBoundingBox'])) && isset($fLon)) {
|
if ((!isset($aOutlineResult['aBoundingBox'])) && isset($fLon)) {
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ class ReverseGeocode
|
|||||||
protected $oDB;
|
protected $oDB;
|
||||||
protected $iMaxRank = 28;
|
protected $iMaxRank = 28;
|
||||||
|
|
||||||
|
|
||||||
function ReverseGeocode(&$oDB)
|
function ReverseGeocode(&$oDB)
|
||||||
{
|
{
|
||||||
$this->oDB =& $oDB;
|
$this->oDB =& $oDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setZoom($iZoom)
|
function setZoom($iZoom)
|
||||||
{
|
{
|
||||||
// Zoom to rank, this could probably be calculated but a lookup gives fine control
|
// Zoom to rank, this could probably be calculated but a lookup gives fine control
|
||||||
@@ -38,8 +40,13 @@ class ReverseGeocode
|
|||||||
$this->iMaxRank = (isset($iZoom) && isset($aZoomRank[$iZoom]))?$aZoomRank[$iZoom]:28;
|
$this->iMaxRank = (isset($iZoom) && isset($aZoomRank[$iZoom]))?$aZoomRank[$iZoom]:28;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns { place_id =>, type => '(osm|tiger)' }
|
|
||||||
// fails if no place was found
|
/* lookup()
|
||||||
|
* returns { place_id =>, type => '(osm|tiger)' }
|
||||||
|
* fails if no place was found
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
function lookup($fLat, $fLon, $bDoInterpolation = true)
|
function lookup($fLat, $fLon, $bDoInterpolation = true)
|
||||||
{
|
{
|
||||||
$sPointSQL = 'ST_SetSRID(ST_Point('.$fLon.','.$fLat.'),4326)';
|
$sPointSQL = 'ST_SetSRID(ST_Point('.$fLon.','.$fLat.'),4326)';
|
||||||
@@ -204,5 +211,4 @@ class ReverseGeocode
|
|||||||
'fraction' => ($bPlaceIsTiger || $bPlaceIsLine) ? $fFraction : -1
|
'fraction' => ($bPlaceIsTiger || $bPlaceIsLine) ? $fFraction : -1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnknown = false)
|
function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnknown = false)
|
||||||
{
|
{
|
||||||
$aQuick = array();
|
$aQuick = array();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require_once('DB.php');
|
require_once('DB.php');
|
||||||
|
|
||||||
|
|
||||||
function &getDB($bNew = false, $bPersistent = false)
|
function &getDB($bNew = false, $bPersistent = false)
|
||||||
{
|
{
|
||||||
// Get the database object
|
// Get the database object
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ require_once('ParameterParser.php');
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function chksql($oSql, $sMsg = "Database request failed")
|
function chksql($oSql, $sMsg = "Database request failed")
|
||||||
{
|
{
|
||||||
if (!PEAR::isError($oSql)) return $oSql;
|
if (!PEAR::isError($oSql)) return $oSql;
|
||||||
@@ -95,4 +96,3 @@ if (CONST_NoAccessControl) {
|
|||||||
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
|
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
|
||||||
|
|
||||||
if (CONST_Debug) header('Content-type: text/html; charset=utf-8');
|
if (CONST_Debug) header('Content-type: text/html; charset=utf-8');
|
||||||
|
|
||||||
|
|||||||
71
lib/lib.php
71
lib/lib.php
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function fail($sError, $sUserError = false)
|
function fail($sError, $sUserError = false)
|
||||||
{
|
{
|
||||||
if (!$sUserError) $sUserError = $sError;
|
if (!$sUserError) $sUserError = $sError;
|
||||||
@@ -98,10 +99,6 @@ function getTokensFromSets($aSets)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
GB Postcode functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
function gbPostcodeCalculate($sPostcode, $sPostcodeSector, $sPostcodeEnd, &$oDB)
|
function gbPostcodeCalculate($sPostcode, $sPostcodeSector, $sPostcodeEnd, &$oDB)
|
||||||
{
|
{
|
||||||
// Try an exact match on the gb_postcode table
|
// Try an exact match on the gb_postcode table
|
||||||
@@ -599,72 +596,78 @@ function addQuotes($s)
|
|||||||
return "'".$s."'";
|
return "'".$s."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns boolean
|
|
||||||
function validLatLon($fLat, $fLon)
|
function validLatLon($fLat, $fLon)
|
||||||
{
|
{
|
||||||
return ($fLat <= 90.1 && $fLat >= -90.1 && $fLon <= 180.1 && $fLon >= -180.1);
|
return ($fLat <= 90.1 && $fLat >= -90.1 && $fLon <= 180.1 && $fLon >= -180.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function looksLikeLatLonPair($sQuery)
|
||||||
|
{
|
||||||
// Do we have anything that looks like a lat/lon pair?
|
// Do we have anything that looks like a lat/lon pair?
|
||||||
// returns array(lat,lon,query_with_lat_lon_removed)
|
// returns array(lat,lon,query_with_lat_lon_removed)
|
||||||
// or null
|
// or null
|
||||||
function looksLikeLatLonPair($sQuery)
|
|
||||||
{
|
|
||||||
$sFound = null;
|
$sFound = null;
|
||||||
$fQueryLat = null;
|
$fQueryLat = null;
|
||||||
$fQueryLon = null;
|
$fQueryLon = null;
|
||||||
|
|
||||||
if (preg_match('/\\b([NS])[ ]+([0-9]+[0-9.]*)[° ]+([0-9.]+)?[′\']*[, ]+([EW])[ ]+([0-9]+)[° ]+([0-9]+[0-9.]*)[′\']*?\\b/', $sQuery, $aData)) {
|
if (preg_match('/\\b([NS])[ ]+([0-9]+[0-9.]*)[° ]+([0-9.]+)?[′\']*[, ]+([EW])[ ]+([0-9]+)[° ]+([0-9]+[0-9.]*)[′\']*?\\b/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4 5 6
|
/* 1 2 3 4 5 6
|
||||||
// degrees decimal minutes
|
* degrees decimal minutes
|
||||||
// N 40 26.767, W 79 58.933
|
* N 40 26.767, W 79 58.933
|
||||||
// N 40°26.767′, W 79°58.933′
|
* N 40°26.767′, W 79°58.933′
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2] + $aData[3]/60);
|
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2] + $aData[3]/60);
|
||||||
$fQueryLon = ($aData[4]=='E'?1:-1) * ($aData[5] + $aData[6]/60);
|
$fQueryLon = ($aData[4]=='E'?1:-1) * ($aData[5] + $aData[6]/60);
|
||||||
} elseif (preg_match('/\\b([0-9]+)[° ]+([0-9]+[0-9.]*)?[′\']*[ ]+([NS])[, ]+([0-9]+)[° ]+([0-9]+[0-9.]*)?[′\' ]+([EW])\\b/', $sQuery, $aData)) {
|
} elseif (preg_match('/\\b([0-9]+)[° ]+([0-9]+[0-9.]*)?[′\']*[ ]+([NS])[, ]+([0-9]+)[° ]+([0-9]+[0-9.]*)?[′\' ]+([EW])\\b/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4 5 6
|
/* 1 2 3 4 5 6
|
||||||
// degrees decimal minutes
|
* degrees decimal minutes
|
||||||
// 40 26.767 N, 79 58.933 W
|
* 40 26.767 N, 79 58.933 W
|
||||||
// 40° 26.767′ N 79° 58.933′ W
|
* 40° 26.767′ N 79° 58.933′ W
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = ($aData[3]=='N'?1:-1) * ($aData[1] + $aData[2]/60);
|
$fQueryLat = ($aData[3]=='N'?1:-1) * ($aData[1] + $aData[2]/60);
|
||||||
$fQueryLon = ($aData[6]=='E'?1:-1) * ($aData[4] + $aData[5]/60);
|
$fQueryLon = ($aData[6]=='E'?1:-1) * ($aData[4] + $aData[5]/60);
|
||||||
} elseif (preg_match('/\\b([NS])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*[, ]+([EW])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*\\b/', $sQuery, $aData)) {
|
} elseif (preg_match('/\\b([NS])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*[, ]+([EW])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*\\b/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4 5 6 7 8
|
/* 1 2 3 4 5 6 7 8
|
||||||
// degrees decimal seconds
|
* degrees decimal seconds
|
||||||
// N 40 26 46 W 79 58 56
|
* N 40 26 46 W 79 58 56
|
||||||
// N 40° 26′ 46″, W 79° 58′ 56″
|
* N 40° 26′ 46″, W 79° 58′ 56″
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2] + $aData[3]/60 + $aData[4]/3600);
|
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2] + $aData[3]/60 + $aData[4]/3600);
|
||||||
$fQueryLon = ($aData[5]=='E'?1:-1) * ($aData[6] + $aData[7]/60 + $aData[8]/3600);
|
$fQueryLon = ($aData[5]=='E'?1:-1) * ($aData[6] + $aData[7]/60 + $aData[8]/3600);
|
||||||
} elseif (preg_match('/\\b([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″" ]+([NS])[, ]+([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″" ]+([EW])\\b/', $sQuery, $aData)) {
|
} elseif (preg_match('/\\b([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″" ]+([NS])[, ]+([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″" ]+([EW])\\b/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4 5 6 7 8
|
/* 1 2 3 4 5 6 7 8
|
||||||
// degrees decimal seconds
|
* degrees decimal seconds
|
||||||
// 40 26 46 N 79 58 56 W
|
* 40 26 46 N 79 58 56 W
|
||||||
// 40° 26′ 46″ N, 79° 58′ 56″ W
|
* 40° 26′ 46″ N, 79° 58′ 56″ W
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = ($aData[4]=='N'?1:-1) * ($aData[1] + $aData[2]/60 + $aData[3]/3600);
|
$fQueryLat = ($aData[4]=='N'?1:-1) * ($aData[1] + $aData[2]/60 + $aData[3]/3600);
|
||||||
$fQueryLon = ($aData[8]=='E'?1:-1) * ($aData[5] + $aData[6]/60 + $aData[7]/3600);
|
$fQueryLon = ($aData[8]=='E'?1:-1) * ($aData[5] + $aData[6]/60 + $aData[7]/3600);
|
||||||
} elseif (preg_match('/\\b([NS])[ ]([0-9]+[0-9]*\\.[0-9]+)[°]*[, ]+([EW])[ ]([0-9]+[0-9]*\\.[0-9]+)[°]*\\b/', $sQuery, $aData)) {
|
} elseif (preg_match('/\\b([NS])[ ]([0-9]+[0-9]*\\.[0-9]+)[°]*[, ]+([EW])[ ]([0-9]+[0-9]*\\.[0-9]+)[°]*\\b/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4
|
/* 1 2 3 4
|
||||||
// degrees decimal
|
* degrees decimal
|
||||||
// N 40.446° W 79.982°
|
* N 40.446° W 79.982°
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2]);
|
$fQueryLat = ($aData[1]=='N'?1:-1) * ($aData[2]);
|
||||||
$fQueryLon = ($aData[3]=='E'?1:-1) * ($aData[4]);
|
$fQueryLon = ($aData[3]=='E'?1:-1) * ($aData[4]);
|
||||||
} elseif (preg_match('/\\b([0-9]+[0-9]*\\.[0-9]+)[° ]+([NS])[, ]+([0-9]+[0-9]*\\.[0-9]+)[° ]+([EW])\\b/', $sQuery, $aData)) {
|
} elseif (preg_match('/\\b([0-9]+[0-9]*\\.[0-9]+)[° ]+([NS])[, ]+([0-9]+[0-9]*\\.[0-9]+)[° ]+([EW])\\b/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4
|
/* 1 2 3 4
|
||||||
// degrees decimal
|
* degrees decimal
|
||||||
// 40.446° N 79.982° W
|
* 40.446° N 79.982° W
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = ($aData[2]=='N'?1:-1) * ($aData[1]);
|
$fQueryLat = ($aData[2]=='N'?1:-1) * ($aData[1]);
|
||||||
$fQueryLon = ($aData[4]=='E'?1:-1) * ($aData[3]);
|
$fQueryLon = ($aData[4]=='E'?1:-1) * ($aData[3]);
|
||||||
} elseif (preg_match('/(\\[|^|\\b)(-?[0-9]+[0-9]*\\.[0-9]+)[, ]+(-?[0-9]+[0-9]*\\.[0-9]+)(\\]|$|\\b)/', $sQuery, $aData)) {
|
} elseif (preg_match('/(\\[|^|\\b)(-?[0-9]+[0-9]*\\.[0-9]+)[, ]+(-?[0-9]+[0-9]*\\.[0-9]+)(\\]|$|\\b)/', $sQuery, $aData)) {
|
||||||
// 1 2 3 4
|
/* 1 2 3 4
|
||||||
// degrees decimal
|
* degrees decimal
|
||||||
// 12.34, 56.78
|
* 12.34, 56.78
|
||||||
// [12.456,-78.90]
|
* [12.456,-78.90]
|
||||||
|
*/
|
||||||
$sFound = $aData[0];
|
$sFound = $aData[0];
|
||||||
$fQueryLat = $aData[2];
|
$fQueryLat = $aData[2];
|
||||||
$fQueryLon = $aData[3];
|
$fQueryLon = $aData[3];
|
||||||
@@ -679,7 +682,7 @@ function looksLikeLatLonPair($sQuery)
|
|||||||
|
|
||||||
function geometryText2Points($geometry_as_text, $fRadius)
|
function geometryText2Points($geometry_as_text, $fRadius)
|
||||||
{
|
{
|
||||||
$aPolyPoints = NULL;
|
$aPolyPoints = null;
|
||||||
if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
|
if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
|
||||||
//
|
//
|
||||||
preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
|
preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
|
function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
|
||||||
{
|
{
|
||||||
$fStartTime = microtime(true);
|
$fStartTime = microtime(true);
|
||||||
@@ -70,5 +71,4 @@ function logEnd(&$oDB, $hLog, $iNumResults)
|
|||||||
);
|
);
|
||||||
file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);
|
file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function formatOSMType($sType, $bIncludeExternal = true)
|
function formatOSMType($sType, $bIncludeExternal = true)
|
||||||
{
|
{
|
||||||
if ($sType == 'N') return 'node';
|
if ($sType == 'N') return 'node';
|
||||||
@@ -38,4 +39,3 @@ function detailsLink($aFeature, $sTitle = false)
|
|||||||
|
|
||||||
return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
|
return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,12 +90,14 @@ EOD;
|
|||||||
$oDB->query($sSQL);
|
$oDB->query($sSQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function degreesAndMinutesToDecimal($iDegrees, $iMinutes = 0, $fSeconds = 0, $sNSEW = 'N')
|
function degreesAndMinutesToDecimal($iDegrees, $iMinutes = 0, $fSeconds = 0, $sNSEW = 'N')
|
||||||
{
|
{
|
||||||
$sNSEW = strtoupper($sNSEW);
|
$sNSEW = strtoupper($sNSEW);
|
||||||
return ($sNSEW == 'S' || $sNSEW == 'W'?-1:1) * ((float)$iDegrees + (float)$iMinutes/60 + (float)$fSeconds/3600);
|
return ($sNSEW == 'S' || $sNSEW == 'W'?-1:1) * ((float)$iDegrees + (float)$iMinutes/60 + (float)$fSeconds/3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _parseWikipediaContent($sPageText)
|
function _parseWikipediaContent($sPageText)
|
||||||
{
|
{
|
||||||
$sPageText = str_replace("\n", ' ', $sPageText);
|
$sPageText = str_replace("\n", ' ', $sPageText);
|
||||||
@@ -201,7 +203,7 @@ function _templatesToProperties($aTemplates)
|
|||||||
foreach ($aTemplates as $iTemplate => $aTemplate) {
|
foreach ($aTemplates as $iTemplate => $aTemplate) {
|
||||||
$aParams = array();
|
$aParams = array();
|
||||||
foreach (array_reverse($aTemplate[1]) as $iParam => $sParam) {
|
foreach (array_reverse($aTemplate[1]) as $iParam => $sParam) {
|
||||||
if (($iPos = strpos($sParam, '=')) === FALSE) {
|
if (($iPos = strpos($sParam, '=')) === false) {
|
||||||
$aParams[] = trim($sParam);
|
$aParams[] = trim($sParam);
|
||||||
} else {
|
} else {
|
||||||
$aParams[trim(substr($sParam, 0, $iPos))] = trim(substr($sParam, $iPos+1));
|
$aParams[trim(substr($sParam, 0, $iPos))] = trim(substr($sParam, $iPos+1));
|
||||||
@@ -224,7 +226,7 @@ function _templatesToProperties($aTemplates)
|
|||||||
if (!isset($aPageProperties['sWebsite']) && isset($aParams['website']) && $aParams['website']) {
|
if (!isset($aPageProperties['sWebsite']) && isset($aParams['website']) && $aParams['website']) {
|
||||||
if (preg_match('#^\\[?([^ \\]]+)[^\\]]*\\]?$#', $aParams['website'], $aMatch)) {
|
if (preg_match('#^\\[?([^ \\]]+)[^\\]]*\\]?$#', $aParams['website'], $aMatch)) {
|
||||||
$aPageProperties['sWebsite'] = $aMatch[1];
|
$aPageProperties['sWebsite'] = $aMatch[1];
|
||||||
if (strpos($aPageProperties['sWebsite'], ':/'.'/') === FALSE) {
|
if (strpos($aPageProperties['sWebsite'], ':/'.'/') === false) {
|
||||||
$aPageProperties['sWebsite'] = 'http:/'.'/'.$aPageProperties['sWebsite'];
|
$aPageProperties['sWebsite'] = 'http:/'.'/'.$aPageProperties['sWebsite'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,6 +344,7 @@ if (isset($aCMDResult['parse-wikipedia'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function nominatimXMLStart($hParser, $sName, $aAttr)
|
function nominatimXMLStart($hParser, $sName, $aAttr)
|
||||||
{
|
{
|
||||||
global $aNominatRecords;
|
global $aNominatRecords;
|
||||||
@@ -352,6 +355,7 @@ function nominatimXMLStart($hParser, $sName, $aAttr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function nominatimXMLEnd($hParser, $sName)
|
function nominatimXMLEnd($hParser, $sName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -494,7 +498,7 @@ if (isset($aCMDResult['link'])) {
|
|||||||
$hXMLParser = xml_parser_create();
|
$hXMLParser = xml_parser_create();
|
||||||
xml_set_element_handler($hXMLParser, 'nominatimXMLStart', 'nominatimXMLEnd');
|
xml_set_element_handler($hXMLParser, 'nominatimXMLStart', 'nominatimXMLEnd');
|
||||||
xml_parse($hXMLParser, $sXML, true);
|
xml_parse($hXMLParser, $sXML, true);
|
||||||
xml_parser_free($hXMLParser);#
|
xml_parser_free($hXMLParser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,9 +526,15 @@ if (isset($aCMDResult['link'])) {
|
|||||||
} else {
|
} else {
|
||||||
$sSQL = "update wikipedia_article set osm_type=";
|
$sSQL = "update wikipedia_article set osm_type=";
|
||||||
switch ($aNominatRecords[$i]['OSM_TYPE']) {
|
switch ($aNominatRecords[$i]['OSM_TYPE']) {
|
||||||
case 'relation': $sSQL .= "'R'"; break;
|
case 'relation':
|
||||||
case 'way': $sSQL .= "'W'"; break;
|
$sSQL .= "'R'";
|
||||||
case 'node': $sSQL .= "'N'"; break;
|
break;
|
||||||
|
case 'way':
|
||||||
|
$sSQL .= "'W'";
|
||||||
|
break;
|
||||||
|
case 'node':
|
||||||
|
$sSQL .= "'N'";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$sSQL .= ", osm_id=".$aNominatRecords[$i]['OSM_ID']." where language = '".pg_escape_string($aRecord['language'])."' and title = '".pg_escape_string($aRecord['title'])."'";
|
$sSQL .= ", osm_id=".$aNominatRecords[$i]['OSM_ID']." where language = '".pg_escape_string($aRecord['language'])."' and title = '".pg_escape_string($aRecord['title'])."'";
|
||||||
$oDB->query($sSQL);
|
$oDB->query($sSQL);
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/php -Cq
|
#!/usr/bin/php -Cq
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Apache log file
|
$sFile = "sample.log.txt"; // Apache log file
|
||||||
$sFile = "sample.log.txt";
|
|
||||||
$sHost1 = 'http://mq-open-search-lm02.ihost.aol.com:8000/nominatim/v1';
|
$sHost1 = 'http://mq-open-search-lm02.ihost.aol.com:8000/nominatim/v1';
|
||||||
$sHost2 = 'http://mq-open-search-lm03.ihost.aol.com:8000/nominatim/v1';
|
$sHost2 = 'http://mq-open-search-lm03.ihost.aol.com:8000/nominatim/v1';
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ if ($aCMDResult['create-db'] || $aCMDResult['all']) {
|
|||||||
if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
||||||
echo "Setup DB\n";
|
echo "Setup DB\n";
|
||||||
$bDidSomething = true;
|
$bDidSomething = true;
|
||||||
// TODO: path detection, detection memory, etc.
|
|
||||||
|
|
||||||
|
// TODO: path detection, detection memory, etc.
|
||||||
|
//
|
||||||
$oDB =& getDB();
|
$oDB =& getDB();
|
||||||
|
|
||||||
$fPostgresVersion = getPostgresVersion($oDB);
|
$fPostgresVersion = getPostgresVersion($oDB);
|
||||||
@@ -649,6 +650,7 @@ if (!$bDidSomething) {
|
|||||||
echo "Setup finished.\n";
|
echo "Setup finished.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function pgsqlRunScriptFile($sFilename)
|
function pgsqlRunScriptFile($sFilename)
|
||||||
{
|
{
|
||||||
if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
|
if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
|
||||||
@@ -698,7 +700,6 @@ function pgsqlRunScriptFile($sFilename)
|
|||||||
fclose($ahGzipPipes[1]);
|
fclose($ahGzipPipes[1]);
|
||||||
proc_close($hGzipProcess);
|
proc_close($hGzipProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pgsqlRunScript($sScript, $bfatal = true)
|
function pgsqlRunScript($sScript, $bfatal = true)
|
||||||
@@ -844,6 +845,4 @@ function create_sql_functions($aCMDResult)
|
|||||||
$sTemplate = str_replace('-- %NOAUXDATA% ', '', $sTemplate);
|
$sTemplate = str_replace('-- %NOAUXDATA% ', '', $sTemplate);
|
||||||
}
|
}
|
||||||
pgsqlRunScript($sTemplate);
|
pgsqlRunScript($sTemplate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,24 +42,24 @@ if ($aCMDResult['wiki-import']) {
|
|||||||
$sLabel = trim($aMatch[1]);
|
$sLabel = trim($aMatch[1]);
|
||||||
$sClass = trim($aMatch[2]);
|
$sClass = trim($aMatch[2]);
|
||||||
$sType = trim($aMatch[3]);
|
$sType = trim($aMatch[3]);
|
||||||
# hack around a bug where building=yes was imported with
|
// hack around a bug where building=yes was imported with
|
||||||
# quotes into the wiki
|
// quotes into the wiki
|
||||||
$sType = preg_replace('/"/', '', $sType);
|
$sType = preg_replace('/"/', '', $sType);
|
||||||
# sanity check, in case somebody added garbage in the wiki
|
// sanity check, in case somebody added garbage in the wiki
|
||||||
if (preg_match('/^\\w+$/', $sClass) < 1
|
if (preg_match('/^\\w+$/', $sClass) < 1
|
||||||
|| preg_match('/^\\w+$/', $sType) < 1
|
|| preg_match('/^\\w+$/', $sType) < 1
|
||||||
) {
|
) {
|
||||||
trigger_error("Bad class/type for language $sLanguage: $sClass=$sType");
|
trigger_error("Bad class/type for language $sLanguage: $sClass=$sType");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# blacklisting: disallow certain class/type combinations
|
// blacklisting: disallow certain class/type combinations
|
||||||
if (isset($aTagsBlacklist[$sClass]) && in_array($sType, $aTagsBlacklist[$sClass])) {
|
if (isset($aTagsBlacklist[$sClass]) && in_array($sType, $aTagsBlacklist[$sClass])) {
|
||||||
# fwrite(STDERR, "Blacklisted: ".$sClass."/".$sType."\n");
|
// fwrite(STDERR, "Blacklisted: ".$sClass."/".$sType."\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
# whitelisting: if class is in whitelist, allow only tags in the list
|
// whitelisting: if class is in whitelist, allow only tags in the list
|
||||||
if (isset($aTagsWhitelist[$sClass]) && !in_array($sType, $aTagsWhitelist[$sClass])) {
|
if (isset($aTagsWhitelist[$sClass]) && !in_array($sType, $aTagsWhitelist[$sClass])) {
|
||||||
# fwrite(STDERR, "Non-Whitelisted: ".$sClass."/".$sType."\n");
|
// fwrite(STDERR, "Non-Whitelisted: ".$sClass."/".$sType."\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$aPairs[$sClass.'|'.$sType] = array($sClass, $sType);
|
$aPairs[$sClass.'|'.$sType] = array($sClass, $sType);
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getosmosistimestamp($sOsmosisConfigDirectory)
|
function getosmosistimestamp($sOsmosisConfigDirectory)
|
||||||
{
|
{
|
||||||
$sStateFile = file_get_contents($sOsmosisConfigDirectory.'/state.txt');
|
$sStateFile = file_get_contents($sOsmosisConfigDirectory.'/state.txt');
|
||||||
|
|||||||
@@ -67,4 +67,3 @@ if (!$aResult['reverse-only']) {
|
|||||||
else echo ".";
|
else echo ".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||||
require_once(CONST_BasePath.'/lib/log.php');
|
require_once(CONST_BasePath.'/lib/log.php');
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
var_dump($aPolygons);
|
var_dump($aPolygons);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -66,6 +68,7 @@ table td {
|
|||||||
|
|
||||||
<table>
|
<table>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!$aPolygons) exit;
|
if (!$aPolygons) exit;
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
// var_dump($aPolygons[0]);
|
// var_dump($aPolygons[0]);
|
||||||
@@ -90,6 +93,7 @@ table td {
|
|||||||
}
|
}
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ if (count($aOsmIds) > CONST_Places_Max_ID_count) {
|
|||||||
userError('Bulk User: Only ' . CONST_Places_Max_ID_count . " ids are allowed in one request.");
|
userError('Bulk User: Only ' . CONST_Places_Max_ID_count . " ids are allowed in one request.");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($aOsmIds AS $sItem) {
|
foreach ($aOsmIds as $sItem) {
|
||||||
// Skip empty sItem
|
// Skip empty sItem
|
||||||
if (empty($sItem)) continue;
|
if (empty($sItem)) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||||
require_once(CONST_BasePath.'/lib/log.php');
|
require_once(CONST_BasePath.'/lib/log.php');
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
var_dump($aPolygons);
|
var_dump($aPolygons);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -126,6 +128,7 @@ table td {
|
|||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||||
|
|
||||||
|
|
||||||
function statusError($sMsg)
|
function statusError($sMsg)
|
||||||
{
|
{
|
||||||
header("HTTP/1.0 500 Internal Server Error");
|
header("HTTP/1.0 500 Internal Server Error");
|
||||||
@@ -34,4 +35,3 @@ if (!$iWordID) {
|
|||||||
|
|
||||||
echo "OK";
|
echo "OK";
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user