phpcs fixes. Mostly spacing and single quotes

This commit is contained in:
Marc Tobias Metten
2018-02-23 01:16:01 +01:00
parent eaaa4a7b31
commit 8a615ad969
10 changed files with 143 additions and 236 deletions

View File

@@ -2,20 +2,15 @@
$aFilteredPlaces = array(); $aFilteredPlaces = array();
if (!sizeof($aPlace)) if (!sizeof($aPlace)) {
{
if (isset($sError)) if (isset($sError))
$aFilteredPlaces['error'] = $sError; $aFilteredPlaces['error'] = $sError;
else else $aFilteredPlaces['error'] = 'Unable to geocode';
$aFilteredPlaces['error'] = 'Unable to geocode'; } else {
}
else
{
if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id']; if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright"; $aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$sOSMType = formatOSMType($aPlace['osm_type']); $sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) if ($sOSMType) {
{
$aFilteredPlaces['osm_type'] = $sOSMType; $aFilteredPlaces['osm_type'] = $sOSMType;
$aFilteredPlaces['osm_id'] = $aPlace['osm_id']; $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
} }
@@ -26,31 +21,25 @@ else
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags']; if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails']; if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
if (isset($aPlace['aBoundingBox'])) if (isset($aPlace['aBoundingBox'])) {
{
$aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox']; $aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
} }
if (isset($aPlace['asgeojson'])) if (isset($aPlace['asgeojson'])) {
{
$aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']); $aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
} }
if (isset($aPlace['assvg'])) if (isset($aPlace['assvg'])) {
{
$aFilteredPlaces['svg'] = $aPlace['assvg']; $aFilteredPlaces['svg'] = $aPlace['assvg'];
} }
if (isset($aPlace['astext'])) if (isset($aPlace['astext'])) {
{
$aFilteredPlaces['geotext'] = $aPlace['astext']; $aFilteredPlaces['geotext'] = $aPlace['astext'];
} }
if (isset($aPlace['askml'])) if (isset($aPlace['askml'])) {
{
$aFilteredPlaces['geokml'] = $aPlace['askml']; $aFilteredPlaces['geokml'] = $aPlace['askml'];
} }
} }
javascript_renderData($aFilteredPlaces); javascript_renderData($aFilteredPlaces);

View File

@@ -2,20 +2,15 @@
$aFilteredPlaces = array(); $aFilteredPlaces = array();
if (!sizeof($aPlace)) if (!sizeof($aPlace)) {
{
if (isset($sError)) if (isset($sError))
$aFilteredPlaces['error'] = $sError; $aFilteredPlaces['error'] = $sError;
else else $aFilteredPlaces['error'] = 'Unable to geocode';
$aFilteredPlaces['error'] = 'Unable to geocode'; } else {
}
else
{
if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id']; if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright"; $aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$sOSMType = formatOSMType($aPlace['osm_type']); $sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) if ($sOSMType) {
{
$aFilteredPlaces['osm_type'] = $sOSMType; $aFilteredPlaces['osm_type'] = $sOSMType;
$aFilteredPlaces['osm_id'] = $aPlace['osm_id']; $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
} }
@@ -38,31 +33,25 @@ else
if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags']; if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails']; if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
if (isset($aPlace['aBoundingBox'])) if (isset($aPlace['aBoundingBox'])) {
{
$aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox']; $aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
} }
if (isset($aPlace['asgeojson'])) if (isset($aPlace['asgeojson'])) {
{
$aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']); $aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
} }
if (isset($aPlace['assvg'])) if (isset($aPlace['assvg'])) {
{
$aFilteredPlaces['svg'] = $aPlace['assvg']; $aFilteredPlaces['svg'] = $aPlace['assvg'];
} }
if (isset($aPlace['astext'])) if (isset($aPlace['astext'])) {
{
$aFilteredPlaces['geotext'] = $aPlace['astext']; $aFilteredPlaces['geotext'] = $aPlace['astext'];
} }
if (isset($aPlace['askml'])) if (isset($aPlace['askml'])) {
{
$aFilteredPlaces['geokml'] = $aPlace['askml']; $aFilteredPlaces['geokml'] = $aPlace['askml'];
} }
} }
javascript_renderData($aFilteredPlaces); javascript_renderData($aFilteredPlaces);

View File

