--- /dev/null
+<?php
+
+ function formatOSMType($sType, $bIncludeExternal=true)
+ {
+ if ($sType == 'N') return 'node';
+ if ($sType == 'W') return 'way';
+ if ($sType == 'R') return 'relation';
+
+ if (!$bIncludeExternal) return '';
+
+ if ($sType == 'T') return 'tiger';
+ if ($sType == 'I') return 'way';
+
+ return '';
+ }
+
+ function osmLink($aFeature, $sRefText=false)
+ {
+ $sOSMType = formatOSMType($aFeature['osm_type'], false);
+ if ($sOSMType)
+ {
+ return '<a href="//www.openstreetmap.org/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.($sRefText?$sRefText:$aFeature['osm_id']).'</a>';
+ }
+ return '';
+ }
+
+ function wikipediaLink($aFeature)
+ {
+ if ($aFeature['wikipedia'])
+ {
+ list($sLanguage, $sArticle) = explode(':',$aFeature['wikipedia']);
+ return '<a href="https://'.$sLanguage.'.wikipedia.org/wiki/'.urlencode($sArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
+ }
+ return '';
+ }
+
+ function detailsLink($aFeature, $sTitle=false)
+ {
+ if (!$aFeature['place_id']) return '';
+
+ return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
+ }
+
{
if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
- $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':
- ($aPlace['osm_type'] == 'T'?'tiger':($aPlace['osm_type'] == 'I'?'interpolation':'')))));
+ $sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType)
{
$aFilteredPlaces['osm_type'] = $sOSMType;
{
$aFilteredPlaces['geokml'] = $aPlace['askml'];
}
-
-
}
javascript_renderData($aFilteredPlaces);
{
if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
$aFilteredPlaces['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
- $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':
- ($aPlace['osm_type'] == 'T'?'tiger':($aPlace['osm_type'] == 'I'?'interpolation':'')))));
+ $sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType)
{
$aFilteredPlaces['osm_type'] = $sOSMType;
{
echo "<result";
if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
- $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':
- ($aPlace['osm_type'] == 'T'?'tiger':($aPlace['osm_type'] == 'I'?'interpolation':'')))));
+ $sOSMType = formatOSMType($aPlace['osm_type']);
if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
<?php
- function osm_link($aFeature)
- {
- $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
- if ($sOSMType) {
- return '<a href="http://www.openstreetmap.org/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.$aFeature['osm_id'].'</a>';
- }
- return '';
- }
-
- function osm_map_url($aFeature)
+ function osmMapUrl($aFeature)
{
$sLon = $aFeature['error_x'];
$sLat = $aFeature['error_y'];
- if (isset($sLat))
+ if (isset($sFeature['error_x']) && isset($sFeature['error_y']))
{
- $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
+ $sBaseUrl = '//www.openstreetmap.org/';
+ $sOSMType = formatOSMType($aFeature['osm_type'], false);
if ($sOSMType)
{
- return "http://www.openstreetmap.org/?lat=".$sLat."&lon=".$sLon."&zoom=18&layers=M&".$sOSMType."=".$aFeature['osm_id'];
+ $sBaseUrl += $sOSMType.'/'.$aFeature['osm_id'];
+ }
+
+ return '<a href="'.$sBaseUrl.'?mlat='.$sLat.'&mlon='.$sLon.'">view on osm.org</a>';
}
}
return '';
return "http://localhost:8111/load_and_zoom?left=".($sLon-$fWidth)."&right=".($sLon+$fWidth)."&top=".($sLat+$fWidth)."&bottom=".($sLat-$fWidth);
}
- $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
+ $sOSMType = formatOSMType($aFeature['osm_type'], false);
if ($sOSMType)
{
return 'http://localhost:8111/import?url=http://www.openstreetmap.org/api/0.6/'.$sOSMType.'/'.$aFeature['osm_id'].'/full';
if (isset($sLat))
{
- return "http://www.openstreetmap.org/edit?editor=potlatch2&bbox=".($sLon-$fWidth).",".($sLat-$fWidth).",".($sLon+$fWidth).",".($sLat+$fWidth);
+ return "//www.openstreetmap.org/edit?editor=potlatch2&bbox=".($sLon-$fWidth).",".($sLat-$fWidth).",".($sLon+$fWidth).",".($sLat+$fWidth);
}
return '';
}
</div>
<div>
- OSM: <span class="label"><?php echo osm_link($aPointDetails); ?><span>
+ OSM: <span class="label"><?php echo osmLink($aPointDetails); ?><span>
</div>
<p>
<?php echo $aPointDetails['errormessage']?$aPointDetails['errormessage']:'unknown'; ?>
</p>
- <?php if (osm_map_url($aPointDetails)) { ?>
- <a href="<?php echo osm_map_url($aPointDetails); ?>">view on osm.org</a>
- <?php } ?>
+ <?php echo osmMapUrl($aPointDetails); ?>
<h4>Edit</h4>
<ul>
</head>
-
<?php
function headline($sTitle)
echo "<tr class='all-columns'><td colspan='6'><h3>".$sTitle."</h3></td></tr>\n";
}
- function osm_link($aFeature)
- {
- $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
- if ($sOSMType)
- {
- return '<a href="http://www.openstreetmap.org/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.$aFeature['osm_id'].'</a>';
- }
- return '';
- }
-
- function wikipedia_link($aFeature)
- {
- if ($aFeature['wikipedia'])
- {
- list($sWikipediaLanguage,$sWikipediaArticle) = explode(':',$aFeature['wikipedia']);
- return '<a href="https://'.$sWikipediaLanguage.'.wikipedia.org/wiki/'.urlencode($sWikipediaArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
- }
- return '';
- }
-
- function nominatim_link($aFeature, $sTitle)
- {
- return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.$sTitle.'</a>';
- }
function format_distance($fDistance)
{
echo '<tr class="' . ($bNotUsed?'notused':'') . '">'."\n";
echo ' <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>')."</td>\n";
echo ' <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . "</td>\n";
- echo ' <td>' . osm_link($aAddressLine) . "</td>\n";
+ echo ' <td>' . osmLink($aAddressLine) . "</td>\n";
echo ' <td>' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . "</td>\n";
echo ' <td>' . format_distance($aAddressLine['distance'])."</td>\n";
- echo ' <td>' . nominatim_link($aAddressLine,'details >') . "</td>\n";
+ echo ' <td>' . detailsLink($aAddressLine,'details >') . "</td>\n";
echo "</tr>\n";
}
}
kv('Coverage' , ($aPointDetails['isarea']=='t'?'Polygon':'Point') );
kv('Centre Point' , $aPointDetails['lat'].','.$aPointDetails['lon'] );
- kv('OSM' , osm_link($aPointDetails) );
+ kv('OSM' , osmLink($aPointDetails) );
if ($aPointDetails['wikipedia'])
{
- kv('Wikipedia Calculated' , wikipedia_link($aPointDetails) );
+ kv('Wikipedia Calculated' , wikipediaLink($aPointDetails) );
}
kv('Extra Tags' , hash_to_subtable($aPointDetails['aExtraTags']) );
'place_id'=>$aPointDetails['place_id'],
);
- $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
+ $sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType)
{
$aPlace['osm_type'] = $sOSMType;
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
);
- $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?
- 'relation':($aPointDetails['osm_type'] == 'T'?'tiger':($aPointDetails['osm_type'] == 'I'?'interpolation':'')))));
+ $sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType)
{
$aPlace['osm_type'] = $sOSMType;
'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
);
- $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':($aPointDetails['osm_type'] == 'T'?'tiger':($aPointDetails['osm_type'] == 'I'?'interpolation':'')))));
+ $sOSMType = formatOSMType($aPointDetails['osm_type']);
if ($sOSMType)
{
$aPlace['osm_type'] = $sOSMType;
foreach($aSearchResults as $iResNum => $aResult)
{
echo "<place place_id='".$aResult['place_id']."'";
- $sOSMType = ($aResult['osm_type'] == 'N'?'node':($aResult['osm_type'] == 'W'?'way':($aResult['osm_type'] == 'R'?'relation':
- ($aResult['osm_type'] == 'T'?'tiger':($aResult['osm_type'] == 'I'?'interpolation':'')))));
+ $sOSMType = formatOSMType($aResult['osm_type']);
if ($sOSMType)
{
echo " osm_type='$sOSMType'";
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
require_once(CONST_BasePath.'/lib/init-website.php');
require_once(CONST_BasePath.'/lib/log.php');
+ require_once(CONST_BasePath.'/lib/output.php');
$sOutputFormat = 'html';
ini_set('memory_limit', '200M');
<table>
<?php
+ if (!$aPolygons) exit;
echo "<tr>";
//var_dump($aPolygons[0]);
foreach($aPolygons[0] as $sCol => $sVal)
switch($sCol)
{
case 'osm_id':
- $sOSMType = ($aRow['osm_type'] == 'N'?'node':($aRow['osm_type'] == 'W'?'way':($aRow['osm_type'] == 'R'?'relation':'')));
- echo '<td><a href="http://www.openstreetmap.org/'.$sOSMType.'/'.$sVal.'" target="_new">'.$sVal.'</a></td>';
+ echo '<td>'.osmLink($aRow).'</td>';
break;
case 'place_id':
- echo '<td><a href="'.CONST_Website_BaseURL.'details?place_id='.$sVal.'">'.$sVal.'</a></td>';
+ echo '<td>'.detailsLink($aRow).'</td>';
break;
default:
echo "<td>".($sVal?$sVal:' ')."</td>";
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
require_once(CONST_BasePath.'/lib/init-website.php');
require_once(CONST_BasePath.'/lib/log.php');
+ require_once(CONST_BasePath.'/lib/output.php');
$sOutputFormat = 'html';
/*
$sTileAttribution = CONST_Map_Tile_Attribution;
}
-
include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
require_once(CONST_BasePath.'/lib/init-website.php');
require_once(CONST_BasePath.'/lib/log.php');
require_once(CONST_BasePath.'/lib/PlaceLookup.php');
+ require_once(CONST_BasePath.'/lib/output.php');
ini_set('memory_limit', '200M');
$oDB =& getDB();
foreach($aPlaceAddress as $i => $aPlace)
{
if (!$aPlace['place_id']) continue;
- $aBreadcrums[] = array('placeId'=>$aPlace['place_id'], 'osmType'=>$aPlace['osm_type'], 'osmId'=>$aPlace['osm_id'], 'localName'=>$aPlace['localname']);
- $sPlaceUrl = 'hierarchy.php?place_id='.$aPlace['place_id'];
- $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));
- $sOSMUrl = 'http://www.openstreetmap.org/'.$sOSMType.'/'.$aPlace['osm_id'];
- if ($sOutputFormat == 'html') if ($i) echo " > ";
- if ($sOutputFormat == 'html') echo '<a href="'.$sPlaceUrl.'">'.$aPlace['localname'].'</a> (<a href="'.$sOSMUrl.'">osm</a>)';
+ $aBreadcrums[] = array('placeId' => $aPlace['place_id'],
+ 'osmType' => $aPlace['osm_type'],
+ 'osmId' => $aPlace['osm_id'],
+ 'localName' => $aPlace['localname']);
+
+ if ($sOutputFormat == 'html')
+ {
+ $sPlaceUrl = 'hierarchy.php?place_id='.$aPlace['place_id'];
+ if ($i) echo " > ";
+ echo '<a href="'.$sPlaceUrl.'">'.$aPlace['localname'].'</a> ('.osmLink($aPlace).')';
+ }
}
if (!isset($aGroupedAddressLines[$aAddressLine['label']])) $aGroupedAddressLines[$aAddressLine['label']] = array();
$aGroupedAddressLines[$aAddressLine['label']][] = $aAddressLine;
- }
- foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
+ }
+
+ foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
+ {
+ echo "<h3>$sGroupHeading</h3>";
+ foreach($aParentOfLines as $aAddressLine)
{
- echo "<h3>$sGroupHeading</h3>";
- foreach($aParentOfLines as $aAddressLine)
- {
- $aAddressLine['localname'] = $aAddressLine['localname']?$aAddressLine['localname']:$aAddressLine['housenumber'];
- $sOSMType = ($aAddressLine['osm_type'] == 'N'?'node':($aAddressLine['osm_type'] == 'W'?'way':($aAddressLine['osm_type'] == 'R'?'relation':'')));
-
- echo '<div class="line">';
- echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
- echo ' (';
- echo '<span class="area">'.($aAddressLine['isarea']=='t'?'Polygon':'Point').'</span>';
- if ($sOSMType) echo ', <span class="osm"><span class="label"></span>'.$sOSMType.' <a href="http://www.openstreetmap.org/'.$sOSMType.'/'.$aAddressLine['osm_id'].'">'.$aAddressLine['osm_id'].'</a></span>';
- echo ', <a href="hierarchy.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
- echo ', '.$aAddressLine['area'];
- echo ')';
- echo '</div>';
- }
+ $aAddressLine['localname'] = $aAddressLine['localname']?$aAddressLine['localname']:$aAddressLine['housenumber'];
+ $sOSMType = formatOSMType($aAddressLine['osm_type'], false);
+
+ echo '<div class="line">';
+ echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
+ echo ' (';
+ echo '<span class="area">'.($aAddressLine['isarea']=='t'?'Polygon':'Point').'</span>';
+ if ($sOSMType) echo ', <span class="osm"><span class="label"></span>'.$sOSMType.' '.osmLink($aAddressLine).'</span>';
+ echo ', <a href="hierarchy.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
+ echo ', '.$aAddressLine['area'];
+ echo ')';
+ echo '</div>';
}
- if (sizeof($aParentOfLines) >= 500) {
- echo '<p>There are more child objects which are not shown.</p>';
- }
- echo '</div>';
}
+ if (sizeof($aParentOfLines) >= 500) {
+ echo '<p>There are more child objects which are not shown.</p>';
+ }
+ echo '</div>';
+ }
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
require_once(CONST_BasePath.'/lib/init-website.php');
require_once(CONST_BasePath.'/lib/log.php');
+ require_once(CONST_BasePath.'/lib/output.php');
ini_set('memory_limit', '200M');
$oDB =& getDB();
<?php
echo "<p>Total number of broken polygons: $iTotalBroken</p>";
+ if (!$aPolygons) exit;
echo "<table>";
echo "<tr>";
//var_dump($aPolygons[0]);
}
break;
case 'id':
- $sOSMType = ($aRow['type'] == 'N'?'node':($aRow['type'] == 'W'?'way':($aRow['type'] == 'R'?'relation':'')));
- echo '<td><a href="http://www.openstreetmap.org/'.$sOSMType.'/'.$aRow['id'].'" target="_new">'.$aRow['id'].'</a></td>';
+ echo '<td>'.osmLink($aRow).'</td>';
break;
default:
echo "<td>".($sVal?$sVal:' ')."</td>";
echo "</tr>";
}
echo "</table>";
-
-
-
-// include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
?>
</body>
</html>
require_once(CONST_BasePath.'/lib/log.php');
require_once(CONST_BasePath.'/lib/PlaceLookup.php');
require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
+ require_once(CONST_BasePath.'/lib/output.php');
if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
{
require_once(CONST_BasePath.'/lib/init-website.php');
require_once(CONST_BasePath.'/lib/log.php');
require_once(CONST_BasePath.'/lib/Geocode.php');
+ require_once(CONST_BasePath.'/lib/output.php');
ini_set('memory_limit', '200M');