fix function declaration errors according to PSR2 coding style guide

This commit is contained in:
Marc Tobias Metten
2016-09-11 05:22:51 +02:00
parent 5c40100b57
commit 2a784fa3d4
24 changed files with 337 additions and 240 deletions

View File

@@ -10,8 +10,7 @@
$oDB =& getDB();
$sSQL = "select placex.place_id, calculated_country_code as country_code, name->'name' as name, i.* from placex, import_polygon_delete i where placex.osm_id = i.osm_id and placex.osm_type = i.osm_type and placex.class = i.class and placex.type = i.type";
$aPolygons = chksql($oDB->getAll($sSQL),
"Could not get list of deleted OSM elements.");
$aPolygons = chksql($oDB->getAll($sSQL), "Could not get list of deleted OSM elements.");
if (CONST_DEBUG) {
var_dump($aPolygons);

View File

@@ -11,7 +11,7 @@ $oParams = new ParameterParser();
$sOutputFormat = 'html';
$aLangPrefOrder = $oParams->getPreferredLanguages();
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
$sLanguagePrefArraySQL = "ARRAY[".join(',', array_map("getDBQuoted", $aLangPrefOrder))."]";
$sPlaceId = $oParams->getString('place_id');
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
@@ -66,8 +66,7 @@ $sSQL .= " ST_y(centroid) as lat, ST_x(centroid) as lon,";
$sSQL .= " case when importance = 0 OR importance IS NULL then 0.75-(rank_search::float/40) else importance end as calculated_importance, ";
$sSQL .= " ST_AsText(CASE WHEN ST_NPoints(geometry) > 5000 THEN ST_SimplifyPreserveTopology(geometry, 0.0001) ELSE geometry END) as outlinestring";
$sSQL .= " from placex where place_id = $iPlaceID";
$aPointDetails = chksql($oDB->getRow($sSQL),
"Could not get details of place object.");
$aPointDetails = chksql($oDB->getRow($sSQL), "Could not get details of place object.");
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
$aClassType = getClassTypesWithImportance();
@@ -122,14 +121,14 @@ if ($oParams->getBool('keywords')) {
$aPlaceSearchName = [];
}
$sSQL = "select * from word where word_id in (".substr($aPlaceSearchName['name_vector'],1,-1).")";
$sSQL = "select * from word where word_id in (".substr($aPlaceSearchName['name_vector'], 1, -1).")";
$aPlaceSearchNameKeywords = $oDB->getAll($sSQL);
if (PEAR::isError($aPlaceSearchNameKeywords)) { // possible timeout
$aPlaceSearchNameKeywords = [];
}
$sSQL = "select * from word where word_id in (".substr($aPlaceSearchName['nameaddress_vector'],1,-1).")";
$sSQL = "select * from word where word_id in (".substr($aPlaceSearchName['nameaddress_vector'], 1, -1).")";
$aPlaceSearchAddressKeywords = $oDB->getAll($sSQL);
if (PEAR::isError($aPlaceSearchAddressKeywords)) { // possible timeout
$aPlaceSearchAddressKeywords = [];

View File

@@ -12,7 +12,7 @@ $oParams = new ParameterParser();
$sOutputFormat = $oParams->getSet('format', array('html', 'json'), 'html');
$aLangPrefOrder = $oParams->getPreferredLanguages();
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
$sLanguagePrefArraySQL = "ARRAY[".join(',', array_map("getDBQuoted", $aLangPrefOrder))."]";
$sPlaceId = $oParams->getString('place_id');
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
@@ -90,7 +90,7 @@ $aRelatedPlaceIDs = chksql($oDB->getCol($sSQL = "select place_id from placex whe
$sSQL = "select obj.place_id, osm_type, osm_id, class, type, housenumber, admin_level, rank_address, ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea, st_area(geometry) as area, ";
$sSQL .= " get_name_by_language(name,$sLanguagePrefArraySQL) as localname, length(name::text) as namelength ";
$sSQL .= " from (select placex.place_id, osm_type, osm_id, class, type, housenumber, admin_level, rank_address, rank_search, geometry, name from placex ";
$sSQL .= " where parent_place_id in (".join(',',$aRelatedPlaceIDs).") and name is not null order by rank_address asc,rank_search asc limit 500) as obj";
$sSQL .= " where parent_place_id in (".join(',', $aRelatedPlaceIDs).") and name is not null order by rank_address asc,rank_search asc limit 500) as obj";
$sSQL .= " order by rank_address asc,rank_search asc,localname,class, type,housenumber";
$aParentOfLines = chksql($oDB->getAll($sSQL));
@@ -100,11 +100,11 @@ if (sizeof($aParentOfLines)) {
$aGroupedAddressLines = array();
foreach ($aParentOfLines as $aAddressLine) {
if (isset($aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label'])
&& $aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label']
&& $aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label']
) {
$aAddressLine['label'] = $aClassType[$aAddressLine['class'].':'.$aAddressLine['type'].':'.$aAddressLine['admin_level']]['label'];
} elseif (isset($aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label'])
&& $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label']
&& $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label']
) {
$aAddressLine['label'] = $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label'];
} else $aAddressLine['label'] = ucwords($aAddressLine['type']);

View File

@@ -62,7 +62,7 @@ foreach ($aOsmIds AS $sItem) {
if (CONST_Debug) exit;
$sXmlRootTag = 'lookupresults';
$sQuery = join(',',$aCleanedQueryParts);
$sQuery = join(',', $aCleanedQueryParts);
// we initialize these to avoid warnings in our logfile
$sViewBox = '';
$bShowPolygons = '';

View File

@@ -101,7 +101,7 @@ table td {
foreach ($aRow as $sCol => $sVal) {
switch ($sCol) {
case 'error message':
if (preg_match('/Self-intersection\\[([0-9.\\-]+) ([0-9.\\-]+)\\]/',$sVal,$aMatch)) {
if (preg_match('/Self-intersection\\[([0-9.\\-]+) ([0-9.\\-]+)\\]/', $sVal, $aMatch)) {
$aRow['lat'] = $aMatch[2];
$aRow['lon'] = $aMatch[1];
echo "<td><a href=\"http://www.openstreetmap.org/?lat=".$aMatch[2]."&lon=".$aMatch[1]."&zoom=18&layers=M&".$sOSMType."=".$aRow['id']."\">".($sVal?$sVal:'&nbsp;')."</a></td>";

View File

@@ -15,9 +15,9 @@ $bAsGeoJSON = $oParams->getBool('polygon_geojson');
$bAsKML = $oParams->getBool('polygon_kml');
$bAsSVG = $oParams->getBool('polygon_svg');
$bAsText = $oParams->getBool('polygon_text');
if ((($bAsGeoJSON?1:0) + ($bAsKML?1:0) + ($bAsSVG?1:0)
+ ($bAsText?1:0)) > CONST_PolygonOutput_MaximumTypes
) {
$iWantedTypes = ($bAsGeoJSON?1:0) + ($bAsKML?1:0) + ($bAsSVG?1:0) + ($bAsText?1:0);
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
if (CONST_PolygonOutput_MaximumTypes) {
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
} else {
@@ -51,16 +51,19 @@ $fLat = $oParams->getFloat('lat');
$fLon = $oParams->getFloat('lon');
if ($sOsmType && $iOsmId > 0) {
$aPlace = $oPlaceLookup->lookupOSMID($sOsmType, $iOsmId);
} else if ($fLat !== false && $fLon !== false) {
} elseif ($fLat !== false && $fLon !== false) {
$oReverseGeocode = new ReverseGeocode($oDB);
$oReverseGeocode->setZoom($oParams->getInt('zoom', 18));
$aLookup = $oReverseGeocode->lookup($fLat, $fLon);
if (CONST_Debug) var_dump($aLookup);
$aPlace = $oPlaceLookup->lookup((int)$aLookup['place_id'],
$aLookup['type'], $aLookup['fraction']);
} else if ($sOutputFormat != 'html') {
$aPlace = $oPlaceLookup->lookup(
(int)$aLookup['place_id'],
$aLookup['type'],
$aLookup['fraction']
);
} elseif ($sOutputFormat != 'html') {
userError("Need coordinates or OSM object to lookup.");
}
@@ -73,9 +76,12 @@ if ($aPlace) {
$oPlaceLookup->setPolygonSimplificationThreshold($fThreshold);
$fRadius = $fDiameter = getResultDiameter($aPlace);
$aOutlineResult = $oPlaceLookup->getOutlines($aPlace['place_id'],
$aPlace['lon'], $aPlace['lat'],
$fRadius);
$aOutlineResult = $oPlaceLookup->getOutlines(
$aPlace['place_id'],
$aPlace['lon'],
$aPlace['lat'],
$fRadius
);
if ($aOutlineResult) {
$aPlace = array_merge($aPlace, $aOutlineResult);

View File

@@ -38,13 +38,8 @@ if ($sOutputFormat == 'html') {
$bAsKML = $oParams->getBool('polygon_kml');
$bAsSVG = $oParams->getBool('polygon_svg');
$bAsText = $oParams->getBool('polygon_text');
if (( ($bAsGeoJSON?1:0)
+ ($bAsKML?1:0)
+ ($bAsSVG?1:0)
+ ($bAsText?1:0)
+ ($bAsPoints?1:0)
) > CONST_PolygonOutput_MaximumTypes
) {
$iWantedTypes = ($bAsGeoJSON?1:0) + ($bAsKML?1:0) + ($bAsSVG?1:0) + ($bAsText?1:0) + ($bAsPoints?1:0);
if ($iWantedTypes > CONST_PolygonOutput_MaximumTypes) {
if (CONST_PolygonOutput_MaximumTypes) {
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
} else {
@@ -82,13 +77,15 @@ if (CONST_Search_BatchMode && isset($_GET['batch'])) {
$oGeocode->setQueryFromParams($oParams);
if (!$oGeocode->getQueryString()
&& isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'][0] == '/') {
&& isset($_SERVER['PATH_INFO'])
&& $_SERVER['PATH_INFO'][0] == '/'
) {
$sQuery = substr(rawurldecode($_SERVER['PATH_INFO']), 1);
// reverse order of '/' separated string
$aPhrases = explode('/', $sQuery);
$aPhrases = array_reverse($aPhrases);
$sQuery = join(', ',$aPhrases);
$sQuery = join(', ', $aPhrases);
$oGeocode->setQuery($sQuery);
}
@@ -107,7 +104,7 @@ $sViewBox = $oGeocode->getViewBoxString();
$bShowPolygons = (isset($_GET['polygon']) && $_GET['polygon']);
$aExcludePlaceIDs = $oGeocode->getExcludedPlaceIDs();
$sMoreURL = CONST_Website_BaseURL.'search.php?format='.urlencode($sOutputFormat).'&exclude_place_ids='.join(',',$aExcludePlaceIDs);
$sMoreURL = CONST_Website_BaseURL.'search.php?format='.urlencode($sOutputFormat).'&exclude_place_ids='.join(',', $aExcludePlaceIDs);
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) $sMoreURL .= '&accept-language='.$_SERVER["HTTP_ACCEPT_LANGUAGE"];
if ($bShowPolygons) $sMoreURL .= '&polygon=1';
if ($oGeocode->getIncludeAddressDetails()) $sMoreURL .= '&addressdetails=1';