@@ -1,103 +1,87 @@
<?php <?php
header("content-type: text/xml; charset=UTF-8"); header('content-type: text/xml; charset=UTF-8');
echo "<"; echo '<';
echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?"; echo '?xml version="1.0" encoding="UTF-8" ?';
echo ">\n"; echo ">\n";
echo "<reversegeocode"; echo '<reversegeocode';
echo " timestamp='".date(DATE_RFC822)."'"; echo " timestamp='".date(DATE_RFC822)."'";
echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'"; echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'"; echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
echo ">\n"; echo ">\n";
if (!sizeof($aPlace)) if (!sizeof($aPlace)) {
{
if (isset($sError)) if (isset($sError))
echo "<error>$sError</error>"; echo "<error>$sError</error>";
else else echo '<error>Unable to geocode</error>';
echo "<error>Unable to geocode</error>"; } else {
} echo '<result';
else
{
echo "<result";
if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"'; if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
$sOSMType = formatOSMType($aPlace['osm_type']); $sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"'; if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"'; if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"'; if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"'; if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
if (isset($aPlace['aBoundingBox'])) if (isset($aPlace['aBoundingBox'])) {
{
echo ' boundingbox="'; echo ' boundingbox="';
echo join(',', $aPlace['aBoundingBox']); echo join(',', $aPlace['aBoundingBox']);
echo '"'; echo '"';
} }
if (isset($aPlace['asgeojson'])) if (isset($aPlace['asgeojson'])) {
{
echo ' geojson=\''; echo ' geojson=\'';
echo $aPlace['asgeojson']; echo $aPlace['asgeojson'];
echo '\''; echo '\'';
} }
if (isset($aPlace['assvg'])) if (isset($aPlace['assvg'])) {
{
echo ' geosvg=\''; echo ' geosvg=\'';
echo $aPlace['assvg']; echo $aPlace['assvg'];
echo '\''; echo '\'';
} }
if (isset($aPlace['astext'])) if (isset($aPlace['astext'])) {
{
echo ' geotext=\''; echo ' geotext=\'';
echo $aPlace['astext']; echo $aPlace['astext'];
echo '\''; echo '\'';
} }
echo ">".htmlspecialchars($aPlace['langaddress'])."</result>"; echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
if (isset($aPlace['aAddress'])) if (isset($aPlace['aAddress'])) {
{ echo '<addressparts>';
echo "<addressparts>"; foreach ($aPlace['aAddress'] as $sKey => $sValue) {
foreach($aPlace['aAddress'] as $sKey => $sValue) $sKey = str_replace(' ', '_', $sKey);
{
$sKey = str_replace(' ','_',$sKey);
echo "<$sKey>"; echo "<$sKey>";
echo htmlspecialchars($sValue); echo htmlspecialchars($sValue);
echo "</$sKey>"; echo "</$sKey>";
} }
echo "</addressparts>"; echo '</addressparts>';
} }
if (isset($aPlace['sExtraTags'])) if (isset($aPlace['sExtraTags'])) {
{ echo '<extratags>';
echo "<extratags>"; foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
foreach ($aPlace['sExtraTags'] as $sKey => $sValue)
{
echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>'; echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
} }
echo "</extratags>"; echo '</extratags>';
} }
if (isset($aPlace['sNameDetails'])) if (isset($aPlace['sNameDetails'])) {
{ echo '<namedetails>';
echo "<namedetails>"; foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
foreach ($aPlace['sNameDetails'] as $sKey => $sValue)
{
echo '<name desc="'.htmlspecialchars($sKey).'">'; echo '<name desc="'.htmlspecialchars($sKey).'">';
echo htmlspecialchars($sValue); echo htmlspecialchars($sValue);
echo "</name>"; echo '</name>';
} }
echo "</namedetails>"; echo '</namedetails>';
} }
if (isset($aPlace['askml'])) if (isset($aPlace['askml'])) {
{
echo "\n<geokml>"; echo "\n<geokml>";
echo $aPlace['askml']; echo $aPlace['askml'];
echo "</geokml>"; echo '</geokml>';
} }
} }
echo "</reversegeocode>"; echo '</reversegeocode>';

View File

