]> git.openstreetmap.org Git - nominatim.git/commitdiff
more tests for libphp - incorporate lonvias feedback
authorMarc Tobias Metten <mtmail@gmx.net>
Thu, 15 Oct 2015 00:30:51 +0000 (02:30 +0200)
committerMarc Tobias Metten <mtmail@gmx.net>
Thu, 15 Oct 2015 00:30:51 +0000 (02:30 +0200)
38 files changed:
VAGRANT.md
Vagrantfile
configure.ac
lib/Geocode.php
lib/PlaceLookup.php
lib/ReverseGeocode.php
lib/lib.php
lib/template/address-json.php
lib/template/address-jsonv2.php
lib/template/address-xml.php
lib/template/search-json.php
lib/template/search-jsonv2.php
lib/template/search-xml.php
m4/ax_lib_postgresql_svr.m4 [new file with mode: 0644]
nominatim/Makefile.am
osm2pgsql
settings/settings.php
sql/functions.sql
sql/indices.src.sql
tests-php/Nominatim/NominatimTest.php
tests-php/README.txt
tests/features/api/lookup.feature [new file with mode: 0644]
tests/features/api/reverse.feature
tests/features/api/reverse_simple.feature
tests/features/api/search_params.feature
tests/features/api/search_simple.feature
tests/features/db/update/search_terms.feature [new file with mode: 0644]
tests/features/osm2pgsql/import/tags.feature
tests/steps/api_result.py
tests/steps/api_setup.py
tests/steps/osm2pgsql_setup.py
utils/setup.php
utils/update.php
vagrant-provision.sh
website/lookup.php [new file with mode: 0755]
website/reverse.php
website/search.php
website/status.php

index d97fb3f788d2531490b30003d9934016214d6535..c662d5e40302b5acb6f1d83270d0b946cceb638e 100644 (file)
@@ -38,7 +38,8 @@ is.
 
 3. Import a small country (Monaco)
 
-    You need to give the virtual machine more memory (2GB) for an import, see `Vagrantfile`.
+    You need to give the virtual machine more memory (2GB) for an import,
+    see `Vagrantfile`. Otherwise 1GB is enough.
     
     See the FAQ how to skip this step and point Nominatim to an existing database.
 
@@ -46,7 +47,7 @@ is.
   # inside the virtual machine:
   cd Nominatim
     wget --no-verbose --output-document=data/monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf
