]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge branch 'reverse-lookup-including-tiger-lookup' of https://github.com/mtmail...
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 30 Apr 2015 19:48:25 +0000 (21:48 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 30 Apr 2015 19:48:25 +0000 (21:48 +0200)
configure.ac
lib/Geocode.php
settings/settings.php
tests/features/api/search.feature
tests/features/api/search_params.feature
website/search.php

index cc77d333ae4cb32b53f04b4cfe3f2f91e5ca0f00..badcb5b224258b4ef2754775a9ba53d86db8302f 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT(Nominatim,2.4)
+AC_INIT(Nominatim,2.5)
 if git rev-parse HEAD 2>/dev/null >/dev/null; then
     AC_SUBST([PACKAGE_VERSION], [$PACKAGE_VERSION-git-`git rev-parse --short HEAD`])
 fi
index 7bd4f55295513518794abbcc5e91405a3b2c9a69..212eebb97cc2a3b04f8a5369755fe6cc79163cc9 100644 (file)
@@ -12,6 +12,7 @@
                protected $bIncludePolygonAsGeoJSON = false;
                protected $bIncludePolygonAsKML = false;
                protected $bIncludePolygonAsSVG = false;
+               protected $fPolygonSimplificationThreshold = 0.0;
 
                protected $aExcludePlaceIDs = array();
                protected $bDeDupe = true;
                        $this->bIncludePolygonAsSVG = $b;
                }
 
+               function setPolygonSimplificationThreshold($f)
+               {
+                       $this->fPolygonSimplificationThreshold = $f;
+               }
+
                function setDeDupe($bDeDupe = true)
                {
                        $this->bDeDupe = (bool)$bDeDupe;
                                                                                        else $aSearch['sOperator'] = 'near'; // near = in for the moment
                                                                                        if (strlen($aSearchTerm['operator']) == 0) $aSearch['iSearchRank'] += 1;
 
-                                                                                       // Do we have a shortcut id?
-                                                                                       if ($aSearch['sOperator'] == 'name')
-                                                                                       {
-                                                                                               $sSQL = "select get_tagpair('".$aSearch['sClass']."', '".$aSearch['sType']."')";
-                                                                                               if ($iAmenityID = $this->oDB->getOne($sSQL))
-                                                                                               {
-                                                                                                       $aValidTokens[$aSearch['sClass'].':'.$aSearch['sType']] = array('word_id' => $iAmenityID);
-                                                                                                       $aSearch['aName'][$iAmenityID] = $iAmenityID;
-                                                                                                       $aSearch['sClass'] = '';
-                                                                                                       $aSearch['sType'] = '';
-                                                                                               }
-                                                                                       }
                                                                                        if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                }
                                                                        }
                        if (!$this->sQuery && !$this->aStructuredQuery) return false;
 
                        $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$this->aLangPrefOrder))."]";
-
                        $sCountryCodesSQL = false;
                        if ($this->aCountryCodes && sizeof($this->aCountryCodes))
                        {
                                        if ($this->bIncludePolygonAsKML) $sSQL .= ",ST_AsKML(geometry) as askml";
                                        if ($this->bIncludePolygonAsSVG) $sSQL .= ",ST_AsSVG(geometry) as assvg";
                                        if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ",ST_AsText(geometry) as astext";
-                                       $sSQL .= " from placex where place_id = ".$aResult['place_id'];
+                                       $sFrom = " from placex where place_id = ".$aResult['place_id'];
+                                       if ($this->fPolygonSimplificationThreshold > 0)
+                                       {
+                                               $sSQL .= " from (select place_id,centroid,ST_SimplifyPreserveTopology(geometry,".$this->fPolygonSimplificationThreshold.") as geometry".$sFrom.") as plx";
+                                       }
+                                       else
+                                       {
+                                               $sSQL .= $sFrom;
+                                       }
+
                                        $aPointPolygon = $this->oDB->getRow($sSQL);
                                        if (PEAR::IsError($aPointPolygon))
                                        {
index a04795efa30035455d9ab65fda19f87492a3fdbc..75b9ac237ea9ee8a3eed4f2a468d8e72e81c3909 100644 (file)
@@ -10,8 +10,8 @@
        @define('CONST_Limit_Reindexing', true);
 
        // Software versions
-       @define('CONST_Postgresql_Version', '9.1'); // values: 9.0, 9.1, 9.2
-       @define('CONST_Postgis_Version', '1.5'); // values: 1.5, 2.0
+       @define('CONST_Postgresql_Version', '9.3'); // values: 9.0, ... , 9.4
+       @define('CONST_Postgis_Version', '2.1'); // values: 1.5, 2.0, 2.1
 
        // Paths
        @define('CONST_Path_Postgresql_Contrib', '/usr/share/postgresql/'.CONST_Postgresql_Version.'/contrib');
index ac378b0e0d6c137a71b13ea54bd0eb417504e9b4..859faa76f1256847d18e3eb703d6da8bbe026c02 100644 (file)
@@ -74,3 +74,9 @@ Feature: Search queries
         Then results contain
           | ID | display_name
           | 0  | Illinois.*
+
+    Scenario: Search with class-type feature
+        When sending jsonv2 search query "Hotel California"
+        Then results contain
+          | place_rank
+          | 30
index 23a6bf5938eb46690efdbd5de2ab2dd73f56d828..1062cd0277c3702a015e3a8bc64fe4f532f6dcc1 100644 (file)
@@ -170,3 +170,35 @@ Feature: Search queries
         Then results contain
           | ID | display_name
           | 0  | Everest.*
+
+    Scenario Outline: Search with polygon threshold (json)
+        Given the request parameters
+          | polygon_geojson | polygon_threshold
+          | 1               | <th>
+        When sending json search query "switzerland"
+        Then at least 1 result is returned
+        And result 0 has attributes geojson
+
+     Examples:
+        | th
+        | -1
+        | 0.0
+        | 0.5
+        | 999
+        | nan
+
+    Scenario Outline: Search with polygon threshold (xml)
+        Given the request parameters
+          | polygon_geojson | polygon_threshold
+          | 1               | <th>
+        When sending xml search query "switzerland"
+        Then at least 1 result is returned
+        And result 0 has attributes geojson
+
+     Examples:
+        | th
+        | -1
+        | 0.0
+        | 0.5
+        | 999
+        | nan
index a9e20d4eb47e564fa4889b42312869ecd8b3462e..bf27ef9a8157e734536b60196f35f009cf3d19ba 100755 (executable)
                $oGeocode->setIncludePolygonAsSVG($bAsSVG);
        }
 
+       // Polygon simplification threshold (optional)
+       $fThreshold = 0.0;
+       if (isset($_GET['polygon_threshold'])) $fThreshold = (float)$_GET['polygon_threshold'];
+       $oGeocode->setPolygonSimplificationThreshold($fThreshold);
+
        $oGeocode->loadParamArray($_GET);
 
        if (CONST_Search_BatchMode && isset($_GET['batch']))