@@ -1,42 +1,37 @@
<?php <?php
$aOutput = array(); $aOutput = array();
$aOutput['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright"; $aOutput['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
$aOutput['batch'] = array(); $aOutput['batch'] = array();
foreach($aBatchResults as $aSearchResults) foreach ($aBatchResults as $aSearchResults) {
{
if (!$aSearchResults) $aSearchResults = array(); if (!$aSearchResults) $aSearchResults = array();
$aFilteredPlaces = array(); $aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails) foreach ($aSearchResults as $iResNum => $aPointDetails) {
{
$aPlace = array( $aPlace = array(
'place_id'=>$aPointDetails['place_id'], 'place_id'=>$aPointDetails['place_id'],
); );
$sOSMType = formatOSMType($aPointDetails['osm_type']); $sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType) if ($sOSMType) {
{
$aPlace['osm_type'] = $sOSMType; $aPlace['osm_type'] = $sOSMType;
$aPlace['osm_id'] = $aPointDetails['osm_id']; $aPlace['osm_id'] = $aPointDetails['osm_id'];
} }
if (isset($aPointDetails['aBoundingBox'])) if (isset($aPointDetails['aBoundingBox'])) {
{
$aPlace['boundingbox'] = array( $aPlace['boundingbox'] = array(
$aPointDetails['aBoundingBox'][0], $aPointDetails['aBoundingBox'][0],
$aPointDetails['aBoundingBox'][1], $aPointDetails['aBoundingBox'][1],
$aPointDetails['aBoundingBox'][2], $aPointDetails['aBoundingBox'][2],
$aPointDetails['aBoundingBox'][3]); $aPointDetails['aBoundingBox'][3]
);
if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons) if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons) {
{
$aPlace['polygonpoints'] = $aPointDetails['aPolyPoints']; $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
} }
} }
if (isset($aPointDetails['zoom'])) if (isset($aPointDetails['zoom'])) {
{
$aPlace['zoom'] = $aPointDetails['zoom']; $aPlace['zoom'] = $aPointDetails['zoom'];
} }
@@ -50,33 +45,27 @@ foreach($aBatchResults as $aSearchResults)
$aPlace['importance'] = $aPointDetails['importance']; $aPlace['importance'] = $aPointDetails['importance'];
if (isset($aPointDetails['icon'])) if (isset($aPointDetails['icon'])) {
{
$aPlace['icon'] = $aPointDetails['icon']; $aPlace['icon'] = $aPointDetails['icon'];
} }
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) {
{
$aPlace['address'] = $aPointDetails['address']; $aPlace['address'] = $aPointDetails['address'];
} }
if (isset($aPointDetails['asgeojson'])) if (isset($aPointDetails['asgeojson'])) {
{
$aPlace['geojson'] = json_decode($aPointDetails['asgeojson']); $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
} }
if (isset($aPointDetails['assvg'])) if (isset($aPointDetails['assvg'])) {
{
$aPlace['svg'] = $aPointDetails['assvg']; $aPlace['svg'] = $aPointDetails['assvg'];
} }
if (isset($aPointDetails['astext'])) if (isset($aPointDetails['astext'])) {
{
$aPlace['geotext'] = $aPointDetails['astext']; $aPlace['geotext'] = $aPointDetails['astext'];
} }
if (isset($aPointDetails['askml'])) if (isset($aPointDetails['askml'])) {
{
$aPlace['geokml'] = $aPointDetails['askml']; $aPlace['geokml'] = $aPointDetails['askml'];
} }

View File

