replace double-quoting with single quotes where applicable

This commit is contained in:
Sarah Hoffmann
2017-10-26 21:21:21 +02:00
parent 71602afcad
commit 6c1977b448
32 changed files with 436 additions and 436 deletions

View File

@@ -525,12 +525,12 @@ class Geocode
$sNormQuery = $this->normTerm($this->sQuery);
$sLanguagePrefArraySQL = getArraySQL(
array_map("getDBQuoted", $this->aLangPrefOrder)
array_map('getDBQuoted', $this->aLangPrefOrder)
);
$sQuery = $this->sQuery;
if (!preg_match('//u', $sQuery)) {
userError("Query string is not UTF-8 encoded.");
userError('Query string is not UTF-8 encoded.');
}
// Conflicts between US state abreviations and various words for 'the' in different languages
@@ -577,7 +577,7 @@ class Geocode
$sSpecialTerm = pg_escape_string($sSpecialTerm);
$sToken = chksql(
$this->oDB->getOne("SELECT make_standard_name('$sSpecialTerm')"),
"Cannot decode query. Wrong encoding?"
'Cannot decode query. Wrong encoding?'
);
$sSQL = 'SELECT class, type FROM word ';
$sSQL .= ' WHERE word_token in (\' '.$sToken.'\')';
@@ -618,7 +618,7 @@ class Geocode
foreach ($aInPhrases as $iPhrase => $sPhrase) {
$sPhrase = chksql(
$this->oDB->getOne('SELECT make_standard_name('.getDBQuoted($sPhrase).')'),
"Cannot normalize query string (is it a UTF-8 string?)"
'Cannot normalize query string (is it a UTF-8 string?)'
);
if (trim($sPhrase)) {
$oPhrase = new Phrase($sPhrase, is_string($iPhrase) ? $iPhrase : '');
@@ -631,14 +631,14 @@ class Geocode
// Check which tokens we have, get the ID numbers
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code, operator, search_name_count';
$sSQL .= ' FROM word ';
$sSQL .= ' WHERE word_token in ('.join(',', array_map("getDBQuoted", $aTokens)).')';
$sSQL .= ' WHERE word_token in ('.join(',', array_map('getDBQuoted', $aTokens)).')';
if (CONST_Debug) var_Dump($sSQL);
$aValidTokens = array();
$aDatabaseWords = chksql(
$this->oDB->getAll($sSQL),
"Could not get word tokens."
'Could not get word tokens.'
);
$aWordFrequencyScores = array();
foreach ($aDatabaseWords as $aToken) {
@@ -780,15 +780,15 @@ class Geocode
if ($sPlaceIds) {
$sSQL = 'SELECT place_id FROM placex ';
$sSQL .= 'WHERE place_id in ('.$sPlaceIds.') ';
$sSQL .= " AND (";
$sSQL .= ' AND (';
$sSQL .= " placex.rank_address between $this->iMinAddressRank and $this->iMaxAddressRank ";
if (14 >= $this->iMinAddressRank && 14 <= $this->iMaxAddressRank) {
$sSQL .= " OR (extratags->'place') = 'city'";
}
if ($this->aAddressRankList) {
$sSQL .= " OR placex.rank_address in (".join(',', $this->aAddressRankList).")";
$sSQL .= ' OR placex.rank_address in ('.join(',', $this->aAddressRankList).')';
}
$sSQL .= ")";
$sSQL .= ')';
$aFilterSql[] = $sSQL;
}
$sPlaceIds = Result::joinIdsByTable($aResults, Result::TABLE_POSTCODE);
@@ -797,9 +797,9 @@ class Geocode
$sSQL .= 'WHERE place_id in ('.$sPlaceIds.') ';
$sSQL .= " AND (lp.rank_address between $this->iMinAddressRank and $this->iMaxAddressRank ";
if ($this->aAddressRankList) {
$sSQL .= " OR lp.rank_address in (".join(',', $this->aAddressRankList).")";
$sSQL .= ' OR lp.rank_address in ('.join(',', $this->aAddressRankList).')';
}
$sSQL .= ") ";
$sSQL .= ') ';
$aFilterSql[] = $sSQL;
}
@@ -835,7 +835,7 @@ class Geocode
$oLookup = $oReverse->lookupPoint($oCtx->sqlNear, false);
if (CONST_Debug) var_dump("Reverse search", $aLookup);
if (CONST_Debug) var_dump('Reverse search', $aLookup);
if ($oLookup) {
$aResults = array($oLookup->iId => $oLookup);
@@ -932,7 +932,7 @@ class Geocode
foreach ($aRecheckWords as $i => $sWord) {
if (stripos($sAddress, $sWord)!==false) {
$iCountWords++;
if (preg_match("/(^|,)\s*".preg_quote($sWord, '/')."\s*(,|$)/", $sAddress)) $iCountWords += 0.1;
if (preg_match('/(^|,)\s*'.preg_quote($sWord, '/').'\s*(,|$)/', $sAddress)) $iCountWords += 0.1;
}
}

View File

@@ -82,8 +82,8 @@ class ParameterParser
public function getPreferredLanguages($sFallback = null)
{
if ($sFallback === null && isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
$sFallback = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
if ($sFallback === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$sFallback = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
$aLanguages = array();

View File

@@ -76,9 +76,9 @@ class PlaceLookup
($this->bIncludePolygonAsSVG ? 1 : 0);
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
if (CONST_PolygonOutput_MaximumTypes) {
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
userError('Select only '.CONST_PolygonOutput_MaximumTypes.' polgyon output option');
} else {
userError("Polygon output is disabled");
userError('Polygon output is disabled');
}
}
}
@@ -216,7 +216,7 @@ class PlaceLookup
if ($this->sAddressRankListSql) {
$sSQL .= ' OR placex.rank_address in '.$this->sAddressRankListSql;
}
$sSQL .= " ) ";
$sSQL .= ' ) ';
if ($this->sAllowedTypesSQLList) {
$sSQL .= 'AND placex.class in '.$this->sAllowedTypesSQLList;
}
@@ -248,22 +248,22 @@ class PlaceLookup
if ($sPlaceIDs) {
$sSQL = 'SELECT';
$sSQL .= " 'P' as osm_type,";
$sSQL .= " (SELECT osm_id from placex p WHERE p.place_id = lp.parent_place_id) as osm_id,";
$sSQL .= ' (SELECT osm_id from placex p WHERE p.place_id = lp.parent_place_id) as osm_id,';
$sSQL .= " 'place' as class, 'postcode' as type,";
$sSQL .= ' null as admin_level, rank_search, rank_address,';
$sSQL .= ' place_id, parent_place_id,';
$sSQL .= ' null as housenumber,';
$sSQL .= ' country_code,';
$sSQL .= $this->langAddressSql('-1');
$sSQL .= " postcode as placename,";
$sSQL .= " postcode as ref,";
if ($this->bExtraTags) $sSQL .= "null AS extra,";
if ($this->bNameDetails) $sSQL .= "null AS names,";
$sSQL .= " ST_x(geometry) AS lon, ST_y(geometry) AS lat,";
$sSQL .= " (0.75-(rank_search::float/40)) AS importance, ";
$sSQL .= ' postcode as placename,';
$sSQL .= ' postcode as ref,';
if ($this->bExtraTags) $sSQL .= 'null AS extra,';
if ($this->bNameDetails) $sSQL .= 'null AS names,';
$sSQL .= ' ST_x(geometry) AS lon, ST_y(geometry) AS lat,';
$sSQL .= ' (0.75-(rank_search::float/40)) AS importance, ';
$sSQL .= $this->addressImportanceSql('geometry', 'lp.parent_place_id');
$sSQL .= " null AS extra_place ";
$sSQL .= "FROM location_postcode lp";
$sSQL .= ' null AS extra_place ';
$sSQL .= 'FROM location_postcode lp';
$sSQL .= " WHERE place_id in ($sPlaceIDs) ";
$sSQL .= " AND lp.rank_address between $iMinRank and $iMaxRank";
@@ -279,9 +279,9 @@ class PlaceLookup
$sHousenumbers = Result::sqlHouseNumberTable($aResults, Result::TABLE_TIGER);
// Tiger search only if a housenumber was searched and if it was found
// (realized through a join)
$sSQL = " SELECT ";
$sSQL = ' SELECT ';
$sSQL .= " 'T' AS osm_type, ";
$sSQL .= " (SELECT osm_id from placex p WHERE p.place_id=blub.parent_place_id) as osm_id, ";
$sSQL .= ' (SELECT osm_id from placex p WHERE p.place_id=blub.parent_place_id) as osm_id, ';
$sSQL .= " 'place' AS class, ";
$sSQL .= " 'house' AS type, ";
$sSQL .= ' null AS admin_level, ';
@@ -292,27 +292,27 @@ class PlaceLookup
$sSQL .= ' housenumber_for_place as housenumber,';
$sSQL .= " 'us' AS country_code, ";
$sSQL .= $this->langAddressSql('housenumber_for_place');
$sSQL .= " null AS placename, ";
$sSQL .= " null AS ref, ";
if ($this->bExtraTags) $sSQL .= "null AS extra,";
if ($this->bNameDetails) $sSQL .= "null AS names,";
$sSQL .= " st_x(centroid) AS lon, ";
$sSQL .= " st_y(centroid) AS lat,";
$sSQL .= " -1.15 AS importance, ";
$sSQL .= ' null AS placename, ';
$sSQL .= ' null AS ref, ';
if ($this->bExtraTags) $sSQL .= 'null AS extra,';
if ($this->bNameDetails) $sSQL .= 'null AS names,';
$sSQL .= ' st_x(centroid) AS lon, ';
$sSQL .= ' st_y(centroid) AS lat,';
$sSQL .= ' -1.15 AS importance, ';
$sSQL .= $this->addressImportanceSql('centroid', 'blub.parent_place_id');
$sSQL .= " null AS extra_place ";
$sSQL .= " FROM (";
$sSQL .= " SELECT place_id, "; // interpolate the Tiger housenumbers here
$sSQL .= " ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) AS centroid, ";
$sSQL .= " parent_place_id, ";
$sSQL .= " housenumber_for_place";
$sSQL .= " FROM (";
$sSQL .= " location_property_tiger ";
$sSQL .= " JOIN (values ".$sHousenumbers.") AS housenumbers(place_id, housenumber_for_place) USING(place_id)) ";
$sSQL .= " WHERE ";
$sSQL .= " housenumber_for_place >= startnumber";
$sSQL .= " AND housenumber_for_place <= endnumber";
$sSQL .= " ) AS blub"; //postgres wants an alias here
$sSQL .= ' null AS extra_place ';
$sSQL .= ' FROM (';
$sSQL .= ' SELECT place_id, '; // interpolate the Tiger housenumbers here
$sSQL .= ' ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) AS centroid, ';
$sSQL .= ' parent_place_id, ';
$sSQL .= ' housenumber_for_place';
$sSQL .= ' FROM (';
$sSQL .= ' location_property_tiger ';
$sSQL .= ' JOIN (values '.$sHousenumbers.') AS housenumbers(place_id, housenumber_for_place) USING(place_id)) ';
$sSQL .= ' WHERE ';
$sSQL .= ' housenumber_for_place >= startnumber';
$sSQL .= ' AND housenumber_for_place <= endnumber';
$sSQL .= ' ) AS blub'; //postgres wants an alias here
$aSubSelects[] = $sSQL;
}
@@ -324,9 +324,9 @@ class PlaceLookup
$sHousenumbers = Result::sqlHouseNumberTable($aResults, Result::TABLE_OSMLINE);
// interpolation line search only if a housenumber was searched
// (realized through a join)
$sSQL = "SELECT ";
$sSQL = 'SELECT ';
$sSQL .= " 'W' AS osm_type, ";
$sSQL .= " osm_id, ";
$sSQL .= ' osm_id, ';
$sSQL .= " 'place' AS class, ";
$sSQL .= " 'house' AS type, ";
$sSQL .= ' 15 AS admin_level, ';
@@ -344,27 +344,27 @@ class PlaceLookup
$sSQL .= ' st_x(centroid) AS lon, ';
$sSQL .= ' st_y(centroid) AS lat, ';
// slightly smaller than the importance for normal houses
$sSQL .= " -0.1 AS importance, ";
$sSQL .= ' -0.1 AS importance, ';
$sSQL .= $this->addressImportanceSql('centroid', 'blub.parent_place_id');
$sSQL .= " null AS extra_place ";
$sSQL .= " FROM (";
$sSQL .= " SELECT ";
$sSQL .= " osm_id, ";
$sSQL .= " place_id, ";
$sSQL .= " country_code, ";
$sSQL .= " CASE "; // interpolate the housenumbers here
$sSQL .= " WHEN startnumber != endnumber ";
$sSQL .= " THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) ";
$sSQL .= " ELSE ST_LineInterpolatePoint(linegeo, 0.5) ";
$sSQL .= " END as centroid, ";
$sSQL .= " parent_place_id, ";
$sSQL .= " housenumber_for_place ";
$sSQL .= " FROM (";
$sSQL .= " location_property_osmline ";
$sSQL .= " JOIN (values ".$sHousenumbers.") AS housenumbers(place_id, housenumber_for_place) USING(place_id)";
$sSQL .= " ) ";
$sSQL .= " WHERE housenumber_for_place >= 0 ";
$sSQL .= " ) as blub"; //postgres wants an alias here
$sSQL .= ' null AS extra_place ';
$sSQL .= ' FROM (';
$sSQL .= ' SELECT ';
$sSQL .= ' osm_id, ';
$sSQL .= ' place_id, ';
$sSQL .= ' country_code, ';
$sSQL .= ' CASE '; // interpolate the housenumbers here
$sSQL .= ' WHEN startnumber != endnumber ';
$sSQL .= ' THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) ';
$sSQL .= ' ELSE ST_LineInterpolatePoint(linegeo, 0.5) ';
$sSQL .= ' END as centroid, ';
$sSQL .= ' parent_place_id, ';
$sSQL .= ' housenumber_for_place ';
$sSQL .= ' FROM (';
$sSQL .= ' location_property_osmline ';
$sSQL .= ' JOIN (values '.$sHousenumbers.') AS housenumbers(place_id, housenumber_for_place) USING(place_id)';
$sSQL .= ' ) ';
$sSQL .= ' WHERE housenumber_for_place >= 0 ';
$sSQL .= ' ) as blub'; //postgres wants an alias here
$aSubSelects[] = $sSQL;
}
@@ -373,9 +373,9 @@ class PlaceLookup
$sPlaceIDs = Result::joinIdsByTable($aResults, Result::TABLE_AUX);
if ($sPlaceIDs) {
$sHousenumbers = Result::sqlHouseNumberTable($aResults, Result::TABLE_AUX);
$sSQL = " SELECT ";
$sSQL = ' SELECT ';
$sSQL .= " 'L' AS osm_type, ";
$sSQL .= " place_id AS osm_id, ";
$sSQL .= ' place_id AS osm_id, ';
$sSQL .= " 'place' AS class,";
$sSQL .= " 'house' AS type, ";
$sSQL .= ' null AS admin_level, ';
@@ -386,19 +386,19 @@ class PlaceLookup
$sSQL .= ' housenumber,';
$sSQL .= " 'us' AS country_code, ";
$sSQL .= $this->langAddressSql('-1');
$sSQL .= " null AS placename, ";
$sSQL .= " null AS ref, ";
if ($this->bExtraTags) $sSQL .= "null AS extra, ";
if ($this->bNameDetails) $sSQL .= "null AS names, ";
$sSQL .= " ST_X(centroid) AS lon, ";
$sSQL .= " ST_Y(centroid) AS lat, ";
$sSQL .= " -1.10 AS importance, ";
$sSQL .= ' null AS placename, ';
$sSQL .= ' null AS ref, ';
if ($this->bExtraTags) $sSQL .= 'null AS extra, ';
if ($this->bNameDetails) $sSQL .= 'null AS names, ';
$sSQL .= ' ST_X(centroid) AS lon, ';
$sSQL .= ' ST_Y(centroid) AS lat, ';
$sSQL .= ' -1.10 AS importance, ';
$sSQL .= $this->addressImportanceSql(
'centroid',
'location_property_aux.parent_place_id'
);
$sSQL .= " null AS extra_place ";
$sSQL .= " FROM location_property_aux ";
$sSQL .= ' null AS extra_place ';
$sSQL .= ' FROM location_property_aux ';
$sSQL .= " WHERE place_id in ($sPlaceIDs) ";
$aSubSelects[] = $sSQL;
@@ -414,7 +414,7 @@ class PlaceLookup
$aPlaces = chksql(
$this->oDB->getAll(join(' UNION ', $aSubSelects)),
"Could not lookup place"
'Could not lookup place'
);
$aClassType = getClassTypes();
@@ -534,22 +534,22 @@ class PlaceLookup
if (CONST_Search_AreaPolygons) {
// Get the bounding box and outline polygon
$sSQL = "select place_id,0 as numfeatures,st_area(geometry) as area,";
$sSQL .= "ST_Y(centroid) as centrelat,ST_X(centroid) as centrelon,";
$sSQL .= "ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,";
$sSQL .= "ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon";
if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ",ST_AsGeoJSON(geometry) as asgeojson";
if ($this->bIncludePolygonAsKML) $sSQL .= ",ST_AsKML(geometry) as askml";
if ($this->bIncludePolygonAsSVG) $sSQL .= ",ST_AsSVG(geometry) as assvg";
if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ",ST_AsText(geometry) as astext";
$sFrom = " from placex where place_id = ".$iPlaceID;
$sSQL = 'select place_id,0 as numfeatures,st_area(geometry) as area,';
$sSQL .= 'ST_Y(centroid) as centrelat,ST_X(centroid) as centrelon,';
$sSQL .= 'ST_YMin(geometry) as minlat,ST_YMax(geometry) as maxlat,';
$sSQL .= 'ST_XMin(geometry) as minlon,ST_XMax(geometry) as maxlon';
if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ',ST_AsText(geometry) as astext';
$sFrom = ' from placex where place_id = '.$iPlaceID;
if ($this->fPolygonSimplificationThreshold > 0) {
$sSQL .= " from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,".$this->fPolygonSimplificationThreshold.") as geometry".$sFrom.") as plx";
$sSQL .= ' from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,'.$this->fPolygonSimplificationThreshold.') as geometry'.$sFrom.') as plx';
} else {
$sSQL .= $sFrom;
}
$aPointPolygon = chksql($this->oDB->getRow($sSQL), "Could not get outline");
$aPointPolygon = chksql($this->oDB->getRow($sSQL), 'Could not get outline');
if ($aPointPolygon['place_id']) {
if ($aPointPolygon['centrelon'] !== null && $aPointPolygon['centrelat'] !== null) {

View File

@@ -65,7 +65,7 @@ class ReverseGeocode
return chksql(
$this->oDB->getRow($sSQL),
"Could not determine closest housenumber on an osm interpolation line."
'Could not determine closest housenumber on an osm interpolation line.'
);
}
@@ -141,7 +141,7 @@ class ReverseGeocode
if (CONST_Debug) var_dump($sSQL);
$aPlace = chksql(
$this->oDB->getRow($sSQL),
"Could not determine closest place."
'Could not determine closest place.'
);
if ($aPlace) {
$oResult = new Result($aPlace['place_id']);
@@ -186,7 +186,7 @@ class ReverseGeocode
$aPlaceTiger = chksql(
$this->oDB->getRow($sSQL),
"Could not determine closest Tiger place."
'Could not determine closest Tiger place.'
);
if ($aPlaceTiger) {
if (CONST_Debug) var_dump('found Tiger housenumber', $aPlaceTiger);
@@ -210,7 +210,7 @@ class ReverseGeocode
$sSQL .= " WHERE place_id = $iPlaceID";
$sSQL .= " ORDER BY abs(cached_rank_address - $iMaxRank) asc,cached_rank_address desc,isaddress desc,distance desc";
$sSQL .= ' LIMIT 1';
$iPlaceID = chksql($this->oDB->getOne($sSQL), "Could not get parent for place.");
$iPlaceID = chksql($this->oDB->getOne($sSQL), 'Could not get parent for place.');
if ($iPlaceID) {
$oResult = new Result($iPlaceID);
}

View File

@@ -146,11 +146,11 @@ class SearchContext
$this->sqlViewboxCentre .= ")'::geometry,4326)";
$sSQL = 'ST_BUFFER('.$this->sqlViewboxCentre.','.($fRouteWidth/69).')';
$sGeom = chksql($oDB->getOne("select ".$sSQL), "Could not get small viewbox");
$sGeom = chksql($oDB->getOne('select '.$sSQL), 'Could not get small viewbox');
$this->sqlViewboxSmall = "'".$sGeom."'::geometry";
$sSQL = 'ST_BUFFER('.$this->sqlViewboxCentre.','.($fRouteWidth/30).')';
$sGeom = chksql($oDB->getOne("select ".$sSQL), "Could not get large viewbox");
$sGeom = chksql($oDB->getOne('select '.$sSQL), 'Could not get large viewbox');
$this->sqlViewboxLarge = "'".$sGeom."'::geometry";
}

View File

@@ -240,7 +240,7 @@ class SearchDescription
$oSearch->sHouseNumber = trim($aSearchTerm['word_token']);
// sanity check: if the housenumber is not mainly made
// up of numbers, add a penalty
if (preg_match_all("/[^0-9]/", $oSearch->sHouseNumber, $aMatches) > 2) {
if (preg_match_all('/[^0-9]/', $oSearch->sHouseNumber, $aMatches) > 2) {
$oSearch->iSearchRank++;
}
if (!isset($aSearchTerm['word_id'])) {
@@ -450,7 +450,7 @@ class SearchDescription
}
if (CONST_Debug) {
echo "<br><b>Place IDs:</b> ";
echo '<br><b>Place IDs:</b> ';
var_dump(array_keys($aResults));
}
@@ -469,7 +469,7 @@ class SearchDescription
}
$aResults = $aNewResults;
if (CONST_Debug) {
echo "<br><b>Place IDs after postcode filtering:</b> ";
echo '<br><b>Place IDs after postcode filtering:</b> ';
var_dump(array_keys($aResults));
}
}
@@ -488,7 +488,7 @@ class SearchDescription
if ($this->oContext->bViewboxBounded) {
$sSQL .= ' AND ST_Intersects('.$this->oContext->sqlViewboxSmall.', geometry)';
}
$sSQL .= " ORDER BY st_area(geometry) DESC LIMIT 1";
$sSQL .= ' ORDER BY st_area(geometry) DESC LIMIT 1';
if (CONST_Debug) var_dump($sSQL);
@@ -543,7 +543,7 @@ class SearchDescription
if ($this->oContext->sqlCountryList) {
$sSQL .= ' AND country_code in '.$this->oContext->sqlCountryList;
}
$sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('centroid')." ASC";
$sSQL .= ' ORDER BY '.$this->oContext->distanceSQL('centroid').' ASC';
$sSQL .= " LIMIT $iLimit";
if (CONST_Debug) var_dump($sSQL);
$aDBResults = chksql($oDB->getCol($sSQL));
@@ -638,13 +638,13 @@ class SearchDescription
}
if ($this->sHouseNumber) {
$aTerms[] = "address_rank between 16 and 27";
$aTerms[] = 'address_rank between 16 and 27';
} elseif (!$this->sClass || $this->iOperator == Operator::NAME) {
if ($iMinAddressRank > 0) {
$aTerms[] = "address_rank >= ".$iMinAddressRank;
$aTerms[] = 'address_rank >= '.$iMinAddressRank;
}
if ($iMaxAddressRank < 30) {
$aTerms[] = "address_rank <= ".$iMaxAddressRank;
$aTerms[] = 'address_rank <= '.$iMaxAddressRank;
}
}
@@ -710,7 +710,7 @@ class SearchDescription
$aDBResults = chksql(
$oDB->getAll($sSQL),
"Could not get places for search terms."
'Could not get places for search terms.'
);
foreach ($aDBResults as $aResult) {
@@ -762,8 +762,8 @@ class SearchDescription
$sSQL .= "interpolationtype='odd'";
}
$sSQL .= " or interpolationtype='all') and ";
$sSQL .= $iHousenumber.">=startnumber and ";
$sSQL .= $iHousenumber."<=endnumber";
$sSQL .= $iHousenumber.'>=startnumber and ';
$sSQL .= $iHousenumber.'<=endnumber';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
$sSQL .= " limit $iLimit";
@@ -801,8 +801,8 @@ class SearchDescription
$sSQL .= "interpolationtype='odd'";
}
$sSQL .= " or interpolationtype='all') and ";
$sSQL .= $iHousenumber.">=startnumber and ";
$sSQL .= $iHousenumber."<=endnumber";
$sSQL .= $iHousenumber.'>=startnumber and ';
$sSQL .= $iHousenumber.'<=endnumber';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
$sSQL .= " limit $iLimit";
@@ -835,9 +835,9 @@ class SearchDescription
$sSQL .= " WHERE place_id in ($sPlaceIDs)";
$sSQL .= " AND class='".$this->sClass."' ";
$sSQL .= " AND type='".$this->sType."'";
$sSQL .= " AND linked_place_id is null";
$sSQL .= ' AND linked_place_id is null';
$sSQL .= $this->oContext->excludeSQL(' AND place_id');
$sSQL .= " ORDER BY rank_search ASC ";
$sSQL .= ' ORDER BY rank_search ASC ';
$sSQL .= " LIMIT $iLimit";
if (CONST_Debug) var_dump($sSQL);
@@ -865,8 +865,8 @@ class SearchDescription
$sSQL .= " WHERE place_id in ($sPlaceIDs)";
$sSQL .= " AND rank_search < $iMaxRank + 5";
$sSQL .= " AND ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon')";
$sSQL .= " ORDER BY rank_search ASC ";
$sSQL .= " LIMIT 1";
$sSQL .= ' ORDER BY rank_search ASC ';
$sSQL .= ' LIMIT 1';
if (CONST_Debug) var_dump($sSQL);
$sPlaceGeom = chksql($oDB->getOne($sSQL));
}
@@ -892,7 +892,7 @@ class SearchDescription
if ($this->oContext->hasNearPoint()) {
$sOrderBySQL = $this->oContext->distanceSQL('l.centroid');
} elseif ($sPlaceIDs) {
$sOrderBySQL = "ST_Distance(l.centroid, f.geometry)";
$sOrderBySQL = 'ST_Distance(l.centroid, f.geometry)';
} elseif ($sPlaceGeom) {
$sOrderBySQL = "ST_Distance(st_centroid('".$sPlaceGeom."'), l.centroid)";
}
@@ -908,7 +908,7 @@ class SearchDescription
$sSQL .= ' from '.$sClassTable.' as l';
if ($sPlaceIDs) {
$sSQL .= ",placex as f WHERE ";
$sSQL .= ',placex as f WHERE ';
$sSQL .= "f.place_id in ($sPlaceIDs) ";
$sSQL .= " AND ST_DWithin(l.centroid, f.centroid, $fRange)";
} elseif ($sPlaceGeom) {
@@ -936,7 +936,7 @@ class SearchDescription
if ($this->oContext->hasNearPoint()) {
$sOrderBySQL = $this->oContext->distanceSQL('l.geometry');
} else {
$sOrderBySQL = "ST_Distance(l.geometry, f.geometry)";
$sOrderBySQL = 'ST_Distance(l.geometry, f.geometry)';
}
$sSQL = 'SELECT distinct l.place_id';
@@ -950,7 +950,7 @@ class SearchDescription
$sSQL .= " AND l.type='".$this->sType."'";
$sSQL .= $this->oContext->excludeSQL(' AND l.place_id');
if ($sOrderBySQL) {
$sSQL .= "ORDER BY orderterm ASC";
$sSQL .= 'ORDER BY orderterm ASC';
}
$sSQL .= " limit $iLimit";
@@ -1005,19 +1005,19 @@ class SearchDescription
return $aWordIDs[$k];
};
echo "<tr>";
echo '<tr>';
echo "<td>$this->iSearchRank</td>";
echo "<td>".join(', ', array_map($kf, $this->aName))."</td>";
echo "<td>".join(', ', array_map($kf, $this->aNameNonSearch))."</td>";
echo "<td>".join(', ', array_map($kf, $this->aAddress))."</td>";
echo "<td>".join(', ', array_map($kf, $this->aAddressNonSearch))."</td>";
echo "<td>".$this->sCountryCode."</td>";
echo "<td>".Operator::toString($this->iOperator)."</td>";
echo "<td>".$this->sClass."</td>";
echo "<td>".$this->sType."</td>";
echo "<td>".$this->sPostcode."</td>";
echo "<td>".$this->sHouseNumber."</td>";
echo '<td>'.join(', ', array_map($kf, $this->aName)).'</td>';
echo '<td>'.join(', ', array_map($kf, $this->aNameNonSearch)).'</td>';
echo '<td>'.join(', ', array_map($kf, $this->aAddress)).'</td>';
echo '<td>'.join(', ', array_map($kf, $this->aAddressNonSearch)).'</td>';
echo '<td>'.$this->sCountryCode.'</td>';
echo '<td>'.Operator::toString($this->iOperator).'</td>';
echo '<td>'.$this->sClass.'</td>';
echo '<td>'.$this->sType.'</td>';
echo '<td>'.$this->sPostcode.'</td>';
echo '<td>'.$this->sHouseNumber.'</td>';
echo "</tr>";
echo '</tr>';
}
}

View File

@@ -99,7 +99,7 @@ function showUsage($aSpec, $bExit = false, $sError = false)
echo 'Try `'.basename($_SERVER['argv'][0]).' --help` for more information.'."\n";
exit;
}
echo "Usage: ".basename($_SERVER['argv'][0])."\n";
echo 'Usage: '.basename($_SERVER['argv'][0])."\n";
$bFirst = true;
foreach ($aSpec as $aLine) {
if (is_array($aLine)) {

View File

@@ -8,7 +8,7 @@ function &getDB($bNew = false, $bPersistent = false)
// Get the database object
$oDB = chksql(
DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent),
"Failed to establish database connection"
'Failed to establish database connection'
);
$oDB->setFetchMode(DB_FETCHMODE_ASSOC);
$oDB->query("SET DateStyle TO 'sql,european'");

View File

@@ -10,7 +10,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;
@@ -38,10 +38,10 @@ INTERNALFAIL;
if (CONST_Debug) {
var_dump($oSql);
} else {
echo "<pre>\n".$oSql->getUserInfo()."</pre>";
echo "<pre>\n".$oSql->getUserInfo().'</pre>';
}
echo "</pre></p></body></html>";
echo '</pre></p></body></html>';
exit;
}
@@ -49,20 +49,20 @@ function failInternalError($sError, $sSQL = false, $vDumpVar = false)
{
header('HTTP/1.0 500 Internal Server Error');
header('Content-type: text/html; charset=utf-8');
echo "<html><body><h1>Internal Server Error</h1>";
echo '<html><body><h1>Internal Server Error</h1>';
echo '<p>Nominatim has encountered an internal error while processing your request. This is most likely because of a bug in the software.</p>';
echo "<p><b>Details:</b> ".$sError,"</p>";
echo '<p><b>Details:</b> '.$sError,'</p>';
echo '<p>Feel free to file an issue on <a href="https://github.com/openstreetmap/Nominatim/issues">Github</a>. ';
echo 'Please include the error message above and the URL you used.</p>';
if (CONST_Debug) {
echo "<hr><h2>Debugging Information</h2><br>";
echo '<hr><h2>Debugging Information</h2><br>';
if ($sSQL) {
echo "<h3>SQL query</h3><code>".$sSQL."</code>";
echo '<h3>SQL query</h3><code>'.$sSQL.'</code>';
}
if ($vDumpVar) {
echo "<h3>Result</h3> <code>";
echo '<h3>Result</h3> <code>';
var_dump($vDumpVar);
echo "</code>";
echo '</code>';
}
}
echo "\n</body></html>\n";
@@ -74,9 +74,9 @@ function userError($sError)
{
header('HTTP/1.0 400 Bad Request');
header('Content-type: text/html; charset=utf-8');
echo "<html><body><h1>Bad Request</h1>";
echo '<html><body><h1>Bad Request</h1>';
echo '<p>Nominatim has encountered an error with your request.</p>';
echo "<p><b>Details:</b> ".$sError."</p>";
echo '<p><b>Details:</b> '.$sError.'</p>';
echo '<p>If you feel this error is incorrect feel file an issue on <a href="https://github.com/openstreetmap/Nominatim/issues">Github</a>. ';
echo 'Please include the error message above and the URL you used.</p>';
echo "\n</body></html>\n";
@@ -89,10 +89,10 @@ function userError($sError)
*/
if (CONST_NoAccessControl) {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: OPTIONS,GET");
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: OPTIONS,GET');
if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
header("Access-Control-Allow-Headers: ".$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
header('Access-Control-Allow-Headers: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
}
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;

View File

@@ -38,7 +38,7 @@ function getDatabaseDate(&$oDB)
// Find the newest node in the DB
$iLastOSMID = $oDB->getOne("select max(osm_id) from place where osm_type = 'N'");
// Lookup the timestamp that node was created
$sLastNodeURL = 'https://www.openstreetmap.org/api/0.6/node/'.$iLastOSMID."/1";
$sLastNodeURL = 'https://www.openstreetmap.org/api/0.6/node/'.$iLastOSMID.'/1';
$sLastNodeXML = file_get_contents($sLastNodeURL);
if ($sLastNodeXML === false) {
@@ -413,11 +413,11 @@ function javascript_renderData($xVal, $iOptions = 0)
$jsonout = json_encode($xVal, $iOptions);
if (!isset($_GET['json_callback'])) {
header("Content-Type: application/json; charset=UTF-8");
header('Content-Type: application/json; charset=UTF-8');
echo $jsonout;
} else {
if (preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $_GET['json_callback'])) {
header("Content-Type: application/javascript; charset=UTF-8");
header('Content-Type: application/javascript; charset=UTF-8');
echo $_GET['json_callback'].'('.$jsonout.')';
} else {
header('HTTP/1.0 400 Bad Request');
@@ -439,16 +439,16 @@ function _debugDumpGroupedSearches($aData, $aTokens)
}
}
}
echo "<table border=\"1\">";
echo "<tr><th>rank</th><th>Name Tokens</th><th>Name Not</th>";
echo "<th>Address Tokens</th><th>Address Not</th><th>country</th><th>operator</th>";
echo "<th>class</th><th>type</th><th>postcode</th><th>housenumber</th></tr>";
echo '<table border="1">';
echo '<tr><th>rank</th><th>Name Tokens</th><th>Name Not</th>';
echo '<th>Address Tokens</th><th>Address Not</th><th>country</th><th>operator</th>';
echo '<th>class</th><th>type</th><th>postcode</th><th>housenumber</th></tr>';
foreach ($aData as $iRank => $aRankedSet) {
foreach ($aRankedSet as $aRow) {
$aRow->dumpAsHtmlTableRow($aWordsIDs);
}
}
echo "</table>";
echo '</table>';
}
@@ -456,7 +456,7 @@ function getAddressDetails(&$oDB, $sLanguagePrefArraySQL, $iPlaceID, $sCountryCo
{
$sSQL = "select *,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata($iPlaceID, $housenumber)";
if (!$bRaw) $sSQL .= " WHERE isaddress OR type = 'country_code'";
$sSQL .= " order by rank_address desc,isaddress desc";
$sSQL .= ' order by rank_address desc,isaddress desc';
$aAddressLines = chksql($oDB->getAll($sSQL));
if ($bRaw) return $aAddressLines;

View File

@@ -20,7 +20,7 @@ function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
$hLog = array(
date('Y-m-d H:i:s', $aStartTime[0]).'.'.$aStartTime[1],
$_SERVER["REMOTE_ADDR"],
$_SERVER['REMOTE_ADDR'],
$_SERVER['QUERY_STRING'],
$sOutQuery,
$sType,