-    utils/setup.php --osm-file data/monaco.osm.pbf --osm2pgsql-cache 1000 --all | tee monaco.$$.log
+    ./utils/setup.php --osm-file data/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | tee monaco.$$.log
     ./utils/specialphrases.php --countries > data/specialphrases_countries.sql
     psql -d nominatim -f data/specialphrases_countries.sql
     ```
index 1b1653270c9dea2e0a542d6307da4c09039e52ec..843dd668227c6aeec154dc9ba21584577e573a24 100644 (file)
@@ -30,7 +30,7 @@ Vagrant.configure("2") do |config|
 
   config.vm.provider "virtualbox" do |vb|
     vb.gui = false
-    vb.customize ["modifyvm", :id, "--memory", "1024"]
+    vb.customize ["modifyvm", :id, "--memory", "2048"]
   end
 
 
index badcb5b224258b4ef2754775a9ba53d86db8302f..53a8e8714281cafa64b4d17cbffbbfee85535424 100644 (file)
@@ -9,6 +9,7 @@ AC_PREREQ(2.61)
 AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 std-options check-news])
 
 dnl Additional macro definitions are in here
+m4_include([m4/ax_lib_postgresql_svr.m4])
 AC_CONFIG_MACRO_DIR([osm2pgsql/m4])
 
 dnl Generate configuration header file
@@ -45,6 +46,7 @@ if test "x$POSTGRESQL_VERSION" = "x"
 then
     AC_MSG_ERROR([postgresql client library not found])
 fi
+AX_LIB_POSTGRESQL_SVR(9.0)
 if test ! -f "$POSTGRESQL_PGXS"
 then
     AC_MSG_ERROR([postgresql server development library not found])
index c89cc48cff856531860a0eadcf084913566f4110..80561d27fd18232b372b1f6b7d24f1c8fab68932 100644 (file)
@@ -6,6 +6,8 @@
                protected $aLangPrefOrder = array();
 
                protected $bIncludeAddressDetails = false;
+               protected $bIncludeExtraTags = false;
+               protected $bIncludeNameDetails = false;
 
                protected $bIncludePolygonAsPoints = false;
                protected $bIncludePolygonAsText = false;
                        return $this->bIncludeAddressDetails;
                }
 
+               function getIncludeExtraTags()
+               {
+                       return $this->bIncludeExtraTags;
+               }
+
+               function getIncludeNameDetails()
+               {
+                       return $this->bIncludeNameDetails;
+               }
+
                function setIncludePolygonAsPoints($b = true)
                {
                        $this->bIncludePolygonAsPoints = $b;
                function loadParamArray($aParams)
                {
                        if (isset($aParams['addressdetails'])) $this->bIncludeAddressDetails = (bool)$aParams['addressdetails'];
+                       if ((float) CONST_Postgresql_Version > 9.2)
+                       {
+                               if (isset($aParams['extratags'])) $this->bIncludeExtraTags = (bool)$aParams['extratags'];
+                               if (isset($aParams['namedetails'])) $this->bIncludeNameDetails = (bool)$aParams['namedetails'];
+                       }
                        if (isset($aParams['bounded'])) $this->bBoundedSearch = (bool)$aParams['bounded'];
                        if (isset($aParams['dedupe'])) $this->bDeDupe = (bool)$aParams['dedupe'];
 
                        $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                        $sSQL .= "get_name_by_language(name, $sLanguagePrefArraySQL) as placename,";
                        $sSQL .= "get_name_by_language(name, ARRAY['ref']) as ref,";
+                       if ($this->bIncludeExtraTags) $sSQL .= "hstore_to_json(extratags)::text as extra,";
+                       if ($this->bIncludeNameDetails) $sSQL .= "hstore_to_json(name)::text as names,";
                        $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
                        $sSQL .= $sImportanceSQL."coalesce(importance,0.75-(rank_search::float/40)) as importance, ";
                        $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(CASE WHEN placex.rank_search < 28 THEN placex.place_id ELSE placex.parent_place_id END) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, ";
                        $sSQL .= ",langaddress ";
                        $sSQL .= ",placename ";
                        $sSQL .= ",ref ";
+                       if ($this->bIncludeExtraTags) $sSQL .= ",extratags";
+                       if ($this->bIncludeNameDetails) $sSQL .= ",name";
                        $sSQL .= ",extratags->'place' ";
 
                        if (30 >= $this->iMinAddressRank && 30 <= $this->iMaxAddressRank)
                                $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= "null as placename,";
                                $sSQL .= "null as ref,";
+                               if ($this->bIncludeExtraTags) $sSQL .= "null as extra,";
+                               if ($this->bIncludeNameDetails) $sSQL .= "null as names,";
                                $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
                                $sSQL .= $sImportanceSQL."-1.15 as importance, ";
                                $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(location_property_tiger.parent_place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, ";
                                $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= "null as placename,";
                                $sSQL .= "null as ref,";
+                               if ($this->bIncludeExtraTags) $sSQL .= "null as extra,";
+                               if ($this->bIncludeNameDetails) $sSQL .= "null as names,";
                                $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
                                $sSQL .= $sImportanceSQL."-1.10 as importance, ";
                                $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(location_property_aux.parent_place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, ";
                                        }
                                }
 
+                               if ($this->bIncludeExtraTags)
+                               {
+                                       if ($aResult['extra'])
+                                       {
+                                               $aResult['sExtraTags'] = json_decode($aResult['extra']);
+                                       }
+                                       else
+                                       {
+                                               $aResult['sExtraTags'] = (object) array();
+                                       }
+                               }
+
+                               if ($this->bIncludeNameDetails)
+                               {
+                                       if ($aResult['names'])
+                                       {
+                                               $aResult['sNameDetails'] = json_decode($aResult['names']);
+                                       }
+                                       else
+                                       {
+                                               $aResult['sNameDetails'] = (object) array();
+                                       }
+                               }
+
                                // Adjust importance for the number of exact string matches in the result
                                $aResult['importance'] = max(0.001,$aResult['importance']);
                                $iCountWords = 0;
                                {
                                        $aResult['foundorder'] += 0.01;
                                }
+                               if (CONST_Debug) { var_dump($aResult); }
                                $aSearchResults[$iResNum] = $aResult;
                        }
                        uasort($aSearchResults, 'byImportance');
index 84c68a99d8f503e89cf772524fa58553c38c405a..c5129fee31006d47a011251a82a08237458703a3 100644 (file)
@@ -5,12 +5,16 @@
 
                protected $iPlaceID;
 
-               protected $bIsTiger = false;
+               protected $sType = false;
 
                protected $aLangPrefOrder = array();
 
                protected $bAddressDetails = false;
 
+               protected $bExtraTags = false;
+
+               protected $bNameDetails = false;
+
                function PlaceLookup(&$oDB)
                {
                        $this->oDB =& $oDB;
                        $this->bAddressDetails = $bAddressDetails;
                }
 
+               function setIncludeExtraTags($bExtraTags = false)
+               {
+                       if ((float) CONST_Postgresql_Version > 9.2)
+                       {
+                               $this->bExtraTags = $bExtraTags;
+                       }
+               }
+
+               function setIncludeNameDetails($bNameDetails = false)
+               {
+                       if ((float) CONST_Postgresql_Version > 9.2)
+                       {
+                               $this->bNameDetails = $bNameDetails;
+                       }
+               }
+
                function setPlaceID($iPlaceID)
                {
                        $this->iPlaceID = $iPlaceID;
                        $this->iPlaceID = $this->oDB->getOne($sSQL);
                }
 
-               function setIsTiger($b = false)
+               function lookupPlace($details)
                {
-                       $this->bIsTiger = $b;
+                       if (isset($details['place_id'])) $this->iPlaceID = $details['place_id'];
+                       if (isset($details['type'])) $this->sType = $details['type'];
+                       if (isset($details['osm_type']) && isset($details['osm_id']))
+                       {
+                               $this->setOSMID($details['osm_type'], $details['osm_id']);
+                       }
+
+                       return $this->lookup();
                }
 
                function lookup()
 
                        $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted", $this->aLangPrefOrder))."]";
 
-                       $sSQL = "select placex.place_id, partition, osm_type, osm_id, class, type, admin_level, housenumber, street, isin, postcode, country_code, extratags, parent_place_id, linked_place_id, rank_address, rank_search, ";
-                       $sSQL .= " coalesce(importance,0.75-(rank_search::float/40)) as importance, indexed_status, indexed_date, wikipedia, calculated_country_code, ";
-                       $sSQL .= " get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
-                       $sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) as placename,";
-                       $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,";
-                       $sSQL .= " (case when centroid is null then st_y(st_centroid(geometry)) else st_y(centroid) end) as lat,";
-                       $sSQL .= " (case when centroid is null then st_x(st_centroid(geometry)) else st_x(centroid) end) as lon";
-                       $sSQL .= " from placex where place_id = ".(int)$this->iPlaceID;
-
-
-                       if ($this->bIsTiger)
+                       if ($this->sType == 'tiger')
                        {
                                $sSQL = "select place_id,partition, 'T' as osm_type, place_id as osm_id, 'place' as class, 'house' as type, null as admin_level, housenumber, null as street, null as isin, postcode,";
-                               $sSQL .= " 'us' as country_code, null as extratags, parent_place_id, null as linked_place_id, 30 as rank_address, 30 as rank_search,";
+                               $sSQL .= " 'us' as country_code, parent_place_id, null as linked_place_id, 30 as rank_address, 30 as rank_search,";
                                $sSQL .= " coalesce(null,0.75-(30::float/40)) as importance, null as indexed_status, null as indexed_date, null as wikipedia, 'us' as calculated_country_code, ";
                                $sSQL .= " get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= " null as placename,";
                                $sSQL .= " null as ref,";
+                               if ($this->bExtraTags) $sSQL .= " null as extra,";
+                               if ($this->bNameDetails) $sSQL .= " null as names,";
                                $sSQL .= " st_y(centroid) as lat,";
                                $sSQL .= " st_x(centroid) as lon";
                                $sSQL .= " from location_property_tiger where place_id = ".(int)$this->iPlaceID;
                        }
+                       else
+                       {
+                               $sSQL = "select placex.place_id, partition, osm_type, osm_id, class, type, admin_level, housenumber, street, isin, postcode, country_code, parent_place_id, linked_place_id, rank_address, rank_search, ";
+                               $sSQL .= " coalesce(importance,0.75-(rank_search::float/40)) as importance, indexed_status, indexed_date, wikipedia, calculated_country_code, ";
+                               $sSQL .= " get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
+                               $sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) as placename,";
+                               $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,";
+                               if ($this->bExtraTags) $sSQL .= " hstore_to_json(extratags) as extra,";
+                               if ($this->bNameDetails) $sSQL .= " hstore_to_json(name) as names,";
+                               $sSQL .= " (case when centroid is null then st_y(st_centroid(geometry)) else st_y(centroid) end) as lat,";
+                               $sSQL .= " (case when centroid is null then st_x(st_centroid(geometry)) else st_x(centroid) end) as lon";
+                               $sSQL .= " from placex where place_id = ".(int)$this->iPlaceID;
+                       }
 
                        $aPlace = $this->oDB->getRow($sSQL);
 
                                $aPlace['aAddress'] = $aAddress;
                        }
 
+                       if ($this->bExtraTags)
+                       {
+                               if ($aPlace['extra'])
+                               {
+                                       $aPlace['sExtraTags'] = json_decode($aPlace['extra']);
+                               }
+                               else
+                               {
+                                       $aPlace['sExtraTags'] = (object) array();
+                               }
+                       }
+
+                       if ($this->bNameDetails)
+                       {
+                               if ($aPlace['names'])
+                               {
+                                       $aPlace['sNameDetails'] = json_decode($aPlace['names']);
+                               }
+                               else
+                               {
+                                       $aPlace['sNameDetails'] = (object) array();
+                               }
+                       }
 
                        $aClassType = getClassTypes();
                        $sAddressType = '';
 
                function getAddressNames()
                {
-                       $aAddressLines = $this->getAddressDetails(false);;
+                       $aAddressLines = $this->getAddressDetails(false);
 
                        $aAddress = array();
                        $aFallback = array();
index ae83af1e90a710aa0341cbd427210c781d70205d..e40ce6cceaa23f2904be061914c46a3bdf73b718 100644 (file)
@@ -9,8 +9,6 @@
 
                protected $aLangPrefOrder = array();
 
-               protected $bShowAddressDetails = true;
-
                function ReverseGeocode(&$oDB)
                {
                        $this->oDB =& $oDB;
                        $this->aLangPrefOrder = $aLangPref;
                }
 
-               function setIncludeAddressDetails($bAddressDetails = true)
-               {
-                       $this->bAddressDetails = $bAddressDetails;
-               }
-
                function setLatLon($fLat, $fLon)
                {
                        $this->fLat = (float)$fLat;
@@ -97,7 +90,7 @@
                                $sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';
                                $sSQL .= ' and rank_search != 28 and rank_search >= '.$iMaxRank;
                                $sSQL .= ' and (name is not null or housenumber is not null)';
-                               $sSQL .= ' and class not in (\'waterway\',\'railway\',\'tunnel\',\'bridge\')';
+                               $sSQL .= ' and class not in (\'waterway\',\'railway\',\'tunnel\',\'bridge\',\'man_made\')';
                                $sSQL .= ' and indexed_status = 0 ';
                                $sSQL .= ' and (ST_GeometryType(geometry) not in (\'ST_Polygon\',\'ST_MultiPolygon\') ';
                                $sSQL .= ' OR ST_DWithin('.$sPointSQL.', centroid, '.$fSearchDiam.'))';
                                }
                        }
 
-                       $oPlaceLookup = new PlaceLookup($this->oDB);
-                       $oPlaceLookup->setLanguagePreference($this->aLangPrefOrder);
-                       $oPlaceLookup->setIncludeAddressDetails($this->bAddressDetails);
-                       $oPlaceLookup->setPlaceId($iPlaceID);
-                       $oPlaceLookup->setIsTiger($bPlaceIsTiger);
-
-                       return $oPlaceLookup->lookup();
+                       return array('place_id' => $iPlaceID,
+                                            'type' => $bPlaceIsTiger ? 'tiger' : 'osm');
                }
        }
 ?>
index c68f04eb9df20e05c13c0a9819cdb4a743148b75..50cf3dc4b44ac21ce572d62751736fcefc216f81 100644 (file)
                exit;
        }
 
+       function getParamBool($name, $default=false)
+       {
+               if (!isset($_GET[$name])) return $default;
+
+               return (bool) $_GET[$name];
+       }
 
        function fail($sError, $sUserError = false)
        {
        }
 
 
-       function javascript_renderData($xVal)
+       function javascript_renderData($xVal, $iOptions = 0)
        {
                header("Access-Control-Allow-Origin: *");
-               $iOptions = 0;
                if (defined('PHP_VERSION_ID') && PHP_VERSION_ID > 50400)
-                       $iOptions = JSON_UNESCAPED_UNICODE;
+                       $iOptions |= JSON_UNESCAPED_UNICODE;
                $jsonout = json_encode($xVal, $iOptions);
 
                if( ! isset($_GET['json_callback']))
                }
                // degrees decimal seconds
                // N 40 26 46 W 79 58 56
-               // N 40° 26′ 46″ W, 79° 58′ 56″
+               // N 40° 26′ 46″, W 79° 58′ 56″
                //                      1        2            3            4                5        6            7            8
                elseif (preg_match('/\\b([NS])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*[, ]+([EW])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*\\b/', $sQuery, $aData))
                {
index 2f0778187f9cce63ff0c2cc5c877ba282cb6bc5b..ff245e145f4dac3414cd073592634c6cd933115e 100644 (file)
@@ -10,7 +10,7 @@
        }
        else
        {
-               if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
+               if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
                $aFilteredPlaces['licence'] = "Data Â© OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
                $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));
                 if ($sOSMType)
@@ -21,7 +21,9 @@
                 if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];
                 if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];
                $aFilteredPlaces['display_name'] = $aPlace['langaddress'];
-               if ($bShowAddressDetails) $aFilteredPlaces['address'] = $aPlace['aAddress'];
+               if (isset($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress'];
+               if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
+               if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
        }
 
        javascript_renderData($aFilteredPlaces);
index 92cf4f1cc5025d830ea92556682f2eb8e746348e..a8a05dd48cfa3c5a7e34c81372630245e93864bb 100644 (file)
 
                $aFilteredPlaces['place_rank'] = $aPlace['rank_search'];
 
-                $aFilteredPlaces['category'] = $aPlace['class'];
-                $aFilteredPlaces['type'] = $aPlace['type'];
+               $aFilteredPlaces['category'] = $aPlace['class'];
+               $aFilteredPlaces['type'] = $aPlace['type'];
 
                $aFilteredPlaces['importance'] = $aPlace['importance'];
 
-                $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);
+               $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);
 
                $aFilteredPlaces['display_name'] = $aPlace['langaddress'];
-                $aFilteredPlaces['name'] = $aPlace['placename'];
-               if ($bShowAddressDetails && $aPlace['aAddress'] && sizeof($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress'];
+               $aFilteredPlaces['name'] = $aPlace['placename'];
+
+               if (isset($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress'];
+               if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
+               if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
        }
 
        javascript_renderData($aFilteredPlaces);
index 9eeb3b778a6c5737d76a49ee33cfd3455fa47081..39d9a14792171a0c0d0cd0efc60ff8fa73c7257b 100644 (file)
@@ -29,7 +29,8 @@
                if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
                echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
 
-               if ($bShowAddressDetails) {
+               if (isset($aPlace['aAddress']))
+               {
                        echo "<addressparts>";
                        foreach($aPlace['aAddress'] as $sKey => $sValue)
                        {
                        }
                        echo "</addressparts>";
                }
+
+               if (isset($aPlace['sExtraTags']))
+               {
+                       echo "<extratags>";
+                       foreach ($aPlace['sExtraTags'] as $sKey => $sValue)
+                       {
+                               echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
+                       }
+                       echo "</extratags>";
+               }
+
+               if (isset($aPlace['sNameDetails']))
+               {
+                       echo "<namedetails>";
+                       foreach ($aPlace['sNameDetails'] as $sKey => $sValue)
+                       {
+                               echo '<name desc="'.htmlspecialchars($sKey).'">';
+                               echo htmlspecialchars($sValue);
+                               echo "</name>";
+                       }
+                       echo "</namedetails>";
+               }
        }
 
        echo "</reversegeocode>";
index 57586fb9eee3c3adeb24003e225d64fb11480aaf..3dcaabdbd6393a94bc27b375c1c401db11626a69 100644 (file)
@@ -74,6 +74,9 @@
                        $aPlace['geokml'] = $aPointDetails['askml'];
                }
 
+               if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags'];
+               if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
+
                $aFilteredPlaces[] = $aPlace;
        }
 
index 126f78662df64970a3acc6c120599637fdaf975d..e974772023393a39818205bc22abe0201c2207c3 100644 (file)
                         $aPlace['geokml'] = $aPointDetails['askml'];
                 }
 
+               if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags'];
+               if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
+
                $aFilteredPlaces[] = $aPlace;
        }
 
-       javascript_renderData($aFilteredPlaces, array('geojson'));
+       javascript_renderData($aFilteredPlaces);
index 693330bb52cfce29fba95d3ce1c45415085b4b99..b61ff22f55fe2eed589466c682a8f650ac14b52b 100644 (file)
@@ -5,7 +5,8 @@
        echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
        echo ">\n";
 
-       echo "<searchresults";
+       echo "<";
+       echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults');
        echo " timestamp='".date(DATE_RFC822)."'";
        echo " attribution='Data Â© OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
        echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
                        echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
                }
 
-               if (isset($aResult['address']) || isset($aResult['askml']))
-               {
-                       echo ">";
-               }
+               $bHasDelim = false;
 
                if (isset($aResult['askml']))
                {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
                        echo "\n<geokml>";
                        echo $aResult['askml'];
                        echo "</geokml>";
                }
 
+               if (isset($aResult['sExtraTags']))
+               {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
+                       echo "\n<extratags>";
+                       foreach ($aResult['sExtraTags'] as $sKey => $sValue)
+                       {
+                               echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
+                       }
+                       echo "</extratags>";
+               }
+
+               if (isset($aResult['sNameDetails']))
+               {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
+                       echo "\n<namedetails>";
+                       foreach ($aResult['sNameDetails'] as $sKey => $sValue)
+                       {
+                               echo '<name desc="'.htmlspecialchars($sKey).'">';
+                               echo htmlspecialchars($sValue);
+                               echo "</name>";
+                       }
+                       echo "</namedetails>";
+               }
+
                if (isset($aResult['address']))
                {
+                       if (!$bHasDelim)
+                       {
+                               $bHasDelim = true;
+                               echo ">";
+                       }
                        echo "\n";
                        foreach($aResult['address'] as $sKey => $sValue)
                        {
                        }
                }
 
-               if (isset($aResult['address']) || isset($aResult['askml']))
+               if ($bHasDelim)
                {
                        echo "</place>";
                }
                }
        }
        
-       echo "</searchresults>";
+       echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";
diff --git a/m4/ax_lib_postgresql_svr.m4 b/m4/ax_lib_postgresql_svr.m4
new file mode 100644 (file)
index 0000000..56ecb5b
--- /dev/null
@@ -0,0 +1,125 @@
+# SYNOPSIS
+#
+#   AX_LIB_POSTGRESQL_SVR([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+#   This macro provides tests of availability of PostgreSQL server library
+#
+#   This macro calls:
+#
+#     AC_SUBST(POSTGRESQL_PGXS)
+#     AC_SUBST(POSTGRESQL_SERVER_CFLAGS)
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
+#   Copyright (c) 2015 Sarah Hoffmann <lonia@denofr.de>
+#
+#   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_POSTGRESQL_SVR],
+[
+    AC_ARG_WITH([postgresql],
+        AC_HELP_STRING([--with-postgresql-svr=@<:@ARG@:>@],
+            [use PostgreSQL server library @<:@default=yes@:>@, optionally specify path to pg_config]
+        ),
+        [
+        if test "$withval" = "no"; then
+            want_postgresql="no"
+        elif test "$withval" = "yes"; then
+            want_postgresql="yes"
+        else
+            want_postgresql="yes"
+            PG_CONFIG="$withval"
+        fi
+        ],
+        [want_postgresql="yes"]
+    )
+
+    dnl
+    dnl Check PostgreSQL server libraries
+    dnl
+
+    if test "$want_postgresql" = "yes"; then
+
+        if test -z "$PG_CONFIG" -o test; then
+            AC_PATH_PROG([PG_CONFIG], [pg_config], [])
+        fi
+
+        if test ! -x "$PG_CONFIG"; then
+            AC_MSG_ERROR([$PG_CONFIG does not exist or it is not an exectuable file])
+            PG_CONFIG="no"
+            found_postgresql="no"
+        fi
+
+        if test "$PG_CONFIG" != "no"; then
+            AC_MSG_CHECKING([for PostgreSQL server libraries])
+
+            POSTGRESQL_SERVER_CFLAGS="-I`$PG_CONFIG --includedir-server`"
+
+            POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'`
+
+            POSTGRESQL_PGXS=`$PG_CONFIG --pgxs`
+        if test -f "$POSTGRESQL_PGXS"
+        then
+          found_postgresql="yes"
+              AC_MSG_RESULT([yes])
+        fi
+        else
+            found_postgresql="no"
+            AC_MSG_RESULT([no])
+        fi
+    fi
+
+    dnl
+    dnl Check if required version of PostgreSQL is available
+    dnl
+
+
+    postgresql_version_req=ifelse([$1], [], [], [$1])
+
+    if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then
+
+        AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req])
+
+        dnl Decompose required version string of PostgreSQL
+        dnl and calculate its number representation
+        postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'`
+        postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+        postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+        if test "x$postgresql_version_req_micro" = "x"; then
+            postgresql_version_req_micro="0"
+        fi
+
+        postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \
+                                   \+ $postgresql_version_req_minor \* 1000 \
+                                   \+ $postgresql_version_req_micro`
+
+        dnl Decompose version string of installed PostgreSQL
+        dnl and calculate its number representation
+        postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'`
+        postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
+        postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+        if test "x$postgresql_version_micro" = "x"; then
+            postgresql_version_micro="0"
+        fi
+
+        postgresql_version_number=`expr $postgresql_version_major \* 1000000 \
+                                   \+ $postgresql_version_minor \* 1000 \
+                                   \+ $postgresql_version_micro`
+
+        postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number`
+        if test "$postgresql_version_check" = "1"; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_RESULT([no])
+        fi
+    fi
+
+    AC_SUBST([POSTGRESQL_PGXS])
+    AC_SUBST([POSTGRESQL_SERVER_CFLAGS])
+])
+
index 3f65398a73fb35b3c2813e74fcf1c5c75660d608..d27ae55490e4287911a990a4d89e29b1ccdece92 100644 (file)
@@ -2,8 +2,8 @@ bin_PROGRAMS = nominatim
 
 nominatim_SOURCES = export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c
 
-AM_CFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CFLAGS@ @XML_CPPFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@ -DVERSION='"@PACKAGE_VERSION@"'
-AM_CPPFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CFLAGS@ @XML_CPPFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@
+AM_CFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CPPFLAGS@ @XML_CPPFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@ -DVERSION='"@PACKAGE_VERSION@"'
+AM_CPPFLAGS = @PTHREAD_CFLAGS@ @POSTGRESQL_CPPFLAGS@ @XML_CPPFLAGS@ @BZIP2_CFLAGS@  @GEOS_CFLAGS@ @PROJ_CFLAGS@
 
 nominatim_LDADD = @PTHREAD_CFLAGS@ @POSTGRESQL_LDFLAGS@ @POSTGRESQL_LIBS@ @XML_LIBS@ @BZIP2_LDFLAGS@ @BZIP2_LIBS@ @GEOS_LDFLAGS@ @GEOS_LIBS@ @PROJ_LDFLAGS@ @PROJ_LIBS@ -lz
 
index 07db15e5e55eca63971a014ddb08bc47cd89f762..8179cdb67e70d7fb5605ab6ddedfd0bd3347db47 160000 (submodule)
--- a/osm2pgsql
+++ b/osm2pgsql
@@ -1 +1 @@
-Subproject commit 07db15e5e55eca63971a014ddb08bc47cd89f762
+Subproject commit 8179cdb67e70d7fb5605ab6ddedfd0bd3347db47
index a1fbc9f8e9a56684206d3470ac62561b5c4c7bac..cc81e7a90967f1b6c73a084bdab7b15c85439324 100644 (file)
 
        @define('CONST_Search_TryDroppedAddressTerms', false);
        @define('CONST_Search_NameOnlySearchFrequencyThreshold', 500);
+       // If set to true, then reverse order of queries will be tried by default.
+       // When set to false only selected languages alloow reverse search.
+       @define('CONST_Search_ReversePlanForAll', true);
+
+       @define('CONST_Places_Max_ID_count', 50); 
 
        // Set to zero to disable polygon output
        @define('CONST_PolygonOutput_MaximumTypes', 1);
index 3c8f16e0831a5696d7974f48889183bc79b9fc10..bd64697ad0801d53d26a641e72ef4040e4f84ac5 100644 (file)
@@ -2118,28 +2118,27 @@ BEGIN
 END; 
 $$ LANGUAGE plpgsql;
 
+
 CREATE OR REPLACE FUNCTION get_name_by_language(name hstore, languagepref TEXT[]) RETURNS TEXT
   AS $$
 DECLARE
-  search TEXT[];
-  found BOOLEAN;
+  result TEXT;
 BEGIN
-
   IF name is null THEN
     RETURN null;
   END IF;
 
-  search := languagepref;
-
-  FOR j IN 1..array_upper(search, 1) LOOP
-    IF name ? search[j] AND trim(name->search[j]) != '' THEN
-      return trim(name->search[j]);
+  FOR j IN 1..array_upper(languagepref,1) LOOP
+    IF name ? languagepref[j] THEN
+      result := trim(name->languagepref[j]);
+      IF result != '' THEN
+        return result;
+      END IF;
     END IF;
   END LOOP;
 
   -- anything will do as a fallback - just take the first name type thing there is
-  search := avals(name);
-  RETURN search[1];
+  RETURN trim((avals(name))[1]);
 END;
 $$
 LANGUAGE plpgsql IMMUTABLE;
index 9a9c379356fc08f9512e4a93ba84a818c08374e8..73ba662b17bfed4eafb2abae4310e6782b4ceded 100644 (file)
@@ -14,7 +14,7 @@ CREATE INDEX idx_placex_rank_search ON placex USING BTREE (rank_search) {ts:sear
 CREATE INDEX idx_placex_rank_address ON placex USING BTREE (rank_address) {ts:search-index};
 CREATE INDEX idx_placex_pendingsector ON placex USING BTREE (rank_search,geometry_sector) {ts:address-index} where indexed_status > 0;
 CREATE INDEX idx_placex_parent_place_id ON placex USING BTREE (parent_place_id) {ts:search-index} where parent_place_id IS NOT NULL;
-CREATE INDEX idx_placex_reverse_geometry ON placex USING gist (geometry) {ts:search-index} where rank_search != 28 and (name is not null or housenumber is not null) and class not in ('waterway','railway','tunnel','bridge');
+CREATE INDEX idx_placex_reverse_geometry ON placex USING gist (geometry) {ts:search-index} where rank_search != 28 and (name is not null or housenumber is not null) and class not in ('waterway','railway','tunnel','bridge','man_made');
 CREATE INDEX idx_location_area_country_place_id ON location_area_country USING BTREE (place_id) {ts:address-index};
 
 CREATE INDEX idx_search_name_country_centroid ON search_name_country USING GIST (centroid) {ts:address-index};
index a36c029e606a2e691d60a3961867203435a5d197..4c5638b14eaebaa26f25ab2b310b720c49bec1fb 100644 (file)
@@ -128,8 +128,10 @@ class NominatimTest extends \PHPUnit_Framework_TestCase
                // 4 words => 8 sets
                // 10 words => 511 sets
                // 15 words => 12911 sets
+               // 18 words => 65536 sets
                // 20 words => 169766 sets
-               // 28 words => 397594 sets
+               // 22 words => 401930 sets
+               // 28 words => 3505699 sets (needs more than 4GB via 'phpunit -d memory_limit=' to run)
                $this->assertEquals(
                        8,
                        count( getWordSets(array_fill( 0, 4, 'a'),0) )
@@ -137,8 +139,8 @@ class NominatimTest extends \PHPUnit_Framework_TestCase
 
 
                $this->assertEquals(
-                       8,
-                       count( getWordSets(array_fill( 0, 28, 'a'),0) )
+                       65536,
+                       count( getWordSets(array_fill( 0, 18, 'a'),0) )
                );
 
 
index 31fd21ed847af1d338fa247c556fbedc504b8052..d551c1da811ae9a5c292966a7e31f639652c928f 100644 (file)
@@ -6,7 +6,8 @@ https://phpunit.de/manual/4.2/en/
 installed.
 
 To execute the test suite run
-$ phpunit
+$ cd tests-php
+$ phpunit ./
 
 It will read phpunit.xml which points to the library, test path, bootstrap
 strip and set other parameters.
diff --git a/tests/features/api/lookup.feature b/tests/features/api/lookup.feature
new file mode 100644 (file)
index 0000000..7b86fb4
--- /dev/null
@@ -0,0 +1,15 @@
+Feature: Places by osm_type and osm_id Tests
+    Simple tests for internal server errors and response format.
+
+    Scenario: address lookup for existing node, way, relation
+        When looking up xml places N158845944,W72493656,,R62422,X99,N0
+        Then the result is valid xml
+        exactly 3 results are returned
+        When looking up json places N158845944,W72493656,,R62422,X99,N0
+        Then the result is valid json
+        exactly 3 results are returned
+
+    Scenario: address lookup for non-existing or invalid node, way, relation
+        When looking up xml places X99,,N0,nN158845944,ABC,,W9
+        Then the result is valid xml
+        exactly 0 results are returned
\ No newline at end of file
index f8c4f3883a7a6b4b6fb0bffb8ce70034e87421ee..fa636acf548b773f9b5df287f9f7ef6ab812512e 100644 (file)
@@ -36,3 +36,28 @@ Feature: Reverse geocoding
           | 0  | Kings Estate Drive | 84128    | us
         And result 0 has attributes osm_id,osm_type
 
+   Scenario Outline: Reverse Geocoding with extratags
+        Given the request parameters
+          | extratags
+          | 1
+        When looking up <format> coordinates 48.86093,2.2978
+        Then result 0 has attributes extratags
+
+   Examples:
+        | format
+        | xml
+        | json
+        | jsonv2
+
+   Scenario Outline: Reverse Geocoding with namedetails
+        Given the request parameters
+          | namedetails
+          | 1
+        When looking up <format> coordinates 48.86093,2.2978
+        Then result 0 has attributes namedetails
+
+   Examples:
+        | format
+        | xml
+        | json
+        | jsonv2
index 7d564dde77e0fb656d97204655c5a0c806ccfbf6..8621ec655903d80006909b7ecf9fff097287cf48 100644 (file)
@@ -94,4 +94,4 @@ Feature: Simple Reverse Tests
      | 48.966.0 | 8.4482
      | 48.966   | 8.448.2
      | Nan      | 8.448
-     | 48.966   | Nan
+     | 48.966   | Nan
\ No newline at end of file
index b9d06791572eadd16e4720f63c19b7b5d812b3b0..7099c72fe4d9f0e4c7fa4b75253f8529093aa441 100644 (file)
@@ -70,7 +70,7 @@ Feature: Search queries
         Then result addresses contain
           | ID | city
           | 0  | Chicago
-    
+
     Scenario: No POI search with unbounded viewbox
         Given the request parameters
           | viewbox
@@ -202,3 +202,31 @@ Feature: Search queries
         | 0.5
         | 999
         | nan
+
+    Scenario Outline: Search with extratags
+        Given the request parameters
+          | extratags
+          | 1
+        When sending <format> search query "Hauptstr"
+        Then result 0 has attributes extratags
+        And result 1 has attributes extratags
+
+    Examples:
+        | format
+        | xml
+        | json
+        | jsonv2
+
+    Scenario Outline: Search with namedetails
+        Given the request parameters
+          | namedetails
+          | 1
+        When sending <format> search query "Hauptstr"
+        Then result 0 has attributes namedetails
+        And result 1 has attributes namedetails
+
+    Examples:
+        | format
+        | xml
+        | json
+        | jsonv2
index 3e6b6e35b80fb85ccd4d6448b9979063799564d2..2cb27b7cf61be0c3237f23220d804bf876374d18 100644 (file)
@@ -51,6 +51,10 @@ Feature: Simple Tests
      | limit            | 1000
      | dedupe           | 1
      | dedupe           | 0
+     | extratags        | 1
+     | extratags        | 0
+     | namedetails      | 1
+     | namedetails      | 0
 
     Scenario: Search with invalid output format
         Given the request parameters
diff --git a/tests/features/db/update/search_terms.feature b/tests/features/db/update/search_terms.feature
new file mode 100644 (file)
index 0000000..d8c4440
--- /dev/null
@@ -0,0 +1,117 @@
+@DB
+Feature: Update of search terms
+    Tests that search_name table is filled correctly
+
+    Scenario: POI-inherited postcode remains when way type is changed
+        Given the scene roads-with-pois
+        And the place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S1
+        And the place ways
+         | osm_id | class   | type        | name     | geometry
+         | 1      | highway | residential | North St | :w-north
+        When importing
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+        When updating place ways
+         | osm_id | class   | type         | name     | geometry
+         | 1      | highway | unclassified | North St | :w-north
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+
+    Scenario: POI-inherited postcode remains when way name is changed
+        Given the scene roads-with-pois
+        And the place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S1
+        And the place ways
+         | osm_id | class   | type        | name     | geometry
+         | 1      | highway | residential | North St | :w-north
+        When importing
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+        When updating place ways
+         | osm_id | class   | type         | name     | geometry
+         | 1      | highway | unclassified | South St | :w-north
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+
+    Scenario: POI-inherited postcode remains when way geometry is changed
+        Given the scene roads-with-pois
+        And the place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S1
+        And the place ways
+         | osm_id | class   | type        | name     | geometry
+         | 1      | highway | residential | North St | :w-north
+        When importing
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+        When updating place ways
+         | osm_id | class   | type         | name     | geometry
+         | 1      | highway | unclassified | South St | :w-south
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+
+    Scenario: POI-inherited postcode is added when POI postcode changes
+        Given the scene roads-with-pois
+        And the place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S1
+        And the place ways
+         | osm_id | class   | type        | name     | geometry
+         | 1      | highway | residential | North St | :w-north
+        When importing
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+        When updating place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 54321    | North St |:p-S1
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 54321
+
+    Scenario: POI-inherited postcode remains when POI geometry changes
+        Given the scene roads-with-pois
+        And the place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S1
+        And the place ways
+         | osm_id | class   | type        | name     | geometry
+         | 1      | highway | residential | North St | :w-north
+        When importing
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+        When updating place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S2
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+
+
+    Scenario: POI-inherited postcode remains when another POI is deleted
+        Given the scene roads-with-pois
+        And the place nodes
+         | osm_id | class | type  | housenumber | postcode | street   | geometry
+         | 1      | place | house | 1           | 12345    | North St |:p-S1
+         | 2      | place | house | 2           |          | North St |:p-S2
+        And the place ways
+         | osm_id | class   | type        | name     | geometry
+         | 1      | highway | residential | North St | :w-north
+        When importing
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
+        When marking for delete N2
+        Then search_name table contains
+         | place_id | nameaddress_vector
+         | W1       | 12345
index 759c6b964e295665058d0c8e72d1e12f9e13dfe2..149c48138f9e693703c04d2fa1a4dc6affc187b0 100644 (file)
@@ -79,19 +79,20 @@ Feature: Tag evaluation
      | my:ref
      | br:name
      | name:prefix
+     | name:source
 
     Scenario: Special character in name tag
         Given the osm nodes:
          | id | tags
-         | 1  | 'highway' : 'yes', 'name: de' : 'Foo', 'name' : 'real'
-         | 2  | 'highway' : 'yes', 'name:\nde' : 'Foo', 'name' : 'real'
-         | 3  | 'highway' : 'yes', 'name:\tde' : 'Foo', 'name:\\' : 'real'
+         | 1  | 'highway' : 'yes', 'name: de' : 'Foo', 'name' : 'real1'
+         | 2  | 'highway' : 'yes', 'name:&#xa;de' : 'Foo', 'name' : 'real2'
+         | 3  | 'highway' : 'yes', 'name:&#x9;de' : 'Foo', 'name:\\' : 'real3'
         When loading osm data
         Then table place contains
          | object | name
-         | N1     | 'name:_de' : 'Foo', 'name' : 'real'
-         | N2     | 'name:_de' : 'Foo', 'name' : 'real'
-         | N3     | 'name:_de' : 'Foo', 'name:\\\\' : 'real'
+         | N1     | 'name: de' : 'Foo', 'name' : 'real1'
+         | N2     | 'name: de' : 'Foo', 'name' : 'real2'
+         | N3     | 'name: de' : 'Foo', 'name:\\\\' : 'real3'
 
     Scenario Outline: Included places
         Given the osm nodes:
@@ -217,6 +218,14 @@ Feature: Tag evaluation
       | boundary | administrative
       | waterway | stream
 
+    Scenario: Footways are not included if they are sidewalks
+        Given the osm nodes:
+         | id | tags
+         | 2  | 'highway' : 'footway', 'name' : 'To Hell', 'footway' : 'sidewalk'
+         | 23 | 'highway' : 'footway', 'name' : 'x'
+        When loading osm data
+        Then table place has no entry for N2
+
     Scenario: named junctions are included if there is no other tag
         Given the osm nodes:
          | id | tags
@@ -393,7 +402,7 @@ Feature: Tag evaluation
         Then table place contains
           | object | class   | type    | isin
           | N10    | place   | village | Feebourgh county
-          | N11    | place   | village | Alabama,Feebourgh county
+          | N11    | place   | village | Feebourgh county,Alabama
           | N12    | place   | village | Feebourgh county
 
     Scenario Outline: Import of address tags
@@ -508,6 +517,10 @@ Feature: Tag evaluation
        | locality
        | wikipedia
        | wikipedia:de
+       | wikidata
+       | name:prefix
+       | name:botanical
+       | name:etymology:wikidata
 
     Scenario: buildings
         Given the osm nodes:
index e86641fc7ee3b8402d5765a38186f1e5ad867d73..91c072968767ed6a499065ede0b68aba762afa3f 100644 (file)
@@ -27,17 +27,35 @@ def _parse_xml():
     world.results = []
 
     # results
-    if page.nodeName == 'searchresults':
+    if page.nodeName == 'searchresults' or page.nodeName == 'lookupresults':
         for node in page.childNodes:
             if node.nodeName != "#text":
                 assert_equals(node.nodeName, 'place', msg="Unexpected element '%s'" % node.nodeName)
                 newresult = OrderedDict(node.attributes.items())
                 assert_not_in('address', newresult)
                 assert_not_in('geokml', newresult)
+                assert_not_in('extratags', newresult)
+                assert_not_in('namedetails', newresult)
                 address = OrderedDict()
                 for sub in node.childNodes:
                     if sub.nodeName == 'geokml':
                         newresult['geokml'] = sub.childNodes[0].toxml()
+                    elif sub.nodeName == 'extratags':
+                        newresult['extratags'] = {}
+                        for tag in sub.childNodes:
+                            assert_equals(tag.nodeName, 'tag')
+                            attrs = dict(tag.attributes.items())
+                            assert_in('key', attrs)
+                            assert_in('value', attrs)
+                            newresult['extratags'][attrs['key']] = attrs['value']
+                    elif sub.nodeName == 'namedetails':
+                        newresult['namedetails'] = {}
+                        for tag in sub.childNodes:
+                            assert_equals(tag.nodeName, 'name')
+                            attrs = dict(tag.attributes.items())
+                            assert_in('desc', attrs)
+                            newresult['namedetails'][attrs['desc']] = tag.firstChild.nodeValue.strip()
+
                     elif sub.nodeName == '#text':
                         pass
                     else:
@@ -65,6 +83,21 @@ def _parse_xml():
                 for sub in node.childNodes:
                     address[sub.nodeName] = sub.firstChild.nodeValue.strip()
                 world.results[0]['address'] = address
+            elif node.nodeName == 'extratags':
+                world.results[0]['extratags'] = {}
+                for tag in node.childNodes:
+                    assert_equals(tag.nodeName, 'tag')
+                    attrs = dict(tag.attributes.items())
+                    assert_in('key', attrs)
+                    assert_in('value', attrs)
+                    world.results[0]['extratags'][attrs['key']] = attrs['value']
+            elif node.nodeName == 'namedetails':
+                world.results[0]['namedetails'] = {}
+                for tag in node.childNodes:
+                    assert_equals(tag.nodeName, 'name')
+                    attrs = dict(tag.attributes.items())
+                    assert_in('desc', attrs)
+                    world.results[0]['namedetails'][attrs['desc']] = tag.firstChild.nodeValue.strip()
             elif node.nodeName == "#text":
                 pass
             else:
@@ -92,6 +125,8 @@ def api_result_is_valid(step, fmt):
         _parse_xml()
     elif world.response_format == 'json':
         world.results = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(world.page)
+        if world.request_type == 'reverse':
+            world.results = (world.results,)
     else:
         assert False, "Unknown page format: %s" % (world.response_format)
 
index fcaa39a2adc91c01c4c9747f754562dc8f990452..c9a4bac476df5818df06cea9b4312a0fdc2a78c8 100644 (file)
@@ -10,6 +10,7 @@ import logging
 logger = logging.getLogger(__name__)
 
 def api_call(requesttype):
+    world.request_type = requesttype
     world.json_callback = None
     data = urllib.urlencode(world.params)
     url = "%s/%s?%s" % (world.config.base_url, requesttype, data)
@@ -123,6 +124,13 @@ def api_setup_details(step, obj):
         world.params['place_id']  = obj
     api_call('details')
 
+@step(u'looking up (\w+) places ((?:[a-z]\d+,*)+)')
+def api_setup_lookup(step, fmt, ids):
+    world.params['osm_ids'] = ids
+    if fmt and fmt.strip():
+        world.params['format'] = fmt.strip()
+    api_call('lookup')
+
 @step(u'sending an API call (\w+)')
 def api_general_call(step, call):
     api_call(call)
index e5198d9df97736d3a3685a2fd365cd7f3e2d8516..eaa14573b58675b9ce2ac403f51ba3a14e3c2223 100644 (file)
@@ -140,7 +140,7 @@ def osm2pgsql_load_place(step):
     world.osm2pgsql.sort(cmp=_sort_xml_entries)
 
     # create a OSM file in /tmp
-    with tempfile.NamedTemporaryFile(dir='/tmp', delete=False) as fd:
+    with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.osm', delete=False) as fd:
         fname = fd.name
         fd.write("<?xml version='1.0' encoding='UTF-8'?>\n")
         fd.write('<osm version="0.6" generator="test-nominatim" timestamp="2014-08-26T20:22:02Z">\n')
@@ -188,7 +188,7 @@ def osm2pgsql_update_place(step):
     world.run_nominatim_script('setup', 'index', 'index-noanalyse')
     world.run_nominatim_script('setup', 'create-functions', 'create-partition-functions', 'enable-diff-updates')
 
-    with tempfile.NamedTemporaryFile(dir='/tmp', delete=False) as fd:
+    with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.osc', delete=False) as fd:
         fname = fd.name
         fd.write("<?xml version='1.0' encoding='UTF-8'?>\n")
         fd.write('<osmChange version="0.6" generator="Osmosis 0.43.1">\n')
index b49813a8ab7f056603e469b8fd8e7fcdfd2c1258..eff7b71b447fef7fd36bab87e3db8569fef84231 100755 (executable)
@@ -39,6 +39,7 @@
                array('index-output', '', 0, 1, 1, 1, 'string', 'File to dump index information to'),
                array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'),
                array('create-website', '', 0, 1, 1, 1, 'realpath', 'Create symlinks to setup web directory'),
+               array('drop', '', 0, 1, 0, 0, 'bool', 'Drop tables needed for updates, making the database readonly (EXPERIMENTAL)'),
        );
        getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
 
        }
 
        // Assume we can steal all the cache memory in the box (unless told otherwise)
-       $iCacheMemory = (isset($aCMDResult['osm2pgsql-cache'])?$aCMDResult['osm2pgsql-cache']:getCacheMemoryMB());
-       if ($iCacheMemory > getTotalMemoryMB())
+       if (isset($aCMDResult['osm2pgsql-cache']))
+       {
+               $iCacheMemory = $aCMDResult['osm2pgsql-cache'];
+       }
+       else
        {
                $iCacheMemory = getCacheMemoryMB();
-               echo "WARNING: resetting cache memory to $iCacheMemory\n";
        }
 
        $aDSNInfo = DB::parseDSN(CONST_Database_DSN);
                        pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/postgis.sql');
                        pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/spatial_ref_sys.sql');
                } else {
-                       pgsqlRunScript('CREATE EXTENSION postgis');
+                       pgsqlRunScript('CREATE EXTENSION IF NOT EXISTS postgis');
                }
                if ($fPostgisVersion < 2.1) {
                        // Function was renamed in 2.1 and throws an annoying deprecation warning
                        $osm2pgsql .= ' --tablespace-main-data '.CONST_Tablespace_Place_Data;
                if (CONST_Tablespace_Place_Index)
                        $osm2pgsql .= ' --tablespace-main-index '.CONST_Tablespace_Place_Index;
-               $osm2pgsql .= ' -lsc -O gazetteer --hstore';
+               $osm2pgsql .= ' -lsc -O gazetteer --hstore --number-processes 1';
                $osm2pgsql .= ' -C '.$iCacheMemory;
                $osm2pgsql .= ' -P '.$aDSNInfo['port'];
                $osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file'];
                if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
        }
 
-       if ($aCMDResult['osmosis-init'] || $aCMDResult['all'])
+       if ($aCMDResult['osmosis-init'] || ($aCMDResult['all'] && !$aCMDResult['drop'])) // no use doing osmosis-init when dropping update tables
        {
                $bDidSomething = true;
                $oDB =& getDB();
                @symlink(CONST_BasePath.'/website/reverse.php', $sTargetDir.'/reverse.php');
                @symlink(CONST_BasePath.'/website/search.php', $sTargetDir.'/search.php');
                @symlink(CONST_BasePath.'/website/search.php', $sTargetDir.'/index.php');
+               @symlink(CONST_BasePath.'/website/lookup.php', $sTargetDir.'/lookup.php');
                @symlink(CONST_BasePath.'/website/deletable.php', $sTargetDir.'/deletable.php');
                @symlink(CONST_BasePath.'/website/polygons.php', $sTargetDir.'/polygons.php');
                @symlink(CONST_BasePath.'/website/status.php', $sTargetDir.'/status.php');
                }
        }
 
+       if ($aCMDResult['drop'])
+       {
+               // The implementation is potentially a bit dangerous because it uses
+               // a positive selection of tables to keep, and deletes everything else.
+               // Including any tables that the unsuspecting user might have manually
+               // created. USE AT YOUR OWN PERIL.
+               $bDidSomething = true;
+
+               // tables we want to keep. everything else goes.
+               $aKeepTables = array(
+                  "*columns",
+                  "import_polygon_*",
+                  "import_status",
+                  "place_addressline",
+                  "location_property*",
+                  "placex",
+                  "search_name",
+                  "seq_*",
+                  "word",
+                  "query_log",
+                  "new_query_log",
+                  "gb_postcode",
+                  "spatial_ref_sys",
+                  "country_name",
+                  "place_classtype_*"
+               );
+
+               $oDB =& getDB();
+               $aDropTables = array();
+               $aHaveTables = $oDB->getCol("SELECT tablename FROM pg_tables WHERE schemaname='public'");
+               if (PEAR::isError($aHaveTables))
+               {
+                       fail($aPartitions->getMessage());
+               }
+               foreach($aHaveTables as $sTable)
+               {
+                       $bFound = false;
+                       foreach ($aKeepTables as $sKeep)
+                       {
+                               if (fnmatch($sKeep, $sTable))
+                               {
+                                       $bFound = true;
+                                       break;
+                               }
+                       }
+                       if (!$bFound) array_push($aDropTables, $sTable);
+               }
+
+               foreach ($aDropTables as $sDrop)
+               {
+                       if ($aCMDResult['verbose']) echo "dropping table $sDrop\n";
+                       @pg_query($oDB->connection, "DROP TABLE $sDrop CASCADE");
+                       // ignore warnings/errors as they might be caused by a table having
+                       // been deleted already by CASCADE
+               }
+
+               if (!is_null(CONST_Osm2pgsql_Flatnode_File))
+               {
+                       if ($aCMDResult['verbose']) echo "deleting ".CONST_Osm2pgsql_Flatnode_File."\n";
+                       unlink(CONST_Osm2pgsql_Flatnode_File);
+               }
+       }
+
        if (!$bDidSomething)
        {
                showUsage($aCMDOptions, true);
index c5fc14a672fa1dbc6f7e8f87066b023a70ce6947..1379045068ec6b2b614af28713c6387c2803bc3a 100755 (executable)
@@ -83,7 +83,7 @@
                $iCacheMemory = getCacheMemoryMB();
                echo "WARNING: resetting cache memory to $iCacheMemory\n";
        }
-       $sOsm2pgsqlCmd = CONST_Osm2pgsql_Binary.' -klas -C '.$iCacheMemory.' -O gazetteer -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'];
+       $sOsm2pgsqlCmd = CONST_Osm2pgsql_Binary.' -klas --number-processes 1 -C '.$iCacheMemory.' -O gazetteer -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'];
        if (!is_null(CONST_Osm2pgsql_Flatnode_File))
        {
                $sOsm2pgsqlCmd .= ' --flat-nodes '.CONST_Osm2pgsql_Flatnode_File;
index aad75443127a7f87401e9d9efdca5128b744d1cd..68e279c54eb52a9a0cc7eb5d91de64c1b38862f3 100755 (executable)
@@ -84,8 +84,6 @@ sudo apt-get install -y libprotobuf-c0-dev protobuf-c-compiler \
 
 # now ideally login as $USERNAME and continue
 su $USERNAME -l
-pwd
-ls -la /home/vagrant
 cd /home/vagrant/Nominatim
 
 # cd ~/Nominatim
@@ -96,6 +94,12 @@ chmod +x ./
 chmod +x ./module
 
 
+LOCALSETTINGS_FILE='settings/local.php'
+if [[ -e "$LOCALSETTINGS_FILE" ]]; then
+  echo "$LOCALSETTINGS_FILE already exist, writing to settings/local-vagrant.php instead."
+  LOCALSETTINGS_FILE='settings/local-vagrant.php'
+fi
+
 # IP=`curl -s http://bot.whatismyipaddress.com`
 IP=localhost
 echo "<?php