@@ -1,33 +1,28 @@
<?php <?php
header("content-type: application/json; charset=UTF-8"); header('content-type: application/json; charset=UTF-8');
$aFilteredPlaces = array(); $aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails) foreach ($aSearchResults as $iResNum => $aPointDetails) {
{
$aPlace = array( $aPlace = array(
'place_id'=>$aPointDetails['place_id'], 'place_id'=>$aPointDetails['place_id'],
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright", 'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright',
); );
$sOSMType = formatOSMType($aPointDetails['osm_type']); $sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType) if ($sOSMType) {
{
$aPlace['osm_type'] = $sOSMType; $aPlace['osm_type'] = $sOSMType;
$aPlace['osm_id'] = $aPointDetails['osm_id']; $aPlace['osm_id'] = $aPointDetails['osm_id'];
} }
if (isset($aPointDetails['aBoundingBox'])) if (isset($aPointDetails['aBoundingBox'])) {
{
$aPlace['boundingbox'] = $aPointDetails['aBoundingBox']; $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
if (isset($aPointDetails['aPolyPoints'])) if (isset($aPointDetails['aPolyPoints'])) {
{
$aPlace['polygonpoints'] = $aPointDetails['aPolyPoints']; $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
} }
} }
if (isset($aPointDetails['zoom'])) if (isset($aPointDetails['zoom'])) {
{
$aPlace['zoom'] = $aPointDetails['zoom']; $aPlace['zoom'] = $aPointDetails['zoom'];
} }
@@ -40,33 +35,27 @@ foreach($aSearchResults as $iResNum => $aPointDetails)
$aPlace['importance'] = $aPointDetails['importance']; $aPlace['importance'] = $aPointDetails['importance'];
if (isset($aPointDetails['icon']) && $aPointDetails['icon']) if (isset($aPointDetails['icon']) && $aPointDetails['icon']) {
{
$aPlace['icon'] = $aPointDetails['icon']; $aPlace['icon'] = $aPointDetails['icon'];
} }
if (isset($aPointDetails['address'])) if (isset($aPointDetails['address'])) {
{
$aPlace['address'] = $aPointDetails['address']; $aPlace['address'] = $aPointDetails['address'];
} }
if (isset($aPointDetails['asgeojson'])) if (isset($aPointDetails['asgeojson'])) {
{
$aPlace['geojson'] = json_decode($aPointDetails['asgeojson']); $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
} }
if (isset($aPointDetails['assvg'])) if (isset($aPointDetails['assvg'])) {
{
$aPlace['svg'] = $aPointDetails['assvg']; $aPlace['svg'] = $aPointDetails['assvg'];
} }
if (isset($aPointDetails['astext'])) if (isset($aPointDetails['astext'])) {
{
$aPlace['geotext'] = $aPointDetails['astext']; $aPlace['geotext'] = $aPointDetails['astext'];
} }
if (isset($aPointDetails['askml'])) if (isset($aPointDetails['askml'])) {
{
$aPlace['geokml'] = $aPointDetails['askml']; $aPlace['geokml'] = $aPointDetails['askml'];
} }

View File

@@ -1,32 +1,27 @@
<?php <?php
$aFilteredPlaces = array(); $aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails) foreach ($aSearchResults as $iResNum => $aPointDetails) {
{
$aPlace = array( $aPlace = array(
'place_id'=>$aPointDetails['place_id'], 'place_id'=>$aPointDetails['place_id'],
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright", 'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
); );
$sOSMType = formatOSMType($aPointDetails['osm_type']); $sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType) if ($sOSMType) {
{
$aPlace['osm_type'] = $sOSMType; $aPlace['osm_type'] = $sOSMType;
$aPlace['osm_id'] = $aPointDetails['osm_id']; $aPlace['osm_id'] = $aPointDetails['osm_id'];
} }
if (isset($aPointDetails['aBoundingBox'])) if (isset($aPointDetails['aBoundingBox'])) {
{
$aPlace['boundingbox'] = $aPointDetails['aBoundingBox']; $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
if (isset($aPointDetails['aPolyPoints'])) if (isset($aPointDetails['aPolyPoints'])) {
{
$aPlace['polygonpoints'] = $aPointDetails['aPolyPoints']; $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
} }
} }
if (isset($aPointDetails['zoom'])) if (isset($aPointDetails['zoom'])) {
{
$aPlace['zoom'] = $aPointDetails['zoom']; $aPlace['zoom'] = $aPointDetails['zoom'];
} }
@@ -40,33 +35,27 @@ foreach($aSearchResults as $iResNum => $aPointDetails)
$aPlace['importance'] = $aPointDetails['importance']; $aPlace['importance'] = $aPointDetails['importance'];
if (isset($aPointDetails['icon'])) if (isset($aPointDetails['icon'])) {
{
$aPlace['icon'] = $aPointDetails['icon']; $aPlace['icon'] = $aPointDetails['icon'];
} }
if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) {
{
$aPlace['address'] = $aPointDetails['address']; $aPlace['address'] = $aPointDetails['address'];
} }
if (isset($aPointDetails['asgeojson'])) if (isset($aPointDetails['asgeojson'])) {
{
$aPlace['geojson'] = json_decode($aPointDetails['asgeojson']); $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
} }
if (isset($aPointDetails['assvg'])) if (isset($aPointDetails['assvg'])) {
{
$aPlace['svg'] = $aPointDetails['assvg']; $aPlace['svg'] = $aPointDetails['assvg'];
} }
if (isset($aPointDetails['astext'])) if (isset($aPointDetails['astext'])) {
{
$aPlace['geotext'] = $aPointDetails['astext']; $aPlace['geotext'] = $aPointDetails['astext'];
} }
if (isset($aPointDetails['askml'])) if (isset($aPointDetails['askml'])) {
{
$aPlace['geokml'] = $aPointDetails['askml']; $aPlace['geokml'] = $aPointDetails['askml'];
} }

