mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
tabs-to-spaces
This commit is contained in:
@@ -1,66 +1,66 @@
|
||||
<?php
|
||||
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');
|
||||
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');
|
||||
|
||||
$sOutputFormat = 'html';
|
||||
$sOutputFormat = 'html';
|
||||
|
||||
$oDB =& getDB();
|
||||
$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.");
|
||||
$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.");
|
||||
|
||||
if (CONST_DEBUG)
|
||||
{
|
||||
var_dump($aPolygons);
|
||||
exit;
|
||||
}
|
||||
if (CONST_DEBUG)
|
||||
{
|
||||
var_dump($aPolygons);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
|
||||
<title>Nominatim Deleted Data</title>
|
||||
|
||||
<meta name="description" content="List of OSM data that has been deleted" lang="en-US" />
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
|
||||
<title>Nominatim Deleted Data</title>
|
||||
|
||||
<meta name="description" content="List of OSM data that has been deleted" lang="en-US" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<style type="text/css">
|
||||
table {
|
||||
border-width: 1px;
|
||||
border-spacing: 0px;
|
||||
border-style: solid;
|
||||
border-color: gray;
|
||||
border-collapse: collapse;
|
||||
background-color: white;
|
||||
margin: 10px;
|
||||
border-width: 1px;
|
||||
border-spacing: 0px;
|
||||
border-style: solid;
|
||||
border-color: gray;
|
||||
border-collapse: collapse;
|
||||
background-color: white;
|
||||
margin: 10px;
|
||||
}
|
||||
table th {
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: #eee;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: #eee;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
}
|
||||
table td {
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: white;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: white;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -68,34 +68,34 @@ table td {
|
||||
|
||||
<table>
|
||||
<?php
|
||||
if (!$aPolygons) exit;
|
||||
echo "<tr>";
|
||||
if (!$aPolygons) exit;
|
||||
echo "<tr>";
|
||||
//var_dump($aPolygons[0]);
|
||||
foreach($aPolygons[0] as $sCol => $sVal)
|
||||
{
|
||||
echo "<th>".$sCol."</th>";
|
||||
}
|
||||
echo "</tr>";
|
||||
foreach($aPolygons as $aRow)
|
||||
{
|
||||
echo "<tr>";
|
||||
foreach($aRow as $sCol => $sVal)
|
||||
{
|
||||
switch($sCol)
|
||||
{
|
||||
case 'osm_id':
|
||||
echo '<td>'.osmLink($aRow).'</td>';
|
||||
break;
|
||||
case 'place_id':
|
||||
echo '<td>'.detailsLink($aRow).'</td>';
|
||||
break;
|
||||
default:
|
||||
echo "<td>".($sVal?$sVal:' ')."</td>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
foreach($aPolygons[0] as $sCol => $sVal)
|
||||
{
|
||||
echo "<th>".$sCol."</th>";
|
||||
}
|
||||
echo "</tr>";
|
||||
foreach($aPolygons as $aRow)
|
||||
{
|
||||
echo "<tr>";
|
||||
foreach($aRow as $sCol => $sVal)
|
||||
{
|
||||
switch($sCol)
|
||||
{
|
||||
case 'osm_id':
|
||||
echo '<td>'.osmLink($aRow).'</td>';
|
||||
break;
|
||||
case 'place_id':
|
||||
echo '<td>'.detailsLink($aRow).'</td>';
|
||||
break;
|
||||
default:
|
||||
echo "<td>".($sVal?$sVal:' ')."</td>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -1,164 +1,164 @@
|
||||
<?php
|
||||
@define('CONST_ConnectionBucket_PageType', 'Details');
|
||||
@define('CONST_ConnectionBucket_PageType', 'Details');
|
||||
|
||||
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');
|
||||
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');
|
||||
|
||||
$oParams = new ParameterParser();
|
||||
$oParams = new ParameterParser();
|
||||
|
||||
$sOutputFormat = 'html';
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
|
||||
$sOutputFormat = 'html';
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
|
||||
|
||||
$sPlaceId = $oParams->getString('place_id');
|
||||
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osmid', -1);
|
||||
$sPlaceId = $oParams->getString('place_id');
|
||||
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osmid', -1);
|
||||
|
||||
$oDB =& getDB();
|
||||
$oDB =& getDB();
|
||||
|
||||
if ($sOsmType && $iOsmId > 0)
|
||||
{
|
||||
$sPlaceId = chksql($oDB->getOne("select place_id from placex where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by type = 'postcode' asc"));
|
||||
if ($sOsmType && $iOsmId > 0)
|
||||
{
|
||||
$sPlaceId = chksql($oDB->getOne("select place_id from placex where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by type = 'postcode' asc"));
|
||||
|
||||
// Be nice about our error messages for broken geometry
|
||||
// Be nice about our error messages for broken geometry
|
||||
|
||||
if (!$sPlaceId)
|
||||
{
|
||||
$aPointDetails = chksql($oDB->getRow("select osm_type, osm_id, errormessage, class, type, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ST_AsText(prevgeometry) as prevgeom, ST_AsText(newgeometry) as newgeom from import_polygon_error where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by updated desc limit 1"));
|
||||
if (!PEAR::isError($aPointDetails) && $aPointDetails) {
|
||||
if (preg_match('/\[(-?\d+\.\d+) (-?\d+\.\d+)\]/', $aPointDetails['errormessage'], $aMatches))
|
||||
{
|
||||
$aPointDetails['error_x'] = $aMatches[1];
|
||||
$aPointDetails['error_y'] = $aMatches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$aPointDetails['error_x'] = 0;
|
||||
$aPointDetails['error_y'] = 0;
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$sPlaceId)
|
||||
{
|
||||
$aPointDetails = chksql($oDB->getRow("select osm_type, osm_id, errormessage, class, type, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ST_AsText(prevgeometry) as prevgeom, ST_AsText(newgeometry) as newgeom from import_polygon_error where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by updated desc limit 1"));
|
||||
if (!PEAR::isError($aPointDetails) && $aPointDetails) {
|
||||
if (preg_match('/\[(-?\d+\.\d+) (-?\d+\.\d+)\]/', $aPointDetails['errormessage'], $aMatches))
|
||||
{
|
||||
$aPointDetails['error_x'] = $aMatches[1];
|
||||
$aPointDetails['error_y'] = $aMatches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$aPointDetails['error_x'] = 0;
|
||||
$aPointDetails['error_y'] = 0;
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$sPlaceId) userError("Please select a place id");
|
||||
if (!$sPlaceId) userError("Please select a place id");
|
||||
|
||||
$iPlaceID = (int)$sPlaceId;
|
||||
$iPlaceID = (int)$sPlaceId;
|
||||
|
||||
if (CONST_Use_US_Tiger_Data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_tiger where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
if (CONST_Use_US_Tiger_Data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_tiger where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
|
||||
if (CONST_Use_Aux_Location_data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
if (CONST_Use_Aux_Location_data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
|
||||
$hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
$hLog = logStart($oDB, 'details', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
|
||||
// Get the details for this point
|
||||
$sSQL = "select place_id, osm_type, osm_id, class, type, name, admin_level, housenumber, street, isin, postcode, calculated_country_code as country_code, importance, wikipedia,";
|
||||
$sSQL .= " to_char(indexed_date, 'YYYY-MM-DD HH24:MI') as indexed_date, parent_place_id, rank_address, rank_search, get_searchrank_label(rank_search) as rank_search_label, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ";
|
||||
$sSQL .= " ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea, ";
|
||||
//$sSQL .= " ST_Area(geometry::geography) as area, ";
|
||||
$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['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
|
||||
// Get the details for this point
|
||||
$sSQL = "select place_id, osm_type, osm_id, class, type, name, admin_level, housenumber, street, isin, postcode, calculated_country_code as country_code, importance, wikipedia,";
|
||||
$sSQL .= " to_char(indexed_date, 'YYYY-MM-DD HH24:MI') as indexed_date, parent_place_id, rank_address, rank_search, get_searchrank_label(rank_search) as rank_search_label, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ";
|
||||
$sSQL .= " ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea, ";
|
||||
//$sSQL .= " ST_Area(geometry::geography) as area, ";
|
||||
$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['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
|
||||
|
||||
$aClassType = getClassTypesWithImportance();
|
||||
$aPointDetails['icon'] = $aClassType[$aPointDetails['class'].':'.$aPointDetails['type']]['icon'];
|
||||
$aClassType = getClassTypesWithImportance();
|
||||
$aPointDetails['icon'] = $aClassType[$aPointDetails['class'].':'.$aPointDetails['type']]['icon'];
|
||||
|
||||
// Get all alternative names (languages, etc)
|
||||
$sSQL = "select (each(name)).key,(each(name)).value from placex where place_id = $iPlaceID order by (each(name)).key";
|
||||
$aPointDetails['aNames'] = $oDB->getAssoc($sSQL);
|
||||
if (PEAR::isError($aPointDetails['aNames'])) // possible timeout
|
||||
{
|
||||
$aPointDetails['aNames'] = [];
|
||||
}
|
||||
// Get all alternative names (languages, etc)
|
||||
$sSQL = "select (each(name)).key,(each(name)).value from placex where place_id = $iPlaceID order by (each(name)).key";
|
||||
$aPointDetails['aNames'] = $oDB->getAssoc($sSQL);
|
||||
if (PEAR::isError($aPointDetails['aNames'])) // possible timeout
|
||||
{
|
||||
$aPointDetails['aNames'] = [];
|
||||
}
|
||||
|
||||
// Extra tags
|
||||
$sSQL = "select (each(extratags)).key,(each(extratags)).value from placex where place_id = $iPlaceID order by (each(extratags)).key";
|
||||
$aPointDetails['aExtraTags'] = $oDB->getAssoc($sSQL);
|
||||
if (PEAR::isError($aPointDetails['aExtraTags'])) // possible timeout
|
||||
{
|
||||
$aPointDetails['aExtraTags'] = [];
|
||||
}
|
||||
// Extra tags
|
||||
$sSQL = "select (each(extratags)).key,(each(extratags)).value from placex where place_id = $iPlaceID order by (each(extratags)).key";
|
||||
$aPointDetails['aExtraTags'] = $oDB->getAssoc($sSQL);
|
||||
if (PEAR::isError($aPointDetails['aExtraTags'])) // possible timeout
|
||||
{
|
||||
$aPointDetails['aExtraTags'] = [];
|
||||
}
|
||||
|
||||
// Address
|
||||
$aAddressLines = getAddressDetails($oDB, $sLanguagePrefArraySQL, $iPlaceID, $aPointDetails['country_code'], -1, true);
|
||||
// Address
|
||||
$aAddressLines = getAddressDetails($oDB, $sLanguagePrefArraySQL, $iPlaceID, $aPointDetails['country_code'], -1, true);
|
||||
|
||||
// Linked places
|
||||
$sSQL = "select placex.place_id, osm_type, osm_id, class, type, housenumber, admin_level, rank_address, ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea, ST_Distance_Spheroid(geometry, placegeometry, 'SPHEROID[\"WGS 84\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]') as distance, ";
|
||||
$sSQL .= " get_name_by_language(name,$sLanguagePrefArraySQL) as localname, length(name::text) as namelength ";
|
||||
$sSQL .= " from placex, (select centroid as placegeometry from placex where place_id = $iPlaceID) as x";
|
||||
$sSQL .= " where linked_place_id = $iPlaceID";
|
||||
$sSQL .= " order by rank_address asc,rank_search asc,get_name_by_language(name,$sLanguagePrefArraySQL),housenumber";
|
||||
$aLinkedLines = $oDB->getAll($sSQL);
|
||||
if (PEAR::isError($aLinkedLines)) // possible timeout
|
||||
{
|
||||
$aLinkedLines = [];
|
||||
}
|
||||
// Linked places
|
||||
$sSQL = "select placex.place_id, osm_type, osm_id, class, type, housenumber, admin_level, rank_address, ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea, ST_Distance_Spheroid(geometry, placegeometry, 'SPHEROID[\"WGS 84\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]') as distance, ";
|
||||
$sSQL .= " get_name_by_language(name,$sLanguagePrefArraySQL) as localname, length(name::text) as namelength ";
|
||||
$sSQL .= " from placex, (select centroid as placegeometry from placex where place_id = $iPlaceID) as x";
|
||||
$sSQL .= " where linked_place_id = $iPlaceID";
|
||||
$sSQL .= " order by rank_address asc,rank_search asc,get_name_by_language(name,$sLanguagePrefArraySQL),housenumber";
|
||||
$aLinkedLines = $oDB->getAll($sSQL);
|
||||
if (PEAR::isError($aLinkedLines)) // possible timeout
|
||||
{
|
||||
$aLinkedLines = [];
|
||||
}
|
||||
|
||||
// All places this is an imediate parent of
|
||||
$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_Distance_Spheroid(geometry, placegeometry, 'SPHEROID[\"WGS 84\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]') as distance, ";
|
||||
$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 = $iPlaceID order by rank_address asc,rank_search asc limit 500) as obj,";
|
||||
$sSQL .= " (select centroid as placegeometry from placex where place_id = $iPlaceID) as x";
|
||||
$sSQL .= " order by rank_address asc,rank_search asc,localname,housenumber";
|
||||
$aParentOfLines = $oDB->getAll($sSQL);
|
||||
if (PEAR::isError($aParentOfLines)) // possible timeout
|
||||
{
|
||||
$aParentOfLines = [];
|
||||
}
|
||||
// All places this is an imediate parent of
|
||||
$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_Distance_Spheroid(geometry, placegeometry, 'SPHEROID[\"WGS 84\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]') as distance, ";
|
||||
$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 = $iPlaceID order by rank_address asc,rank_search asc limit 500) as obj,";
|
||||
$sSQL .= " (select centroid as placegeometry from placex where place_id = $iPlaceID) as x";
|
||||
$sSQL .= " order by rank_address asc,rank_search asc,localname,housenumber";
|
||||
$aParentOfLines = $oDB->getAll($sSQL);
|
||||
if (PEAR::isError($aParentOfLines)) // possible timeout
|
||||
{
|
||||
$aParentOfLines = [];
|
||||
}
|
||||
|
||||
$aPlaceSearchNameKeywords = false;
|
||||
$aPlaceSearchAddressKeywords = false;
|
||||
if ($oParams->getBool('keywords'))
|
||||
{
|
||||
$sSQL = "select * from search_name where place_id = $iPlaceID";
|
||||
$aPlaceSearchName = $oDB->getRow($sSQL);
|
||||
if (PEAR::isError($aPlaceSearchName)) // possible timeout
|
||||
{
|
||||
$aPlaceSearchName = [];
|
||||
}
|
||||
$aPlaceSearchNameKeywords = false;
|
||||
$aPlaceSearchAddressKeywords = false;
|
||||
if ($oParams->getBool('keywords'))
|
||||
{
|
||||
$sSQL = "select * from search_name where place_id = $iPlaceID";
|
||||
$aPlaceSearchName = $oDB->getRow($sSQL);
|
||||
if (PEAR::isError($aPlaceSearchName)) // possible timeout
|
||||
{
|
||||
$aPlaceSearchName = [];
|
||||
}
|
||||
|
||||
$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['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).")";
|
||||
$aPlaceSearchAddressKeywords = $oDB->getAll($sSQL);
|
||||
if (PEAR::isError($aPlaceSearchAddressKeywords)) // possible timeout
|
||||
{
|
||||
$aPlaceSearchAddressKeywords = [];
|
||||
}
|
||||
$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 = [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
logEnd($oDB, $hLog, 1);
|
||||
logEnd($oDB, $hLog, 1);
|
||||
|
||||
if ($sOutputFormat=='html')
|
||||
{
|
||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||
$sTileURL = CONST_Map_Tile_URL;
|
||||
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||
}
|
||||
if ($sOutputFormat=='html')
|
||||
{
|
||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||
$sTileURL = CONST_Map_Tile_URL;
|
||||
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||
}
|
||||
|
||||
include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
|
||||
include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
|
||||
|
||||
@@ -1,149 +1,149 @@
|
||||
<?php
|
||||
@define('CONST_ConnectionBucket_PageType', 'Details');
|
||||
@define('CONST_ConnectionBucket_PageType', 'Details');
|
||||
|
||||
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/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
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/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
$oParams = new ParameterParser();
|
||||
$oParams = new ParameterParser();
|
||||
|
||||
$sOutputFormat = $oParams->getSet('format', array('html', 'json'), 'html');
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
|
||||
$sOutputFormat = $oParams->getSet('format', array('html', 'json'), 'html');
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
$sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$aLangPrefOrder))."]";
|
||||
|
||||
$sPlaceId = $oParams->getString('place_id');
|
||||
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osmid', -1);
|
||||
$sPlaceId = $oParams->getString('place_id');
|
||||
$sOsmType = $oParams->getSet('osmtype', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osmid', -1);
|
||||
|
||||
$oDB =& getDB();
|
||||
$oDB =& getDB();
|
||||
|
||||
if ($sOsmType && $iOsmId > 0)
|
||||
{
|
||||
$sPlaceId = chksql($oDB->getOne("select place_id from placex where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by type = 'postcode' asc"));
|
||||
if ($sOsmType && $iOsmId > 0)
|
||||
{
|
||||
$sPlaceId = chksql($oDB->getOne("select place_id from placex where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by type = 'postcode' asc"));
|
||||
|
||||
// Be nice about our error messages for broken geometry
|
||||
if (!$sPlaceId)
|
||||
{
|
||||
$aPointDetails = chksql($oDB->getRow("select osm_type, osm_id, errormessage, class, type, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ST_AsText(prevgeometry) as prevgeom, ST_AsText(newgeometry) as newgeom from import_polygon_error where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by updated desc limit 1"));
|
||||
if ($aPointDetails) {
|
||||
if (preg_match('/\[(-?\d+\.\d+) (-?\d+\.\d+)\]/', $aPointDetails['errormessage'], $aMatches))
|
||||
{
|
||||
$aPointDetails['error_x'] = $aMatches[1];
|
||||
$aPointDetails['error_y'] = $aMatches[2];
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Be nice about our error messages for broken geometry
|
||||
if (!$sPlaceId)
|
||||
{
|
||||
$aPointDetails = chksql($oDB->getRow("select osm_type, osm_id, errormessage, class, type, get_name_by_language(name,$sLanguagePrefArraySQL) as localname, ST_AsText(prevgeometry) as prevgeom, ST_AsText(newgeometry) as newgeom from import_polygon_error where osm_type = '".$sOsmType."' and osm_id = ".$iOsmId." order by updated desc limit 1"));
|
||||
if ($aPointDetails) {
|
||||
if (preg_match('/\[(-?\d+\.\d+) (-?\d+\.\d+)\]/', $aPointDetails['errormessage'], $aMatches))
|
||||
{
|
||||
$aPointDetails['error_x'] = $aMatches[1];
|
||||
$aPointDetails['error_y'] = $aMatches[2];
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/details-error-'.$sOutputFormat.'.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$sPlaceId) userError("Please select a place id");
|
||||
if (!$sPlaceId) userError("Please select a place id");
|
||||
|
||||
$iPlaceID = (int)$sPlaceId;
|
||||
$iPlaceID = (int)$sPlaceId;
|
||||
|
||||
if (CONST_Use_US_Tiger_Data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_tiger where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
if (CONST_Use_US_Tiger_Data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_tiger where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
|
||||
if (CONST_Use_Aux_Location_data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
if (CONST_Use_Aux_Location_data)
|
||||
{
|
||||
$iParentPlaceID = chksql($oDB->getOne('select parent_place_id from location_property_aux where place_id = '.$iPlaceID));
|
||||
if ($iParentPlaceID) $iPlaceID = $iParentPlaceID;
|
||||
}
|
||||
|
||||
$oPlaceLookup = new PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||
$oPlaceLookup = new PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails(true);
|
||||
|
||||
$aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID));
|
||||
$aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID));
|
||||
|
||||
if (!sizeof($aPlaceAddress)) userError("Unknown place id.");
|
||||
if (!sizeof($aPlaceAddress)) userError("Unknown place id.");
|
||||
|
||||
$aBreadcrums = array();
|
||||
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']);
|
||||
$aBreadcrums = array();
|
||||
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']);
|
||||
|
||||
if ($sOutputFormat == 'html')
|
||||
{
|
||||
$sPlaceUrl = 'hierarchy.php?place_id='.$aPlace['place_id'];
|
||||
if ($i) echo " > ";
|
||||
echo '<a href="'.$sPlaceUrl.'">'.$aPlace['localname'].'</a> ('.osmLink($aPlace).')';
|
||||
}
|
||||
}
|
||||
if ($sOutputFormat == 'html')
|
||||
{
|
||||
$sPlaceUrl = 'hierarchy.php?place_id='.$aPlace['place_id'];
|
||||
if ($i) echo " > ";
|
||||
echo '<a href="'.$sPlaceUrl.'">'.$aPlace['localname'].'</a> ('.osmLink($aPlace).')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($sOutputFormat == 'json')
|
||||
{
|
||||
header("content-type: application/json; charset=UTF-8");
|
||||
$aDetails = array();
|
||||
$aDetails['breadcrumbs'] = $aBreadcrums;
|
||||
javascript_renderData($aDetails);
|
||||
exit;
|
||||
}
|
||||
if ($sOutputFormat == 'json')
|
||||
{
|
||||
header("content-type: application/json; charset=UTF-8");
|
||||
$aDetails = array();
|
||||
$aDetails['breadcrumbs'] = $aBreadcrums;
|
||||
javascript_renderData($aDetails);
|
||||
exit;
|
||||
}
|
||||
|
||||
$aRelatedPlaceIDs = chksql($oDB->getCol($sSQL = "select place_id from placex where linked_place_id = $iPlaceID or place_id = $iPlaceID"));
|
||||
$aRelatedPlaceIDs = chksql($oDB->getCol($sSQL = "select place_id from placex where linked_place_id = $iPlaceID or place_id = $iPlaceID"));
|
||||
|
||||
$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 .= " order by rank_address asc,rank_search asc,localname,class, type,housenumber";
|
||||
$aParentOfLines = chksql($oDB->getAll($sSQL));
|
||||
$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 .= " order by rank_address asc,rank_search asc,localname,class, type,housenumber";
|
||||
$aParentOfLines = chksql($oDB->getAll($sSQL));
|
||||
|
||||
if (sizeof($aParentOfLines))
|
||||
{
|
||||
echo '<h2>Parent Of:</h2>';
|
||||
$aClassType = getClassTypesWithImportance();
|
||||
$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'])
|
||||
{
|
||||
$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'])
|
||||
{
|
||||
$aAddressLine['label'] = $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label'];
|
||||
}
|
||||
else $aAddressLine['label'] = ucwords($aAddressLine['type']);
|
||||
if (sizeof($aParentOfLines))
|
||||
{
|
||||
echo '<h2>Parent Of:</h2>';
|
||||
$aClassType = getClassTypesWithImportance();
|
||||
$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'])
|
||||
{
|
||||
$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'])
|
||||
{
|
||||
$aAddressLine['label'] = $aClassType[$aAddressLine['class'].':'.$aAddressLine['type']]['label'];
|
||||
}
|
||||
else $aAddressLine['label'] = ucwords($aAddressLine['type']);
|
||||
|
||||
if (!isset($aGroupedAddressLines[$aAddressLine['label']])) $aGroupedAddressLines[$aAddressLine['label']] = array();
|
||||
$aGroupedAddressLines[$aAddressLine['label']][] = $aAddressLine;
|
||||
}
|
||||
if (!isset($aGroupedAddressLines[$aAddressLine['label']])) $aGroupedAddressLines[$aAddressLine['label']] = array();
|
||||
$aGroupedAddressLines[$aAddressLine['label']][] = $aAddressLine;
|
||||
}
|
||||
|
||||
foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
|
||||
{
|
||||
echo "<h3>$sGroupHeading</h3>";
|
||||
foreach($aParentOfLines as $aAddressLine)
|
||||
{
|
||||
$aAddressLine['localname'] = $aAddressLine['localname']?$aAddressLine['localname']:$aAddressLine['housenumber'];
|
||||
$sOSMType = formatOSMType($aAddressLine['osm_type'], false);
|
||||
foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
|
||||
{
|
||||
echo "<h3>$sGroupHeading</h3>";
|
||||
foreach($aParentOfLines as $aAddressLine)
|
||||
{
|
||||
$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>';
|
||||
}
|
||||
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>';
|
||||
}
|
||||
|
||||
@@ -3,201 +3,201 @@ var last_click_latlng;
|
||||
|
||||
jQuery(document).on('ready', function(){
|
||||
|
||||
if ( !$('#search-page,#reverse-page').length ){ return; }
|
||||
|
||||
var is_reverse_search = !!( $('#reverse-page').length );
|
||||
if ( !$('#search-page,#reverse-page').length ){ return; }
|
||||
|
||||
var is_reverse_search = !!( $('#reverse-page').length );
|
||||
|
||||
$('#q').focus();
|
||||
$('#q').focus();
|
||||
|
||||
map = new L.map('map', {
|
||||
attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
|
||||
scrollWheelZoom: !L.Browser.touch,
|
||||
touchZoom: false
|
||||
});
|
||||
map = new L.map('map', {
|
||||
attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
|
||||
scrollWheelZoom: !L.Browser.touch,
|
||||
touchZoom: false
|
||||
});
|
||||
|
||||
L.tileLayer(nominatim_map_init.tile_url, {
|
||||
noWrap: true, // otherwise we end up with click coordinates like latitude -728
|
||||
// moved to footer
|
||||
attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
L.tileLayer(nominatim_map_init.tile_url, {
|
||||
noWrap: true, // otherwise we end up with click coordinates like latitude -728
|
||||
// moved to footer
|
||||
attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
map.setView([nominatim_map_init.lat, nominatim_map_init.lon], nominatim_map_init.zoom);
|
||||
map.setView([nominatim_map_init.lat, nominatim_map_init.lon], nominatim_map_init.zoom);
|
||||
|
||||
if ( is_reverse_search ){
|
||||
// We don't need a marker, but an L.circle instance changes radius once you zoom in/out
|
||||
var cm = L.circleMarker([nominatim_map_init.lat,nominatim_map_init.lon], { radius: 5, weight: 2, fillColor: '#ff7800', color: 'red', opacity: 0.75, clickable: false});
|
||||
cm.addTo(map);
|
||||
}
|
||||
if ( is_reverse_search ){
|
||||
// We don't need a marker, but an L.circle instance changes radius once you zoom in/out
|
||||
var cm = L.circleMarker([nominatim_map_init.lat,nominatim_map_init.lon], { radius: 5, weight: 2, fillColor: '#ff7800', color: 'red', opacity: 0.75, clickable: false});
|
||||
cm.addTo(map);
|
||||
}
|
||||
|
||||
var MapPositionControl = L.Control.extend({
|
||||
options: {
|
||||
position: 'topright'
|
||||
},
|
||||
var MapPositionControl = L.Control.extend({
|
||||
options: {
|
||||
position: 'topright'
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
var container = L.DomUtil.create('div', 'my-custom-control');
|
||||
onAdd: function (map) {
|
||||
var container = L.DomUtil.create('div', 'my-custom-control');
|
||||
|
||||
$(container).text('show map bounds').addClass('leaflet-bar btn btn-sm btn-default').on('click', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$('#map-position').show();
|
||||
$(container).hide();
|
||||
});
|
||||
$('#map-position-close a').on('click', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$('#map-position').hide();
|
||||
$(container).show();
|
||||
});
|
||||
$(container).text('show map bounds').addClass('leaflet-bar btn btn-sm btn-default').on('click', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$('#map-position').show();
|
||||
$(container).hide();
|
||||
});
|
||||
$('#map-position-close a').on('click', function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$('#map-position').hide();
|
||||
$(container).show();
|
||||
});
|
||||
|
||||
return container;
|
||||
}
|
||||
});
|
||||
return container;
|
||||
}
|
||||
});
|
||||
|
||||
map.addControl(new MapPositionControl());
|
||||
map.addControl(new MapPositionControl());
|
||||
|
||||
|
||||
function display_map_position(mouse_lat_lng){
|
||||
function display_map_position(mouse_lat_lng){
|
||||
|
||||
html_mouse = "mouse position " + (mouse_lat_lng ? [mouse_lat_lng.lat.toFixed(5), mouse_lat_lng.lng.toFixed(5)].join(',') : '-');
|
||||
html_click = "last click: " + (last_click_latlng ? [last_click_latlng.lat.toFixed(5),last_click_latlng.lng.toFixed(5)].join(',') : '-');
|
||||
html_mouse = "mouse position " + (mouse_lat_lng ? [mouse_lat_lng.lat.toFixed(5), mouse_lat_lng.lng.toFixed(5)].join(',') : '-');
|
||||
html_click = "last click: " + (last_click_latlng ? [last_click_latlng.lat.toFixed(5),last_click_latlng.lng.toFixed(5)].join(',') : '-');
|
||||
|
||||
html_center =
|
||||
"map center: " +
|
||||
map.getCenter().lat.toFixed(5) + ',' + map.getCenter().lng.toFixed(5) +
|
||||
" <a target='_blank' href='" + map_link_to_osm() + "'>view on osm.org</a>";
|
||||
html_center =
|
||||
"map center: " +
|
||||
map.getCenter().lat.toFixed(5) + ',' + map.getCenter().lng.toFixed(5) +
|
||||
" <a target='_blank' href='" + map_link_to_osm() + "'>view on osm.org</a>";
|
||||
|
||||
html_zoom = "map zoom: " + map.getZoom();
|
||||
html_zoom = "map zoom: " + map.getZoom();
|
||||
|
||||
html_viewbox = "viewbox: " + map_viewbox_as_string();
|
||||
html_viewbox = "viewbox: " + map_viewbox_as_string();
|
||||
|
||||
$('#map-position-inner').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
|
||||
$('input#use_viewbox').trigger('change');
|
||||
}
|
||||
$('#map-position-inner').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
|
||||
$('input#use_viewbox').trigger('change');
|
||||
}
|
||||
|
||||
map.on('move', function(e) {
|
||||
display_map_position();
|
||||
});
|
||||
map.on('move', function(e) {
|
||||
display_map_position();
|
||||
});
|
||||
|
||||
map.on('mousemove', function(e) {
|
||||
display_map_position(e.latlng);
|
||||
});
|
||||
map.on('mousemove', function(e) {
|
||||
display_map_position(e.latlng);
|
||||
});
|
||||
|
||||
map.on('click', function(e) {
|
||||
last_click_latlng = e.latlng;
|
||||
display_map_position();
|
||||
});
|
||||
map.on('click', function(e) {
|
||||
last_click_latlng = e.latlng;
|
||||
display_map_position();
|
||||
});
|
||||
|
||||
map.on('load', function(e){
|
||||
display_map_position();
|
||||
});
|
||||
map.on('load', function(e){
|
||||
display_map_position();
|
||||
});
|
||||
|
||||
|
||||
$('input#use_viewbox').on('change', function(){
|
||||
$('input[name=viewbox]').val( $(this).prop('checked') ? map_viewbox_as_string() : '');
|
||||
});
|
||||
$('input#use_viewbox').on('change', function(){
|
||||
$('input[name=viewbox]').val( $(this).prop('checked') ? map_viewbox_as_string() : '');
|
||||
});
|
||||
|
||||
|
||||
|
||||
function map_viewbox_as_string() {
|
||||
// since .toBBoxString() doesn't round numbers
|
||||
return [
|
||||
map.getBounds().getSouthWest().lat.toFixed(5),
|
||||
map.getBounds().getSouthWest().lng.toFixed(5),
|
||||
map.getBounds().getNorthEast().lat.toFixed(5),
|
||||
map.getBounds().getNorthEast().lng.toFixed(5) ].join(',');
|
||||
}
|
||||
function map_link_to_osm(){
|
||||
return "http://openstreetmap.org/#map=" + map.getZoom() + "/" + map.getCenter().lat + "/" + map.getCenter().lng;
|
||||
}
|
||||
function map_viewbox_as_string() {
|
||||
// since .toBBoxString() doesn't round numbers
|
||||
return [
|
||||
map.getBounds().getSouthWest().lat.toFixed(5),
|
||||
map.getBounds().getSouthWest().lng.toFixed(5),
|
||||
map.getBounds().getNorthEast().lat.toFixed(5),
|
||||
map.getBounds().getNorthEast().lng.toFixed(5) ].join(',');
|
||||
}
|
||||
function map_link_to_osm(){
|
||||
return "http://openstreetmap.org/#map=" + map.getZoom() + "/" + map.getCenter().lat + "/" + map.getCenter().lng;
|
||||
}
|
||||
|
||||
function get_result_element(position){
|
||||
return $('.result').eq(position);
|
||||
}
|
||||
function marker_for_result(result){
|
||||
return L.marker([result.lat,result.lon], {riseOnHover:true,title:result.name });
|
||||
}
|
||||
function circle_for_result(result){
|
||||
return L.circleMarker([result.lat,result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75, clickable: !is_reverse_search});
|
||||
}
|
||||
function get_result_element(position){
|
||||
return $('.result').eq(position);
|
||||
}
|
||||
function marker_for_result(result){
|
||||
return L.marker([result.lat,result.lon], {riseOnHover:true,title:result.name });
|
||||
}
|
||||
function circle_for_result(result){
|
||||
return L.circleMarker([result.lat,result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75, clickable: !is_reverse_search});
|
||||
}
|
||||
|
||||
var layerGroup = new L.layerGroup().addTo(map);
|
||||
function highlight_result(position, bool_focus){
|
||||
var result = nominatim_results[position];
|
||||
if (!result){ return }
|
||||
var result_el = get_result_element(position);
|
||||
var layerGroup = new L.layerGroup().addTo(map);
|
||||
function highlight_result(position, bool_focus){
|
||||
var result = nominatim_results[position];
|
||||
if (!result){ return }
|
||||
var result_el = get_result_element(position);
|
||||
|
||||
$('.result').removeClass('highlight');
|
||||
result_el.addClass('highlight');
|
||||
$('.result').removeClass('highlight');
|
||||
result_el.addClass('highlight');
|
||||
|
||||
layerGroup.clearLayers();
|
||||
layerGroup.clearLayers();
|
||||
|
||||
if (result.lat){
|
||||
var circle = circle_for_result(result);
|
||||
circle.on('click', function(){
|
||||
highlight_result(position);
|
||||
});
|
||||
layerGroup.addLayer(circle);
|
||||
}
|
||||
if (result.aBoundingBox){
|
||||
if (result.lat){
|
||||
var circle = circle_for_result(result);
|
||||
circle.on('click', function(){
|
||||
highlight_result(position);
|
||||
});
|
||||
layerGroup.addLayer(circle);
|
||||
}
|
||||
if (result.aBoundingBox){
|
||||
|
||||
var bounds = [[result.aBoundingBox[0]*1,result.aBoundingBox[2]*1], [result.aBoundingBox[1]*1,result.aBoundingBox[3]*1]];
|
||||
map.fitBounds(bounds);
|
||||
if (result.astext && result.astext.match(/(POLY)|(LINE)/) ){
|
||||
var geojson_layer = L.geoJson(null, {
|
||||
// http://leafletjs.com/reference.html#geojson-style
|
||||
style: function(feature) { return { clickable: false, color: 'blue' }; }
|
||||
});
|
||||
omnivore.wkt.parse(result.astext,null,geojson_layer);
|
||||
layerGroup.addLayer(geojson_layer);
|
||||
}
|
||||
else {
|
||||
// var layer = L.rectangle(bounds, {color: "#ff7800", weight: 1} );
|
||||
// layerGroup.addLayer(layer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( is_reverse_search ){
|
||||
// make sure the search coordinates are in the map view as well
|
||||
map.fitBounds([[result.lat,result.lon], [nominatim_map_init.lat,nominatim_map_init.lon]], {padding: [50,50], maxZoom: map.getZoom()});
|
||||
var bounds = [[result.aBoundingBox[0]*1,result.aBoundingBox[2]*1], [result.aBoundingBox[1]*1,result.aBoundingBox[3]*1]];
|
||||
map.fitBounds(bounds);
|
||||
if (result.astext && result.astext.match(/(POLY)|(LINE)/) ){
|
||||
var geojson_layer = L.geoJson(null, {
|
||||
// http://leafletjs.com/reference.html#geojson-style
|
||||
style: function(feature) { return { clickable: false, color: 'blue' }; }
|
||||
});
|
||||
omnivore.wkt.parse(result.astext,null,geojson_layer);
|
||||
layerGroup.addLayer(geojson_layer);
|
||||
}
|
||||
else {
|
||||
// var layer = L.rectangle(bounds, {color: "#ff7800", weight: 1} );
|
||||
// layerGroup.addLayer(layer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( is_reverse_search ){
|
||||
// make sure the search coordinates are in the map view as well
|
||||
map.fitBounds([[result.lat,result.lon], [nominatim_map_init.lat,nominatim_map_init.lon]], {padding: [50,50], maxZoom: map.getZoom()});
|
||||
|
||||
// better, but causes a leaflet warning
|
||||
// map.panInsideBounds([[result.lat,result.lon], [nominatim_map_init.lat,nominatim_map_init.lon]], {animate: false});
|
||||
}
|
||||
else {
|
||||
map.panTo([result.lat,result.lon], result.zoom || nominatim_map_init.zoom);
|
||||
}
|
||||
}
|
||||
// better, but causes a leaflet warning
|
||||
// map.panInsideBounds([[result.lat,result.lon], [nominatim_map_init.lat,nominatim_map_init.lon]], {animate: false});
|
||||
}
|
||||
else {
|
||||
map.panTo([result.lat,result.lon], result.zoom || nominatim_map_init.zoom);
|
||||
}
|
||||
}
|
||||
|
||||
// var crosshairIcon = L.icon({
|
||||
// iconUrl: 'images/crosshair.png',
|
||||
// iconSize: [12, 12],
|
||||
// iconAnchor: [6, 6],
|
||||
// });
|
||||
// var crossMarker = new L.Marker([result.lat,result.lon], { icon: crosshairIcon, clickable: false});
|
||||
// layerGroup.addLayer(crossMarker);
|
||||
// var crosshairIcon = L.icon({
|
||||
// iconUrl: 'images/crosshair.png',
|
||||
// iconSize: [12, 12],
|
||||
// iconAnchor: [6, 6],
|
||||
// });
|
||||
// var crossMarker = new L.Marker([result.lat,result.lon], { icon: crosshairIcon, clickable: false});
|
||||
// layerGroup.addLayer(crossMarker);
|
||||
|
||||
|
||||
|
||||
if (bool_focus){
|
||||
$('#map').focus();
|
||||
}
|
||||
}
|
||||
if (bool_focus){
|
||||
$('#map').focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('.result').on('click', function(e){
|
||||
highlight_result($(this).data('position'), true);
|
||||
});
|
||||
$('.result').on('click', function(e){
|
||||
highlight_result($(this).data('position'), true);
|
||||
});
|
||||
|
||||
if ( is_reverse_search ){
|
||||
map.on('click', function(e){
|
||||
$('form input[name=lat]').val( e.latlng.lat);
|
||||
$('form input[name=lon]').val( e.latlng.lng);
|
||||
$('form').submit();
|
||||
});
|
||||
}
|
||||
if ( is_reverse_search ){
|
||||
map.on('click', function(e){
|
||||
$('form input[name=lat]').val( e.latlng.lat);
|
||||
$('form input[name=lon]').val( e.latlng.lng);
|
||||
$('form').submit();
|
||||
});
|
||||
}
|
||||
|
||||
highlight_result(0, false);
|
||||
highlight_result(0, false);
|
||||
|
||||
|
||||
});
|
||||
@@ -205,41 +205,41 @@ jQuery(document).on('ready', function(){
|
||||
|
||||
jQuery(document).on('ready', function(){
|
||||
|
||||
if ( !$('#details-page').length ){ return; }
|
||||
if ( !$('#details-page').length ){ return; }
|
||||
|
||||
|
||||
map = new L.map('map', {
|
||||
// center: [nominatim_map_init.lat, nominatim_map_init.lon],
|
||||
// zoom: nominatim_map_init.zoom,
|
||||
attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
|
||||
scrollWheelZoom: false,
|
||||
touchZoom: false,
|
||||
});
|
||||
map = new L.map('map', {
|
||||
// center: [nominatim_map_init.lat, nominatim_map_init.lon],
|
||||
// zoom: nominatim_map_init.zoom,
|
||||
attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
|
||||
scrollWheelZoom: false,
|
||||
touchZoom: false,
|
||||
});
|
||||
|
||||
|
||||
L.tileLayer(nominatim_map_init.tile_url, {
|
||||
// moved to footer
|
||||
attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
L.tileLayer(nominatim_map_init.tile_url, {
|
||||
// moved to footer
|
||||
attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
|
||||
var layerGroup = new L.layerGroup().addTo(map);
|
||||
var layerGroup = new L.layerGroup().addTo(map);
|
||||
|
||||
var circle = L.circleMarker([nominatim_result.lat,nominatim_result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
|
||||
map.addLayer(circle);
|
||||
var circle = L.circleMarker([nominatim_result.lat,nominatim_result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
|
||||
map.addLayer(circle);
|
||||
|
||||
if ( nominatim_result.outlinestring ){
|
||||
if ( nominatim_result.outlinestring ){
|
||||
|
||||
var geojson_layer = L.geoJson(null, {
|
||||
// http://leafletjs.com/reference.html#geojson-style
|
||||
style: function(feature) { return { clickable: false, color: 'blue' }; }
|
||||
});
|
||||
omnivore.wkt.parse(nominatim_result.outlinestring,null,geojson_layer);
|
||||
layerGroup.addLayer(geojson_layer);
|
||||
map.fitBounds(geojson_layer.getBounds());
|
||||
} else {
|
||||
map.setView([nominatim_result.lat,nominatim_result.lon],10);
|
||||
}
|
||||
var geojson_layer = L.geoJson(null, {
|
||||
// http://leafletjs.com/reference.html#geojson-style
|
||||
style: function(feature) { return { clickable: false, color: 'blue' }; }
|
||||
});
|
||||
omnivore.wkt.parse(nominatim_result.outlinestring,null,geojson_layer);
|
||||
layerGroup.addLayer(geojson_layer);
|
||||
map.fitBounds(geojson_layer.getBounds());
|
||||
} else {
|
||||
map.setView([nominatim_result.lat,nominatim_result.lon],10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
div.olMap {
|
||||
z-index: 0;
|
||||
z-index: 0;
|
||||
padding: 0px!important;
|
||||
margin: 0px!important;
|
||||
cursor: default;
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
<?php
|
||||
@define('CONST_ConnectionBucket_PageType', 'Reverse');
|
||||
@define('CONST_ConnectionBucket_PageType', 'Reverse');
|
||||
|
||||
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/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
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/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
$oParams = new ParameterParser();
|
||||
$oParams = new ParameterParser();
|
||||
|
||||
// Format for output
|
||||
$sOutputFormat = $oParams->getSet('format', array('xml', 'json'), 'xml');
|
||||
// Format for output
|
||||
$sOutputFormat = $oParams->getSet('format', array('xml', 'json'), 'xml');
|
||||
|
||||
// Preferred language
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
// Preferred language
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
|
||||
$oDB =& getDB();
|
||||
$oDB =& getDB();
|
||||
|
||||
$hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
$hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
|
||||
$aSearchResults = array();
|
||||
$aCleanedQueryParts = array();
|
||||
$aSearchResults = array();
|
||||
$aCleanedQueryParts = array();
|
||||
|
||||
$oPlaceLookup = new PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
||||
$oPlaceLookup->setIncludeExtraTags($oParams->getBool('extratags', false));
|
||||
$oPlaceLookup->setIncludeNameDetails($oParams->getBool('namedetails', false));
|
||||
$oPlaceLookup = new PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
||||
$oPlaceLookup->setIncludeExtraTags($oParams->getBool('extratags', false));
|
||||
$oPlaceLookup->setIncludeNameDetails($oParams->getBool('namedetails', false));
|
||||
|
||||
$aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
|
||||
$aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
|
||||
|
||||
if (count($aOsmIds) > CONST_Places_Max_ID_count)
|
||||
{
|
||||
userError('Bulk User: Only ' . CONST_Places_Max_ID_count . " ids are allowed in one request.");
|
||||
}
|
||||
if (count($aOsmIds) > CONST_Places_Max_ID_count)
|
||||
{
|
||||
userError('Bulk User: Only ' . CONST_Places_Max_ID_count . " ids are allowed in one request.");
|
||||
}
|
||||
|
||||
foreach ($aOsmIds AS $sItem)
|
||||
{
|
||||
// Skip empty sItem
|
||||
if (empty($sItem)) continue;
|
||||
|
||||
$sType = $sItem[0];
|
||||
$iId = (int) substr($sItem, 1);
|
||||
if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
|
||||
{
|
||||
$aCleanedQueryParts[] = $sType . $iId;
|
||||
$oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
|
||||
if ($oPlace){
|
||||
// we want to use the search-* output templates, so we need to fill
|
||||
// $aSearchResults and slightly change the (reverse search) oPlace
|
||||
// key names
|
||||
$oResult = $oPlace;
|
||||
unset($oResult['aAddress']);
|
||||
if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
|
||||
unset($oResult['langaddress']);
|
||||
$oResult['name'] = $oPlace['langaddress'];
|
||||
$aSearchResults[] = $oResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($aOsmIds AS $sItem)
|
||||
{
|
||||
// Skip empty sItem
|
||||
if (empty($sItem)) continue;
|
||||
|
||||
$sType = $sItem[0];
|
||||
$iId = (int) substr($sItem, 1);
|
||||
if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
|
||||
{
|
||||
$aCleanedQueryParts[] = $sType . $iId;
|
||||
$oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
|
||||
if ($oPlace){
|
||||
// we want to use the search-* output templates, so we need to fill
|
||||
// $aSearchResults and slightly change the (reverse search) oPlace
|
||||
// key names
|
||||
$oResult = $oPlace;
|
||||
unset($oResult['aAddress']);
|
||||
if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
|
||||
unset($oResult['langaddress']);
|
||||
$oResult['name'] = $oPlace['langaddress'];
|
||||
$aSearchResults[] = $oResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CONST_Debug) exit;
|
||||
if (CONST_Debug) exit;
|
||||
|
||||
$sXmlRootTag = 'lookupresults';
|
||||
$sQuery = join(',',$aCleanedQueryParts);
|
||||
// we initialize these to avoid warnings in our logfile
|
||||
$sViewBox = '';
|
||||
$bShowPolygons = '';
|
||||
$aExcludePlaceIDs = [];
|
||||
$sMoreURL = '';
|
||||
$sXmlRootTag = 'lookupresults';
|
||||
$sQuery = join(',',$aCleanedQueryParts);
|
||||
// we initialize these to avoid warnings in our logfile
|
||||
$sViewBox = '';
|
||||
$bShowPolygons = '';
|
||||
$aExcludePlaceIDs = [];
|
||||
$sMoreURL = '';
|
||||
|
||||
include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');
|
||||
include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');
|
||||
|
||||
@@ -1,143 +1,143 @@
|
||||
<?php
|
||||
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');
|
||||
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');
|
||||
|
||||
$oParams = new ParameterParser();
|
||||
$oParams = new ParameterParser();
|
||||
|
||||
$sOutputFormat = 'html';
|
||||
$iDays = $oParams->getInt('days', 1);
|
||||
$bReduced = $oParams->getBool('reduced', false);
|
||||
$sClass = $oParams->getString('class', false);
|
||||
$sOutputFormat = 'html';
|
||||
$iDays = $oParams->getInt('days', 1);
|
||||
$bReduced = $oParams->getBool('reduced', false);
|
||||
$sClass = $oParams->getString('class', false);
|
||||
|
||||
$oDB =& getDB();
|
||||
$oDB =& getDB();
|
||||
|
||||
$iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
|
||||
$iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
|
||||
|
||||
$aPolygons = array();
|
||||
while($iTotalBroken && !sizeof($aPolygons))
|
||||
{
|
||||
$sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
|
||||
$sSQL .= 'country_code as "country",errormessage as "error message",updated';
|
||||
$sSQL .= " from import_polygon_error";
|
||||
$sSQL .= " where updated > 'now'::timestamp - '".$iDays." day'::interval";
|
||||
$iDays++;
|
||||
$aPolygons = array();
|
||||
while($iTotalBroken && !sizeof($aPolygons))
|
||||
{
|
||||
$sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
|
||||
$sSQL .= 'country_code as "country",errormessage as "error message",updated';
|
||||
$sSQL .= " from import_polygon_error";
|
||||
$sSQL .= " where updated > 'now'::timestamp - '".$iDays." day'::interval";
|
||||
$iDays++;
|
||||
|
||||
if ($bReduced) $sSQL .= " and errormessage like 'Area reduced%'";
|
||||
if ($sClass) $sSQL .= " and class = '".pg_escape_string($sClass)."'";
|
||||
$sSQL .= " order by updated desc limit 1000";
|
||||
$aPolygons = chksql($oDB->getAll($sSQL));
|
||||
}
|
||||
if ($bReduced) $sSQL .= " and errormessage like 'Area reduced%'";
|
||||
if ($sClass) $sSQL .= " and class = '".pg_escape_string($sClass)."'";
|
||||
$sSQL .= " order by updated desc limit 1000";
|
||||
$aPolygons = chksql($oDB->getAll($sSQL));
|
||||
}
|
||||
|
||||
if (CONST_Debug)
|
||||
{
|
||||
var_dump($aPolygons);
|
||||
exit;
|
||||
}
|
||||
if (CONST_Debug)
|
||||
{
|
||||
var_dump($aPolygons);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
|
||||
<title>Nominatim Broken Polygon Data</title>
|
||||
|
||||
<meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
|
||||
<title>Nominatim Broken Polygon Data</title>
|
||||
|
||||
<meta name="description" content="List of broken OSM polygon data by date" lang="en-US" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<style type="text/css">
|
||||
table {
|
||||
border-width: 1px;
|
||||
border-spacing: 0px;
|
||||
border-style: solid;
|
||||
border-color: gray;
|
||||
border-collapse: collapse;
|
||||
background-color: white;
|
||||
margin: 10px;
|
||||
border-width: 1px;
|
||||
border-spacing: 0px;
|
||||
border-style: solid;
|
||||
border-color: gray;
|
||||
border-collapse: collapse;
|
||||
background-color: white;
|
||||
margin: 10px;
|
||||
}
|
||||
table th {
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: #eee;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: #eee;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
}
|
||||
table td {
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: white;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
border-width: 1px;
|
||||
padding: 2px;
|
||||
border-style: inset;
|
||||
border-color: gray;
|
||||
border-left-color: #ddd;
|
||||
border-right-color: #ddd;
|
||||
background-color: white;
|
||||
-moz-border-radius: 0px 0px 0px 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php
|
||||
|
||||
echo "<p>Total number of broken polygons: $iTotalBroken</p>";
|
||||
if (!$aPolygons) exit;
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
echo "<p>Total number of broken polygons: $iTotalBroken</p>";
|
||||
if (!$aPolygons) exit;
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
//var_dump($aPolygons[0]);
|
||||
foreach($aPolygons[0] as $sCol => $sVal)
|
||||
{
|
||||
echo "<th>".$sCol."</th>";
|
||||
}
|
||||
echo "<th> </th>";
|
||||
echo "<th> </th>";
|
||||
echo "</tr>";
|
||||
$aSeen = array();
|
||||
foreach($aPolygons as $aRow)
|
||||
{
|
||||
if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
|
||||
$aSeen[$aRow['type'].$aRow['id']] = 1;
|
||||
echo "<tr>";
|
||||
foreach($aRow as $sCol => $sVal)
|
||||
{
|
||||
switch($sCol)
|
||||
{
|
||||
case 'error message':
|
||||
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:' ')."</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td>".($sVal?$sVal:' ')."</td>";
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
echo '<td>'.osmLink($aRow).'</td>';
|
||||
break;
|
||||
default:
|
||||
echo "<td>".($sVal?$sVal:' ')."</td>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo "<td><a href=\"http://localhost:8111/import?url=http://www.openstreetmap.org/api/0.6/".$sOSMType.'/'.$aRow['id']."/full\" target=\"josm\">josm</a></td>";
|
||||
if (isset($aRow['lat']))
|
||||
{
|
||||
echo "<td><a href=\"http://open.mapquestapi.com/dataedit/index_flash.html?lat=".$aRow['lat']."&lon=".$aRow['lon']."&zoom=18\" target=\"potlatch2\">P2</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td> </td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
foreach($aPolygons[0] as $sCol => $sVal)
|
||||
{
|
||||
echo "<th>".$sCol."</th>";
|
||||
}
|
||||
echo "<th> </th>";
|
||||
echo "<th> </th>";
|
||||
echo "</tr>";
|
||||
$aSeen = array();
|
||||
foreach($aPolygons as $aRow)
|
||||
{
|
||||
if (isset($aSeen[$aRow['type'].$aRow['id']])) continue;
|
||||
$aSeen[$aRow['type'].$aRow['id']] = 1;
|
||||
echo "<tr>";
|
||||
foreach($aRow as $sCol => $sVal)
|
||||
{
|
||||
switch($sCol)
|
||||
{
|
||||
case 'error message':
|
||||
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:' ')."</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td>".($sVal?$sVal:' ')."</td>";
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
echo '<td>'.osmLink($aRow).'</td>';
|
||||
break;
|
||||
default:
|
||||
echo "<td>".($sVal?$sVal:' ')."</td>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo "<td><a href=\"http://localhost:8111/import?url=http://www.openstreetmap.org/api/0.6/".$sOSMType.'/'.$aRow['id']."/full\" target=\"josm\">josm</a></td>";
|
||||
if (isset($aRow['lat']))
|
||||
{
|
||||
echo "<td><a href=\"http://open.mapquestapi.com/dataedit/index_flash.html?lat=".$aRow['lat']."&lon=".$aRow['lon']."&zoom=18\" target=\"potlatch2\">P2</a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td> </td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
<?php
|
||||
@define('CONST_ConnectionBucket_PageType', 'Reverse');
|
||||
@define('CONST_ConnectionBucket_PageType', 'Reverse');
|
||||
|
||||
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/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
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/PlaceLookup.php');
|
||||
require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
$oParams = new ParameterParser();
|
||||
$oParams = new ParameterParser();
|
||||
|
||||
$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)
|
||||
{
|
||||
if (CONST_PolygonOutput_MaximumTypes)
|
||||
{
|
||||
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
||||
}
|
||||
else
|
||||
{
|
||||
userError("Polygon output is disabled");
|
||||
}
|
||||
}
|
||||
$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)
|
||||
{
|
||||
if (CONST_PolygonOutput_MaximumTypes)
|
||||
{
|
||||
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
||||
}
|
||||
else
|
||||
{
|
||||
userError("Polygon output is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// Polygon simplification threshold (optional)
|
||||
$fThreshold = $oParams->getFloat('polygon_threshold', 0.0);
|
||||
// Polygon simplification threshold (optional)
|
||||
$fThreshold = $oParams->getFloat('polygon_threshold', 0.0);
|
||||
|
||||
// Format for output
|
||||
$sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2'), 'xml');
|
||||
// Format for output
|
||||
$sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2'), 'xml');
|
||||
|
||||
// Preferred language
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
// Preferred language
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
|
||||
$oDB =& getDB();
|
||||
$oDB =& getDB();
|
||||
|
||||
$hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
$hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
||||
|
||||
|
||||
$oPlaceLookup = new PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
||||
$oPlaceLookup->setIncludeExtraTags($oParams->getBool('extratags', false));
|
||||
$oPlaceLookup->setIncludeNameDetails($oParams->getBool('namedetails', false));
|
||||
$oPlaceLookup = new PlaceLookup($oDB);
|
||||
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
||||
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
||||
$oPlaceLookup->setIncludeExtraTags($oParams->getBool('extratags', false));
|
||||
$oPlaceLookup->setIncludeNameDetails($oParams->getBool('namedetails', false));
|
||||
|
||||
$sOsmType = $oParams->getSet('osm_type', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osm_id', -1);
|
||||
$fLat = $oParams->getFloat('lat');
|
||||
$fLon = $oParams->getFloat('lon');
|
||||
if ($sOsmType && $iOsmId > 0)
|
||||
{
|
||||
$aPlace = $oPlaceLookup->lookupOSMID($sOsmType, $iOsmId);
|
||||
}
|
||||
else if ($fLat !== false && $fLon !== false)
|
||||
{
|
||||
$oReverseGeocode = new ReverseGeocode($oDB);
|
||||
$oReverseGeocode->setZoom($oParams->getInt('zoom', 18));
|
||||
$sOsmType = $oParams->getSet('osm_type', array('N', 'W', 'R'));
|
||||
$iOsmId = $oParams->getInt('osm_id', -1);
|
||||
$fLat = $oParams->getFloat('lat');
|
||||
$fLon = $oParams->getFloat('lon');
|
||||
if ($sOsmType && $iOsmId > 0)
|
||||
{
|
||||
$aPlace = $oPlaceLookup->lookupOSMID($sOsmType, $iOsmId);
|
||||
}
|
||||
else if ($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);
|
||||
$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')
|
||||
{
|
||||
userError("Need coordinates or OSM object to lookup.");
|
||||
}
|
||||
$aPlace = $oPlaceLookup->lookup((int)$aLookup['place_id'],
|
||||
$aLookup['type'], $aLookup['fraction']);
|
||||
}
|
||||
else if ($sOutputFormat != 'html')
|
||||
{
|
||||
userError("Need coordinates or OSM object to lookup.");
|
||||
}
|
||||
|
||||
if ($aPlace)
|
||||
{
|
||||
$oPlaceLookup->setIncludePolygonAsPoints(false);
|
||||
$oPlaceLookup->setIncludePolygonAsText($bAsText);
|
||||
$oPlaceLookup->setIncludePolygonAsGeoJSON($bAsGeoJSON);
|
||||
$oPlaceLookup->setIncludePolygonAsKML($bAsKML);
|
||||
$oPlaceLookup->setIncludePolygonAsSVG($bAsSVG);
|
||||
$oPlaceLookup->setPolygonSimplificationThreshold($fThreshold);
|
||||
if ($aPlace)
|
||||
{
|
||||
$oPlaceLookup->setIncludePolygonAsPoints(false);
|
||||
$oPlaceLookup->setIncludePolygonAsText($bAsText);
|
||||
$oPlaceLookup->setIncludePolygonAsGeoJSON($bAsGeoJSON);
|
||||
$oPlaceLookup->setIncludePolygonAsKML($bAsKML);
|
||||
$oPlaceLookup->setIncludePolygonAsSVG($bAsSVG);
|
||||
$oPlaceLookup->setPolygonSimplificationThreshold($fThreshold);
|
||||
|
||||
$fRadius = $fDiameter = getResultDiameter($aPlace);
|
||||
$aOutlineResult = $oPlaceLookup->getOutlines($aPlace['place_id'],
|
||||
$aPlace['lon'], $aPlace['lat'],
|
||||
$fRadius);
|
||||
$fRadius = $fDiameter = getResultDiameter($aPlace);
|
||||
$aOutlineResult = $oPlaceLookup->getOutlines($aPlace['place_id'],
|
||||
$aPlace['lon'], $aPlace['lat'],
|
||||
$fRadius);
|
||||
|
||||
if ($aOutlineResult)
|
||||
{
|
||||
$aPlace = array_merge($aPlace, $aOutlineResult);
|
||||
}
|
||||
}
|
||||
if ($aOutlineResult)
|
||||
{
|
||||
$aPlace = array_merge($aPlace, $aOutlineResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CONST_Debug)
|
||||
{
|
||||
var_dump($aPlace);
|
||||
exit;
|
||||
}
|
||||
if (CONST_Debug)
|
||||
{
|
||||
var_dump($aPlace);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($sOutputFormat=='html')
|
||||
{
|
||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||
$sTileURL = CONST_Map_Tile_URL;
|
||||
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
|
||||
if ($sOutputFormat=='html')
|
||||
{
|
||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||
$sTileURL = CONST_Map_Tile_URL;
|
||||
$sTileAttribution = CONST_Map_Tile_Attribution;
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
|
||||
|
||||
@@ -1,132 +1,132 @@
|
||||
<?php
|
||||
@define('CONST_ConnectionBucket_PageType', 'Search');
|
||||
@define('CONST_ConnectionBucket_PageType', 'Search');
|
||||
|
||||
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/Geocode.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
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/Geocode.php');
|
||||
require_once(CONST_BasePath.'/lib/output.php');
|
||||
ini_set('memory_limit', '200M');
|
||||
|
||||
$oDB =& getDB();
|
||||
$oParams = new ParameterParser();
|
||||
$oDB =& getDB();
|
||||
$oParams = new ParameterParser();
|
||||
|
||||
$oGeocode = new Geocode($oDB);
|
||||
$oGeocode = new Geocode($oDB);
|
||||
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
$oGeocode->setLanguagePreference($aLangPrefOrder);
|
||||
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
||||
$oGeocode->setLanguagePreference($aLangPrefOrder);
|
||||
|
||||
if (CONST_Search_ReversePlanForAll
|
||||
|| isset($aLangPrefOrder['name:de'])
|
||||
|| isset($aLangPrefOrder['name:ru'])
|
||||
|| isset($aLangPrefOrder['name:ja'])
|
||||
|| isset($aLangPrefOrder['name:pl']))
|
||||
{
|
||||
$oGeocode->setReverseInPlan(true);
|
||||
}
|
||||
if (CONST_Search_ReversePlanForAll
|
||||
|| isset($aLangPrefOrder['name:de'])
|
||||
|| isset($aLangPrefOrder['name:ru'])
|
||||
|| isset($aLangPrefOrder['name:ja'])
|
||||
|| isset($aLangPrefOrder['name:pl']))
|
||||
{
|
||||
$oGeocode->setReverseInPlan(true);
|
||||
}
|
||||
|
||||
// Format for output
|
||||
$sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2'), 'html');
|
||||
// Format for output
|
||||
$sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2'), 'html');
|
||||
|
||||
// Show / use polygons
|
||||
if ($sOutputFormat == 'html')
|
||||
{
|
||||
$oGeocode->setIncludePolygonAsText($oParams->getBool('polygon'));
|
||||
$bAsText = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bAsPoints = $oParams->getBool('polygon');
|
||||
$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)
|
||||
+ ($bAsPoints?1:0)
|
||||
) > CONST_PolygonOutput_MaximumTypes)
|
||||
{
|
||||
if (CONST_PolygonOutput_MaximumTypes)
|
||||
{
|
||||
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
||||
}
|
||||
else
|
||||
{
|
||||
userError("Polygon output is disabled");
|
||||
}
|
||||
exit;
|
||||
}
|
||||
$oGeocode->setIncludePolygonAsPoints($bAsPoints);
|
||||
$oGeocode->setIncludePolygonAsText($bAsText);
|
||||
$oGeocode->setIncludePolygonAsGeoJSON($bAsGeoJSON);
|
||||
$oGeocode->setIncludePolygonAsKML($bAsKML);
|
||||
$oGeocode->setIncludePolygonAsSVG($bAsSVG);
|
||||
}
|
||||
// Show / use polygons
|
||||
if ($sOutputFormat == 'html')
|
||||
{
|
||||
$oGeocode->setIncludePolygonAsText($oParams->getBool('polygon'));
|
||||
$bAsText = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bAsPoints = $oParams->getBool('polygon');
|
||||
$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)
|
||||
+ ($bAsPoints?1:0)
|
||||
) > CONST_PolygonOutput_MaximumTypes)
|
||||
{
|
||||
if (CONST_PolygonOutput_MaximumTypes)
|
||||
{
|
||||
userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
|
||||
}
|
||||
else
|
||||
{
|
||||
userError("Polygon output is disabled");
|
||||
}
|
||||
exit;
|
||||
}
|
||||
$oGeocode->setIncludePolygonAsPoints($bAsPoints);
|
||||
$oGeocode->setIncludePolygonAsText($bAsText);
|
||||
$oGeocode->setIncludePolygonAsGeoJSON($bAsGeoJSON);
|
||||
$oGeocode->setIncludePolygonAsKML($bAsKML);
|
||||
$oGeocode->setIncludePolygonAsSVG($bAsSVG);
|
||||
}
|
||||
|
||||
// Polygon simplification threshold (optional)
|
||||
$oGeocode->setPolygonSimplificationThreshold($oParams->getFloat('polygon_threshold', 0.0));
|
||||
// Polygon simplification threshold (optional)
|
||||
$oGeocode->setPolygonSimplificationThreshold($oParams->getFloat('polygon_threshold', 0.0));
|
||||
|
||||
$oGeocode->loadParamArray($oParams);
|
||||
$oGeocode->loadParamArray($oParams);
|
||||
|
||||
if (CONST_Search_BatchMode && isset($_GET['batch']))
|
||||
{
|
||||
$aBatch = json_decode($_GET['batch'], true);
|
||||
$aBatchResults = array();
|
||||
foreach($aBatch as $aBatchParams)
|
||||
{
|
||||
$oBatchGeocode = clone $oGeocode;
|
||||
$oBatchParams = new ParameterParser($aBatchParams);
|
||||
$oBatchGeocode->loadParamArray($oBatchParams);
|
||||
$oBatchGeocode->setQueryFromParams($oBatchParams);
|
||||
$aSearchResults = $oBatchGeocode->lookup();
|
||||
$aBatchResults[] = $aSearchResults;
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/search-batch-json.php');
|
||||
exit;
|
||||
}
|
||||
if (CONST_Search_BatchMode && isset($_GET['batch']))
|
||||
{
|
||||
$aBatch = json_decode($_GET['batch'], true);
|
||||
$aBatchResults = array();
|
||||
foreach($aBatch as $aBatchParams)
|
||||
{
|
||||
$oBatchGeocode = clone $oGeocode;
|
||||
$oBatchParams = new ParameterParser($aBatchParams);
|
||||
$oBatchGeocode->loadParamArray($oBatchParams);
|
||||
$oBatchGeocode->setQueryFromParams($oBatchParams);
|
||||
$aSearchResults = $oBatchGeocode->lookup();
|
||||
$aBatchResults[] = $aSearchResults;
|
||||
}
|
||||
include(CONST_BasePath.'/lib/template/search-batch-json.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$oGeocode->setQueryFromParams($oParams);
|
||||
$oGeocode->setQueryFromParams($oParams);
|
||||
|
||||
if (!$oGeocode->getQueryString()
|
||||
&& isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'][0] == '/')
|
||||
{
|
||||
$sQuery = substr(rawurldecode($_SERVER['PATH_INFO']), 1);
|
||||
if (!$oGeocode->getQueryString()
|
||||
&& 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);
|
||||
$oGeocode->setQuery($sQuery);
|
||||
}
|
||||
// reverse order of '/' separated string
|
||||
$aPhrases = explode('/', $sQuery);
|
||||
$aPhrases = array_reverse($aPhrases);
|
||||
$sQuery = join(', ',$aPhrases);
|
||||
$oGeocode->setQuery($sQuery);
|
||||
}
|
||||
|
||||
$hLog = logStart($oDB, 'search', $oGeocode->getQueryString(), $aLangPrefOrder);
|
||||
$hLog = logStart($oDB, 'search', $oGeocode->getQueryString(), $aLangPrefOrder);
|
||||
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
if ($aSearchResults === false) $aSearchResults = array();
|
||||
$aSearchResults = $oGeocode->lookup();
|
||||
if ($aSearchResults === false) $aSearchResults = array();
|
||||
|
||||
if ($sOutputFormat=='html')
|
||||
{
|
||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||
}
|
||||
logEnd($oDB, $hLog, sizeof($aSearchResults));
|
||||
if ($sOutputFormat=='html')
|
||||
{
|
||||
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
|
||||
}
|
||||
logEnd($oDB, $hLog, sizeof($aSearchResults));
|
||||
|
||||
$sQuery = $oGeocode->getQueryString();
|
||||
$sViewBox = $oGeocode->getViewBoxString();
|
||||
$bShowPolygons = (isset($_GET['polygon']) && $_GET['polygon']);
|
||||
$aExcludePlaceIDs = $oGeocode->getExcludedPlaceIDs();
|
||||
$sQuery = $oGeocode->getQueryString();
|
||||
$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);
|
||||
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) $sMoreURL .= '&accept-language='.$_SERVER["HTTP_ACCEPT_LANGUAGE"];
|
||||
if ($bShowPolygons) $sMoreURL .= '&polygon=1';
|
||||
if ($oGeocode->getIncludeAddressDetails()) $sMoreURL .= '&addressdetails=1';
|
||||
if ($oGeocode->getIncludeExtraTags()) $sMoreURL .= '&extratags=1';
|
||||
if ($oGeocode->getIncludeNameDetails()) $sMoreURL .= '&namedetails=1';
|
||||
if ($sViewBox) $sMoreURL .= '&viewbox='.urlencode($sViewBox);
|
||||
if (isset($_GET['nearlat']) && isset($_GET['nearlon'])) $sMoreURL .= '&nearlat='.(float)$_GET['nearlat'].'&nearlon='.(float)$_GET['nearlon'];
|
||||
$sMoreURL .= '&q='.urlencode($sQuery);
|
||||
$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';
|
||||
if ($oGeocode->getIncludeExtraTags()) $sMoreURL .= '&extratags=1';
|
||||
if ($oGeocode->getIncludeNameDetails()) $sMoreURL .= '&namedetails=1';
|
||||
if ($sViewBox) $sMoreURL .= '&viewbox='.urlencode($sViewBox);
|
||||
if (isset($_GET['nearlat']) && isset($_GET['nearlon'])) $sMoreURL .= '&nearlat='.(float)$_GET['nearlat'].'&nearlon='.(float)$_GET['nearlon'];
|
||||
$sMoreURL .= '&q='.urlencode($sQuery);
|
||||
|
||||
if (CONST_Debug) exit;
|
||||
if (CONST_Debug) exit;
|
||||
|
||||
include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');
|
||||
include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
<?php
|
||||
@define('CONST_ConnectionBucket_PageType', 'Status');
|
||||
@define('CONST_ConnectionBucket_PageType', 'Status');
|
||||
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||
require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
|
||||
require_once(CONST_BasePath.'/lib/init-website.php');
|
||||
|
||||
function statusError($sMsg)
|
||||
{
|
||||
header("HTTP/1.0 500 Internal Server Error");
|
||||
echo "ERROR: ".$sMsg;
|
||||
exit;
|
||||
}
|
||||
function statusError($sMsg)
|
||||
{
|
||||
header("HTTP/1.0 500 Internal Server Error");
|
||||
echo "ERROR: ".$sMsg;
|
||||
exit;
|
||||
}
|
||||
|
||||
$oDB =& DB::connect(CONST_Database_DSN, false);
|
||||
if (!$oDB || PEAR::isError($oDB))
|
||||
{
|
||||
statusError("No database");
|
||||
}
|
||||
$oDB =& DB::connect(CONST_Database_DSN, false);
|
||||
if (!$oDB || PEAR::isError($oDB))
|
||||
{
|
||||
statusError("No database");
|
||||
}
|
||||
|
||||
$sStandardWord = $oDB->getOne("select make_standard_name('a')");
|
||||
if (PEAR::isError($sStandardWord))
|
||||
{
|
||||
statusError("Module failed");
|
||||
}
|
||||
if ($sStandardWord != 'a')
|
||||
{
|
||||
statusError("Module call failed");
|
||||
}
|
||||
$sStandardWord = $oDB->getOne("select make_standard_name('a')");
|
||||
if (PEAR::isError($sStandardWord))
|
||||
{
|
||||
statusError("Module failed");
|
||||
}
|
||||
if ($sStandardWord != 'a')
|
||||
{
|
||||
statusError("Module call failed");
|
||||
}
|
||||
|
||||
$iWordID = $oDB->getOne("select word_id,word_token, word, class, type, country_code, operator, search_name_count from word where word_token in (' a')");
|
||||
if (PEAR::isError($iWordID))
|
||||
{
|
||||
statusError("Query failed");
|
||||
}
|
||||
if (!$iWordID)
|
||||
{
|
||||
statusError("No value");
|
||||
}
|
||||
$iWordID = $oDB->getOne("select word_id,word_token, word, class, type, country_code, operator, search_name_count from word where word_token in (' a')");
|
||||
if (PEAR::isError($iWordID))
|
||||
{
|
||||
statusError("Query failed");
|
||||
}
|
||||
if (!$iWordID)
|
||||
{
|
||||
statusError("No value");
|
||||
}
|
||||
|
||||
echo "OK";
|
||||
exit;
|
||||
echo "OK";
|
||||
exit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user