$sSQL = "select (each(extratags)).key,(each(extratags)).value from placex where place_id = {$iPlaceID} order by (each(extratags)).key"; $aPointDetails['aExtraTags'] = $oDB->getAssoc($sSQL); // 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(geometry, placegeometry) 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 .= " 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); // 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(geometry, placegeometry) 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 .= " order by rank_address asc,rank_search asc,localname,housenumber"; $aParentOfLines = $oDB->getAll($sSQL); $aPlaceSearchNameKeywords = false; $aPlaceSearchAddressKeywords = false; if (isset($_GET['keywords']) && $_GET['keywords']) { $sSQL = "select * from search_name where place_id = {$iPlaceID}"; $aPlaceSearchName = $oDB->getRow($sSQL); $sSQL = "select * from word where word_id in (" . substr($aPlaceSearchName['name_vector'], 1, -1) . ")"; $aPlaceSearchNameKeywords = $oDB->getAll($sSQL); $sSQL = "select * from word where word_id in (" . substr($aPlaceSearchName['nameaddress_vector'], 1, -1) . ")"; $aPlaceSearchAddressKeywords = $oDB->getAll($sSQL); } logEnd($oDB, $hLog, 1); include CONST_BasePath . '/lib/template/details-' . $sOutputFormat . '.php';
// reverse order of '/' separated string $aPhrases = explode('/', $sQuery); $aPhrases = array_reverse($aPhrases); $sQuery = join(', ', $aPhrases); $oGeocode->setQuery($sQuery); } else { $oGeocode->setQueryFromParams($_GET); } } $hLog = logStart($oDB, 'search', $oGeocode->getQueryString(), $aLangPrefOrder); $aSearchResults = $oGeocode->lookup(); if ($aSearchResults === false) { $aSearchResults = array(); } $sDataDate = $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)); $bAsText = $oGeocode->getIncludePolygonAsText(); $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(',', $oGeocode->getExcludedPlaceIDs()); 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 (!$bDeDupe || !isset($aOSMIDDone[$aResult['osm_type'] . $aResult['osm_id']]) && !isset($aClassTypeNameDone[$aResult['osm_type'] . $aResult['class'] . $aResult['name']])) { $aOSMIDDone[$aResult['osm_type'] . $aResult['osm_id']] = true; $aClassTypeNameDone[$aResult['osm_type'] . $aResult['class'] . $aResult['name']] = true; $aSearchResults[] = $aResult; } // Absolute limit on number of results if (sizeof($aSearchResults) >= $iLimit) { break; } } $sDataDate = $oDB->getOne("select TO_CHAR(lastimportdate - '1 day'::interval,'YYYY/MM/DD') from import_status limit 1"); if (isset($_GET['nearlat']) && isset($_GET['nearlon'])) { $sQuery .= ' [' . $_GET['nearlat'] . ',' . $_GET['nearlon'] . ']'; } if ($sQuery) { logEnd($oDB, $hLog, sizeof($aToFilter)); } $sMoreURL = CONST_Website_BaseURL . 'search?format=' . urlencode($sOutputFormat) . '&exclude_place_ids=' . join(',', $aExcludePlaceIDs); $sMoreURL .= '&accept-language=' . $_SERVER["HTTP_ACCEPT_LANGUAGE"]; if ($bShowPolygons) { $sMoreURL .= '&polygon=1'; } if ($bShowAddressDetails) { $sMoreURL .= '&addressdetails=1'; } if (isset($_GET['viewbox']) && $_GET['viewbox']) { $sMoreURL .= '&viewbox=' . urlencode($_GET['viewbox']); } if (isset($_GET['nearlat']) && isset($_GET['nearlon'])) { $sMoreURL .= '&nearlat=' . (double) $_GET['nearlat'] . '&nearlon=' . (double) $_GET['nearlon']; }