View File

@@ -1,72 +1,63 @@
<?php <?php
header("content-type: text/xml; charset=UTF-8"); header('content-type: text/xml; charset=UTF-8');
echo "<"; echo '<';
echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?"; echo '?xml version="1.0" encoding="UTF-8" ?';
echo ">\n"; echo ">\n";
echo "<"; echo '<';
echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults'); echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults');
echo " timestamp='".date(DATE_RFC822)."'"; echo " timestamp='".date(DATE_RFC822)."'";
echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'"; echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'"; echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
if (isset($aMoreParams['viewbox'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'"; if (isset($aMoreParams['viewbox'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
echo " polygon='".(isset($aMoreParams['polygon'])?'true':'false')."'"; echo " polygon='".(isset($aMoreParams['polygon'])?'true':'false')."'";
if (isset($aMoreParams['exclude_place_ids'])) if (isset($aMoreParams['exclude_place_ids'])) {
{
echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'"; echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
} }
echo " more_url='".htmlspecialchars($sMoreURL)."'"; echo " more_url='".htmlspecialchars($sMoreURL)."'";
echo ">\n"; echo ">\n";
foreach($aSearchResults as $iResNum => $aResult) foreach ($aSearchResults as $iResNum => $aResult) {
{
echo "<place place_id='".$aResult['place_id']."'"; echo "<place place_id='".$aResult['place_id']."'";
$sOSMType = formatOSMType($aResult['osm_type']); $sOSMType = formatOSMType($aResult['osm_type']);
if ($sOSMType) if ($sOSMType) {
{
echo " osm_type='$sOSMType'"; echo " osm_type='$sOSMType'";
echo " osm_id='".$aResult['osm_id']."'"; echo " osm_id='".$aResult['osm_id']."'";
} }
echo " place_rank='".$aResult['rank_search']."'"; echo " place_rank='".$aResult['rank_search']."'";
if (isset($aResult['aBoundingBox'])) if (isset($aResult['aBoundingBox'])) {
{
echo ' boundingbox="'; echo ' boundingbox="';
echo join(',',$aResult['aBoundingBox']); echo join(',', $aResult['aBoundingBox']);
echo '"'; echo '"';
if (isset($aResult['aPolyPoints'])) if (isset($aResult['aPolyPoints'])) {
{
echo ' polygonpoints=\''; echo ' polygonpoints=\'';
echo json_encode($aResult['aPolyPoints']); echo json_encode($aResult['aPolyPoints']);
echo '\''; echo '\'';
} }
} }
if (isset($aResult['asgeojson'])) if (isset($aResult['asgeojson'])) {
{
echo ' geojson=\''; echo ' geojson=\'';
echo $aResult['asgeojson']; echo $aResult['asgeojson'];
echo '\''; echo '\'';
} }
if (isset($aResult['assvg'])) if (isset($aResult['assvg'])) {
{
echo ' geosvg=\''; echo ' geosvg=\'';
echo $aResult['assvg']; echo $aResult['assvg'];
echo '\''; echo '\'';
} }
if (isset($aResult['astext'])) if (isset($aResult['astext'])) {
{
echo ' geotext=\''; echo ' geotext=\'';
echo $aResult['astext']; echo $aResult['astext'];
echo '\''; echo '\'';
} }
if (isset($aResult['zoom'])) if (isset($aResult['zoom'])) {
{
echo " zoom='".$aResult['zoom']."'"; echo " zoom='".$aResult['zoom']."'";
} }
@@ -77,82 +68,67 @@ foreach($aSearchResults as $iResNum => $aResult)
echo " class='".htmlspecialchars($aResult['class'])."'"; echo " class='".htmlspecialchars($aResult['class'])."'";
echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'"; echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
echo " importance='".htmlspecialchars($aResult['importance'])."'"; echo " importance='".htmlspecialchars($aResult['importance'])."'";
if (isset($aResult['icon']) && $aResult['icon']) if (isset($aResult['icon']) && $aResult['icon']) {
{
echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'"; echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
} }
$bHasDelim = false; $bHasDelim = false;
if (isset($aResult['askml'])) if (isset($aResult['askml'])) {
{ if (!$bHasDelim) {
if (!$bHasDelim)
{
$bHasDelim = true; $bHasDelim = true;
echo ">"; echo '>';
} }
echo "\n<geokml>"; echo "\n<geokml>";
echo $aResult['askml']; echo $aResult['askml'];
echo "</geokml>"; echo '</geokml>';
} }
if (isset($aResult['sExtraTags'])) if (isset($aResult['sExtraTags'])) {
{ if (!$bHasDelim) {
if (!$bHasDelim)
{
$bHasDelim = true; $bHasDelim = true;
echo ">"; echo '>';
} }
echo "\n<extratags>"; echo "\n<extratags>";
foreach ($aResult['sExtraTags'] as $sKey => $sValue) foreach ($aResult['sExtraTags'] as $sKey => $sValue) {
{
echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>'; echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
} }
echo "</extratags>"; echo '</extratags>';
} }
if (isset($aResult['sNameDetails'])) if (isset($aResult['sNameDetails'])) {
{ if (!$bHasDelim) {
if (!$bHasDelim)
{
$bHasDelim = true; $bHasDelim = true;
echo ">"; echo '>';
} }
echo "\n<namedetails>"; echo "\n<namedetails>";
foreach ($aResult['sNameDetails'] as $sKey => $sValue) foreach ($aResult['sNameDetails'] as $sKey => $sValue) {
{
echo '<name desc="'.htmlspecialchars($sKey).'">'; echo '<name desc="'.htmlspecialchars($sKey).'">';
echo htmlspecialchars($sValue); echo htmlspecialchars($sValue);
echo "</name>"; echo '</name>';
} }
echo "</namedetails>"; echo '</namedetails>';
} }
if (isset($aResult['address'])) if (isset($aResult['address'])) {
{ if (!$bHasDelim) {
if (!$bHasDelim)
{
$bHasDelim = true; $bHasDelim = true;
echo ">"; echo '>';
} }
echo "\n"; echo "\n";
foreach($aResult['address'] as $sKey => $sValue) foreach ($aResult['address'] as $sKey => $sValue) {
{ $sKey = str_replace(' ', '_', $sKey);
$sKey = str_replace(' ','_',$sKey);
echo "<$sKey>"; echo "<$sKey>";
echo htmlspecialchars($sValue); echo htmlspecialchars($sValue);
echo "</$sKey>"; echo "</$sKey>";
} }
} }
if ($bHasDelim) if ($bHasDelim) {
{ echo '</place>';
echo "</place>"; } else {
} echo '/>';
else
{
echo "/>";
} }
} }
echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">"; echo '</' . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . '>';

View File

@@ -1,6 +1,7 @@
<?php <?php
require_once 'SebastianBergmann/CodeCoverage/autoload.php'; require_once 'SebastianBergmann/CodeCoverage/autoload.php';
function coverage_shutdown($oCoverage) function coverage_shutdown($oCoverage)
{ {
$oCoverage->stop(); $oCoverage->stop();
@@ -16,5 +17,3 @@ $coverage->start($_SERVER['COV_TEST_NAME']);
register_shutdown_function('coverage_shutdown', $coverage); register_shutdown_function('coverage_shutdown', $coverage);
include $_SERVER['COV_SCRIPT_FILENAME']; include $_SERVER['COV_SCRIPT_FILENAME'];

View File

@@ -6,6 +6,8 @@ require_once '../../lib/Phrase.php';
class PhraseTest extends \PHPUnit_Framework_TestCase class PhraseTest extends \PHPUnit_Framework_TestCase
{ {
private function serializeSets($aSets) private function serializeSets($aSets)
{ {
$aParts = array(); $aParts = array();

View File

@@ -10,6 +10,7 @@ class SearchContextTest extends \PHPUnit_Framework_TestCase
{ {
private $oCtx; private $oCtx;
protected function setUp() protected function setUp()
{ {
$this->oCtx = new SearchContext(); $this->oCtx = new SearchContext();