<?php
$aNominatimMapInit = [
- 'zoom' => isset($_GET['zoom'])?htmlspecialchars($_GET['zoom']):NULL,
- 'lat' => isset($_GET['lat'] )?htmlspecialchars($_GET['lat']):NULL,
- 'lon' => isset($_GET['lon'] )?htmlspecialchars($_GET['lon']):NULL
+ 'zoom' => isset($_GET['zoom']) ? htmlspecialchars($_GET['zoom']) : CONST_Default_Zoom,
+ 'lat' => isset($_GET['lat'] ) ? htmlspecialchars($_GET['lat'] ) : CONST_Default_Lat,
+ 'lon' => isset($_GET['lon'] ) ? htmlspecialchars($_GET['lon'] ) : CONST_Default_Lon,
+ 'tile_url' => $sTileURL,
+ 'tile_attribution' => $sTileAttribution
];
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
<link href="css/details.css" rel="stylesheet" type="text/css" />
</head>
-<?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
<?php
function headline($sTitle)
{
- echo "<h2>".$sTitle."</h2>\n";
+ echo "<tr class='all-columns'><td colspan='6'><h2>".$sTitle."</h2></td></tr>\n";
+ }
+
+ function headline3($sTitle)
+ {
+ echo "<tr class='all-columns'><td colspan='6'><h3>".$sTitle."</h3></td></tr>\n";
}
function osm_link($aFeature)
function _one_row($aAddressLine){
$bNotUsed = (isset($aAddressLine['isaddress']) && $aAddressLine['isaddress'] == 'f');
- echo '<tr class="' . ($bNotUsed?'notused':'') . '">';
- echo ' <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</td>';
- echo ' <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . '</td>';
- echo ' <td>' . osm_link($aAddressLine) . '</td>';
- echo ' <td>' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . '</td>';
- // echo '<td>' . (isset($aAddressLine['rank_search_label']) ? $aAddressLine['rank_search_label'] : '') .'</td>';
+ 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>' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . "</td>\n";
+ // echo '<td>' . (isset($aAddressLine['rank_search_label']) ? $aAddressLine['rank_search_label'] : '') ."</td>\n";
// echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
- echo ' <td>' . format_distance($aAddressLine['distance']).'</td>';;
- echo ' <td>' . nominatim_link($aAddressLine,'details >') . '</td>';;
+ echo ' <td>' . format_distance($aAddressLine['distance'])."</td>\n";
+ echo ' <td>' . nominatim_link($aAddressLine,'details >') . "</td>\n";
echo "</tr>\n";
}
<body id="details-page">
+ <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
<div class="container">
<div class="row">
<div class="col-sm-10">
}
?>
- </tbody>
- </table>
<?php
if ($aLinkedLines)
{
headline('Linked Places');
- echo '<table id="linked" class="table table-striped table-responsive">';
foreach($aLinkedLines as $aAddressLine)
{
_one_row($aAddressLine);
}
- echo '</table>';
}
echo '<div>'.($aRow['word_token'][0]==' '?'*':'').$aRow['word_token'].'('.$aRow['word_id'].')'."</div>\n";
}
}
-
+
if (sizeof($aParentOfLines))
{
headline('Parent Of');
foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
{
$sGroupHeading = ucwords($sGroupHeading);
- echo "<h3>$sGroupHeading</h3>\n";
+ headline3($sGroupHeading);
- echo '<table id="linked" class="table table-striped table-responsive">';
foreach($aParentOfLines as $aAddressLine)
{
_one_row($aAddressLine);
}
- echo '</table>';
}
if (sizeof($aParentOfLines) >= 500) {
echo '<p>There are more child objects which are not shown.</p>';
// headline('Other Parts');
// headline('Linked To');
+
+ echo "</table>\n";
?>
</div>
</div>
<script type="text/javascript">
+ <?php
+
+ $aNominatimMapInit = [
+ 'tile_url' => $sTileURL,
+ 'tile_attribution' => $sTileAttribution
+ ];
+ echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
+
+ $aPlace = [
+ 'outlinestring' => $aPointDetails['outlinestring'],
+ 'lon' => $aPointDetails['lon'],
+ 'lat' => $aPointDetails['lat'],
+ ];
+ echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';';
- var nominatim_result = {
- outlinestring: '<?php echo $aPointDetails['outlinestring'];?>',
- lon: <?php echo $aPointDetails['lon'];?>,
- lat: <?php echo $aPointDetails['lat'];?>,
- };
+ ?>
</script>
<h2>Welcome to Nominatim</h2>
<p>Nominatim is a search engine for <a href="http://www.openstreetmap.org">OpenStreetMap</a>
-data. This is the debugging interface. You can try search and reverse search queries
-and explore the details of each object saved in the database.</p>
+data. This is the debugging interface. You may search for a name or address(forward search) or
+look up data by its geographic coordinate(reverse search). Each result comes with a
+link to a details page where you can inspect what data about the object is saved in
+the database and investigate how the address of the object has been computed.</p>
For more information visit the <a href="http://wiki.openstreetmap.org/wiki/Nominatim">Nominatim wiki page</a>.
$aNominatimMapInit = [
'zoom' => $iZoom,
'lat' => $fLat,
- 'lon' => $fLon
+ 'lon' => $fLon,
+ 'tile_url' => $sTileURL,
+ 'tile_attribution' => $sTileAttribution
];
echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
--- /dev/null
+# SYNOPSIS
+#
+# AX_LIB_XML2([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+# This macro provides tests of availability of xml2 'libxml2' library
+# of particular version or newer.
+#
+# AX_LIB_LIBXML2 macro takes only one argument which is optional. If
+# there is no required version passed, then macro does not run version
+# test.
+#
+# The --with-libxml2 option takes one of three possible values:
+#
+# no - do not check for xml2 library
+#
+# yes - do check for xml2 library in standard locations (xml2-config
+# should be in the PATH)
+#
+# path - complete path to xml2-config utility, use this option if xml2-config
+# can't be found in the PATH
+#
+# This macro calls:
+#
+# AC_SUBST(XML2_CFLAGS)
+# AC_SUBST(XML2_LDFLAGS)
+# AC_SUBST(XML2_VERSION)
+#
+# And sets:
+#
+# HAVE_XML2
+#
+# LICENSE
+#
+# Copyright (c) 2009 Hartmut Holzgraefe <hartmut@php.net>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AX_LIB_XML2],
+[
+ AC_ARG_WITH([libxml2],
+ AC_HELP_STRING([--with-libxml2=@<:@ARG@:>@],
+ [use libxml2 library @<:@default=yes@:>@, optionally specify path to xml2-config]
+ ),
+ [
+ if test "$withval" = "no"; then
+ want_libxml2="no"
+ elif test "$withval" = "yes"; then
+ want_libxml2="yes"
+ else
+ want_libxml2="yes"
+ XML2_CONFIG="$withval"
+ fi
+ ],
+ [want_libxml2="yes"]
+ )
+
+ XML2_CFLAGS=""
+ XML2_LDFLAGS=""
+ XML2_VERSION=""
+
+ dnl
+ dnl Check xml2 libraries (libxml2)
+ dnl
+
+ if test "$want_libxml2" = "yes"; then
+
+ if test -z "$XML2_CONFIG" -o test; then
+ AC_PATH_PROG([XML2_CONFIG], [xml2-config], [])
+ fi
+
+ if test ! -x "$XML2_CONFIG"; then
+ AC_MSG_ERROR([$XML2_CONFIG does not exist or it is not an exectuable file])
+ XML2_CONFIG="no"
+ found_libxml2="no"
+ fi
+
+ if test "$XML2_CONFIG" != "no"; then
+ AC_MSG_CHECKING([for xml2 libraries])
+
+ XML2_CFLAGS="`$XML2_CONFIG --cflags`"
+ XML2_LDFLAGS="`$XML2_CONFIG --libs`"
+
+ XML2_VERSION=`$XML2_CONFIG --version`
+
+ AC_DEFINE([HAVE_XML2], [1],
+ [Define to 1 if xml2 libraries are available])
+
+ found_libxml2="yes"
+ AC_MSG_RESULT([yes])
+ else
+ found_libxml2="no"
+ AC_MSG_RESULT([no])
+ fi
+ fi
+
+ dnl
+ dnl Check if required version of xml2 is available
+ dnl
+
+
+ libxml2_version_req=ifelse([$1], [], [], [$1])
+
+
+ if test "$found_libxml2" = "yes" -a -n "$libxml2_version_req"; then
+
+ AC_MSG_CHECKING([if libxml2 version is >= $libxml2_version_req])
+
+ dnl Decompose required version string of libxml2
+ dnl and calculate its number representation
+ libxml2_version_req_major=`expr $libxml2_version_req : '\([[0-9]]*\)'`
+ libxml2_version_req_minor=`expr $libxml2_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+ libxml2_version_req_micro=`expr $libxml2_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+ if test "x$libxml2_version_req_micro" = "x"; then
+ libxml2_version_req_micro="0"
+ fi
+
+ libxml2_version_req_number=`expr $libxml2_version_req_major \* 1000000 \
+ \+ $libxml2_version_req_minor \* 1000 \
+ \+ $libxml2_version_req_micro`
+
+ dnl Decompose version string of installed PostgreSQL
+ dnl and calculate its number representation
+ libxml2_version_major=`expr $XML2_VERSION : '\([[0-9]]*\)'`
+ libxml2_version_minor=`expr $XML2_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
+ libxml2_version_micro=`expr $XML2_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+ if test "x$libxml2_version_micro" = "x"; then
+ libxml2_version_micro="0"
+ fi
+
+ libxml2_version_number=`expr $libxml2_version_major \* 1000000 \
+ \+ $libxml2_version_minor \* 1000 \
+ \+ $libxml2_version_micro`
+
+ libxml2_version_check=`expr $libxml2_version_number \>\= $libxml2_version_req_number`
+ if test "$libxml2_version_check" = "1"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+
+ AC_SUBST([XML2_VERSION])
+ AC_SUBST([XML2_CFLAGS])
+ AC_SUBST([XML2_LDFLAGS])
+])
+
@define('CONST_Default_Lat', 20.0);
@define('CONST_Default_Lon', 0.0);
@define('CONST_Default_Zoom', 2);
+ @define('CONST_Map_Tile_URL', 'http://{s}.tile.osm.org/{z}/{x}/{y}.png');
+ @define('CONST_Map_Tile_Attribution', ''); // Set if tile source isn't osm.org
@define('CONST_Search_AreaPolygons_Enabled', true);
@define('CONST_Search_AreaPolygons', true);
@define('CONST_Log_File_Format', 'TODO'); // Currently hard coded
@define('CONST_Log_File_SearchLog', '');
@define('CONST_Log_File_ReverseLog', '');
+
+
sudo apt-get update -qq
sudo apt-get upgrade -y
-sudo apt-get install -y build-essential libxml2-dev libgeos-dev libpq-dev libbz2-dev \
+sudo apt-get install -y build-essential libgeos-dev libpq-dev libbz2-dev \
libtool automake libproj-dev libboost-dev libboost-system-dev \
libboost-filesystem-dev libboost-thread-dev libexpat-dev
sudo apt-get autoremove -y
###
### Nominatim
###
-sudo apt-get install -y libprotobuf-c0-dev protobuf-c-compiler \
- libgeos-c1 libgeos++-dev \
- lua5.2 liblua5.2-dev
-
-# git clone --recursive https://github.com/twain47/Nominatim.git
-
+sudo apt-get install -y libgeos-c1 libgeos++-dev libxml2-dev
# now ideally login as $USERNAME and continue
su $USERNAME -l
-cd /home/vagrant/Nominatim
+cd /home/vagrant
+
+if [ ! -d "Nominatim" ]; then
+ sudo apt-get install -y git
+ git clone --recursive https://github.com/twain47/Nominatim.git
+fi
+
+cd Nominatim
-# cd ~/Nominatim
./autogen.sh
./configure
make
h2 {
font-size: 2em;
padding-left: 8px;
+ background-color: white;
}
h3 {
font-size: 1.5em;
padding-left: 8px;
}
+
+tr.all-columns {
+ background-color: white !important;
+ border: none;
+}
+tr.all-columns td {
+ border-top: none !important;
+ padding-left: 0 !important;
+}
+
.table {
width: 100%;
}
// 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'] = [];
+ }
// Address
$aAddressLines = getAddressDetails($oDB, $sLanguagePrefArraySQL, $iPlaceID, $aPointDetails['country_code'], 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 geometry as placegeometry from placex where place_id = $iPlaceID) as x";
+ $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 geometry as placegeometry from placex where place_id = $iPlaceID) as x";
+ $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;
{
$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['nameaddress_vector'],1,-1).")";
$aPlaceSearchAddressKeywords = $oDB->getAll($sSQL);
+ if (PEAR::isError($aPlaceSearchAddressKeywords)) // possible timeout
+ {
+ $aPlaceSearchAddressKeywords = [];
+ }
+
}
logEnd($oDB, $hLog, 1);
+ $sTileURL = CONST_Map_Tile_URL;
+ $sTileAttribution = CONST_Map_Tile_Attribution;
+
include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
$('#q').focus();
map = new L.map('map', {
- attributionControl: false, // moved to page footer
+ attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
scrollWheelZoom: !L.Browser.touch,
touchZoom: false
});
-
-
- L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
- noWrap: true // otherwise we end up with click coordinates like latitude -728
+ L.tileLayer(nominatim_map_init.tile_url, {
+ noWrap: true, // otherwise we end up with click coordinates like latitude -728
// moved to footer
- // attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
+ attribution: (nominatim_map_init.tile_attribution || null ) //'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
- if ( nominatim_map_init.lat ){
- map.setView([nominatim_map_init.lat || 0, nominatim_map_init.lon], nominatim_map_init.zoom);
-
- if ( is_reverse_search ){
- // not really a market, but the .circle 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);
- }
+ map.setView([nominatim_map_init.lat, nominatim_map_init.lon], nominatim_map_init.zoom);
- } else {
- map.setView([0,0],2);
+ 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);
}
map = new L.map('map', {
// center: [nominatim_map_init.lat, nominatim_map_init.lon],
// zoom: nominatim_map_init.zoom,
- attributionControl: false,
+ attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
scrollWheelZoom: false,
touchZoom: false,
});
- L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
+
+ L.tileLayer(nominatim_map_init.tile_url, {
// moved to footer
- // attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
+ 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 circle = L.circleMarker([nominatim_result.lat,nominatim_result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75});
exit;
}
+ $sTileURL = CONST_Map_Tile_URL;
+ $sTileAttribution = CONST_Map_Tile_Attribution;
include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
$fLat = CONST_Default_Lat;
$fLon = CONST_Default_Lon;
$iZoom = CONST_Default_Zoom;
+ $sTileURL = CONST_Map_Tile_URL;
+ $sTileAttribution = CONST_Map_Tile_Attribution;
$oGeocode =& new Geocode($oDB);