@@ -106,7 +110,7 @@ echo "<?php
    @define('CONST_Postgis_Version', '2.1');
    // Website settings
    @define('CONST_Website_BaseURL', 'http://$IP:8089/nominatim/');
-" > settings/local.php
+" > $LOCALSETTINGS_FILE
 
 
 
@@ -118,7 +122,7 @@ echo "<?php
 ### Setup Apache/website
 ###
 
-createuser -SDR www-data
+sudo -u postgres createuser -SDR www-data
 
 echo '
 Listen 8089
diff --git a/website/lookup.php b/website/lookup.php
new file mode 100755 (executable)
index 0000000..51abe1f
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+       @define('CONST_ConnectionBucket_PageType', 'Reverse');
+
+       require_once(dirname(dirname(__FILE__)).'/lib/init-website.php');
+       require_once(CONST_BasePath.'/lib/log.php');
+       require_once(CONST_BasePath.'/lib/PlaceLookup.php');
+
+       if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
+       {
+               $fLoadAvg = getLoadAverage();
+               if ($fLoadAvg > 2) sleep(60);
+               if ($fLoadAvg > 4) sleep(120);
+               if ($fLoadAvg > 6)
+               {
+                       userError("Bulk User: Temporary block due to high server load");
+                       exit;
+               }
+       }
+
+       $oDB =& getDB();
+       ini_set('memory_limit', '200M');
+
+       // Format for output
+       $sOutputFormat = 'xml';
+       if (isset($_GET['format']) && ($_GET['format'] == 'xml' || $_GET['format'] == 'json'))
+       {
+               $sOutputFormat = $_GET['format'];
+       }
+
+       // Preferred language
+       $aLangPrefOrder = getPreferredLanguages();
+
+       $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
+
+       $aSearchResults = array();
+       $aCleanedQueryParts = array();
+       if (isset($_GET['osm_ids']))
+       {
+               $oPlaceLookup = new PlaceLookup($oDB);
+               $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
+               $oPlaceLookup->setIncludeAddressDetails(getParamBool('addressdetails', true));
+               $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
+               $oPlaceLookup->setIncludeNameDetails(getParamBool('namedetails', false));
+               
+               $aOsmIds = explode(',', $_GET['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.");
+                       exit;
+               }
+               
+               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;
+                               $oPlaceLookup->setOSMID($sType, $iId);
+                               $oPlace = $oPlaceLookup->lookup();
+                               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;
+
+       $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');
index 93cb58771cd3ad68df10ab6ec50798e4102bd77d..abc33a09ed297e382cc1d3862fc8147badc63e6f 100755 (executable)
                $sOutputFormat = $_GET['format'];
        }
 
-       // Show address breakdown
-       $bShowAddressDetails = true;
-       if (isset($_GET['addressdetails'])) $bShowAddressDetails = (bool)$_GET['addressdetails'];
-
        // Preferred language
        $aLangPrefOrder = getPreferredLanguages();
 
        $hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
+
        if (isset($_GET['osm_type']) && isset($_GET['osm_id']) && (int)$_GET['osm_id'] && ($_GET['osm_type'] == 'N' || $_GET['osm_type'] == 'W' || $_GET['osm_type'] == 'R'))
        {
-               $oPlaceLookup = new PlaceLookup($oDB);
-               $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
-               $oPlaceLookup->setIncludeAddressDetails($bShowAddressDetails);
-               $oPlaceLookup->setOSMID($_GET['osm_type'], $_GET['osm_id']);
-
-               $aPlace = $oPlaceLookup->lookup();
+               $aLookup = array('osm_type' => $_GET['osm_type'], 'osm_id' => $_GET['osm_id']);
        }
        else if (isset($_GET['lat']) && isset($_GET['lon']) && preg_match('/^[+-]?[0-9]*\.?[0-9]+$/', $_GET['lat']) && preg_match('/^[+-]?[0-9]*\.?[0-9]+$/', $_GET['lon']))
        {
                $oReverseGeocode = new ReverseGeocode($oDB);
                $oReverseGeocode->setLanguagePreference($aLangPrefOrder);
-               $oReverseGeocode->setIncludeAddressDetails($bShowAddressDetails);
 
                $oReverseGeocode->setLatLon($_GET['lat'], $_GET['lon']);
                $oReverseGeocode->setZoom(@$_GET['zoom']);
 
-               $aPlace = $oReverseGeocode->lookup();
+               $aLookup = $oReverseGeocode->lookup();
+               if (CONST_Debug) var_dump($aLookup);
+       }
+       else
+       {
+               $aLookup = null;
+       }
+
+       if ($aLookup)
+       {
+               $oPlaceLookup = new PlaceLookup($oDB);
+               $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
+               $oPlaceLookup->setIncludeAddressDetails(getParamBool('addressdetails', true));
+               $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
+               $oPlaceLookup->setIncludeNameDetails(getParamBool('namedetails', false));
+
+               $aPlace = $oPlaceLookup->lookupPlace($aLookup);
        }
        else
        {
                $aPlace = null;
        }
 
-       if (CONST_Debug) exit;
+
+       if (CONST_Debug)
+       {
+               var_dump($aPlace);
+               exit;
+       }
 
        include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
index bf27ef9a8157e734536b60196f35f009cf3d19ba..b107e120c4fde6d38c0e575f15a647dcb394060e 100755 (executable)
        $aLangPrefOrder = getPreferredLanguages();
        $oGeocode->setLanguagePreference($aLangPrefOrder);
 
-       if (isset($aLangPrefOrder['name:de'])) $oGeocode->setReverseInPlan(true);
-       if (isset($aLangPrefOrder['name:ru'])) $oGeocode->setReverseInPlan(true);
-       if (isset($aLangPrefOrder['name:ja'])) $oGeocode->setReverseInPlan(true);
-       if (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 = 'html';
        $bShowPolygons = (isset($_GET['polygon']) && $_GET['polygon']);
        $aExcludePlaceIDs = $oGeocode->getExcludedPlaceIDs();
 
-       $sMoreURL = CONST_Website_BaseURL.'search?format='.urlencode($sOutputFormat).'&exclude_place_ids='.join(',',$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 ($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);
index a876f999ffc456b820568044df4e1c03bc2a44f7..832f4600c60032c2913fdcd78d8615c5677717f9 100644 (file)
@@ -10,7 +10,7 @@
                exit;
        }
 
-       $oDB =& getDB();
+       $oDB =& DB::connect(CONST_Database_DSN, false);
        if (!$oDB || PEAR::isError($oDB))
        {
                statusError("No database");