]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 22 May 2015 20:10:56 +0000 (22:10 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 22 May 2015 20:10:56 +0000 (22:10 +0200)
lib/Geocode.php
lib/init-cmd.php
settings/settings.php
sql/tables.sql
tests/features/api/search.feature
tests/features/api/search_params.feature
tests/steps/api_result.py

index 2d5d33944e640a7b0fa92bfc6bb028ae84dc68bb..c79dcf1ea5d41e49af50b7c0cbd4168af264c28d 100644 (file)
 
                        foreach($aSearchResults as $iResNum => $aResult)
                        {
+                               // Default
+                               $fDiameter = 0.0001;
+
+                               if (isset($aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
+                                               && $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
+                               {
+                                       $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defzoom'];
+                               }
+                               elseif (isset($aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
+                                               && $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
+                               {
+                                       $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'];
+                               }
+                               $fRadius = $fDiameter / 2;
+
                                if (CONST_Search_AreaPolygons)
                                {
                                        // Get the bounding box and outline polygon
                             */
                                                        elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#',$aPointPolygon['astext'],$aMatch))
                                                        {
-                                                               $fRadius = 0.01;
                                                                $iSteps = ($fRadius * 40000)^2;
                                                                $fStepSize = (2*pi())/$iSteps;
                                                                $aPolyPoints = array();
                                                                {
                                                                        $aPolyPoints[] = array('',$aMatch[1]+($fRadius*sin($f)),$aMatch[2]+($fRadius*cos($f)));
                                                                }
-                                                               $aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
-                                                               $aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
-                                                               $aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
-                                                               $aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
                                                        }
                                                }
 
                                                                $aResult['aPolyPoints'][] = array($aPoint[1], $aPoint[2]);
                                                        }
                                                }
+
+                                               if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001)
+                                               {
+                                                       $aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
+                                                       $aPointPolygon['maxlat'] = $aPointPolygon['maxlat'] + $fRadius;
+                                               }
+                                               if (abs($aPointPolygon['minlon'] - $aPointPolygon['maxlon']) < 0.0000001)
+                                               {
+                                                       $aPointPolygon['minlon'] = $aPointPolygon['minlon'] - $fRadius;
+                                                       $aPointPolygon['maxlon'] = $aPointPolygon['maxlon'] + $fRadius;
+                                               }
                                                $aResult['aBoundingBox'] = array($aPointPolygon['minlat'],$aPointPolygon['maxlat'],$aPointPolygon['minlon'],$aPointPolygon['maxlon']);
                                        }
                                }
 
                                if (!isset($aResult['aBoundingBox']))
                                {
-                                       // Default
-                                       $fDiameter = 0.0001;
-
-                                       if (isset($aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
-                                                       && $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
-                                       {
-                                               $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defzoom'];
-                                       }
-                                       elseif (isset($aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
-                                                       && $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
-                                       {
-                                               $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'];
-                                       }
-                                       $fRadius = $fDiameter / 2;
-
                                        $iSteps = max(8,min(100,$fRadius * 3.14 * 100000));
                                        $fStepSize = (2*pi())/$iSteps;
-                                       $aPolyPoints = array();
-                                       for($f = 0; $f < 2*pi(); $f += $fStepSize)
-                                       {
-                                               $aPolyPoints[] = array('',$aResult['lon']+($fRadius*sin($f)),$aResult['lat']+($fRadius*cos($f)));
-                                       }
                                        $aPointPolygon['minlat'] = $aResult['lat'] - $fRadius;
                                        $aPointPolygon['maxlat'] = $aResult['lat'] + $fRadius;
                                        $aPointPolygon['minlon'] = $aResult['lon'] - $fRadius;
                                        // Output data suitable for display (points and a bounding box)
                                        if ($this->bIncludePolygonAsPoints)
                                        {
+                                               $aPolyPoints = array();
+                                               for($f = 0; $f < 2*pi(); $f += $fStepSize)
+                                               {
+                                                       $aPolyPoints[] = array('',$aResult['lon']+($fRadius*sin($f)),$aResult['lat']+($fRadius*cos($f)));
+                                               }
                                                $aResult['aPolyPoints'] = array();
                                                foreach($aPolyPoints as $aPoint)
                                                {
index e6de0522146fe381770662f78fad11542442ac7b..e5a650fc1a49ebb9e01aa73dcbf187b26f7a90d1 100644 (file)
@@ -6,3 +6,26 @@
 
        require_once('init.php');
        require_once('cmd.php');
+
+       // handle http proxy when using file_get_contents
+       if (CONST_HTTP_Proxy) {
+         $proxy = 'tcp://' . CONST_HTTP_Proxy_Host . ':' . CONST_HTTP_Proxy_Port;
+         $aHeaders = array();
+         if(CONST_HTTP_Proxy_Login != null && CONST_HTTP_Proxy_Login != '' && CONST_HTTP_Proxy_Password != null && CONST_HTTP_Proxy_Password != '') {
+           $auth = base64_encode(CONST_HTTP_Proxy_Login . ':' . CONST_HTTP_Proxy_Password);
+           $aHeaders = array("Proxy-Authorization: Basic $auth");
+         }
+         $aContext = array(
+           'http' => array(
+             'proxy' => $proxy,
+             'request_fulluri' => true,
+             'header' => $aHeaders
+           ),
+           'https' => array(
+             'proxy' => $proxy,
+             'request_fulluri' => true,
+             'header' => $aHeaders
+           )
+         );
+         stream_context_set_default($aContext);
+       }
index 694c8352990fe29d859933e7149451ebe5515832..ccf75f878b1424427bbd261755b72251861756f1 100644 (file)
@@ -9,6 +9,13 @@
        @define('CONST_Max_Word_Frequency', '50000');
        @define('CONST_Limit_Reindexing', true);
 
+       // Proxy settings
+       @define('CONST_HTTP_Proxy', false);
+       @define('CONST_HTTP_Proxy_Host', 'proxy.mydomain.com');
+       @define('CONST_HTTP_Proxy_Port', '3128');
+       @define('CONST_HTTP_Proxy_Login', '');
+       @define('CONST_HTTP_Proxy_Password', '');
+
        // Software versions
        @define('CONST_Postgresql_Version', '9.3'); // values: 9.0, ... , 9.4
        @define('CONST_Postgis_Version', '2.1'); // values: 1.5, 2.0, 2.1
index dcee40700036bcc07707a60e988f9e66fd1da444..ccca8f138f044485314bdeec244da80f695d3d29 100644 (file)
@@ -171,9 +171,6 @@ CREATE TRIGGER place_before_delete BEFORE DELETE ON place
 CREATE TRIGGER place_before_insert BEFORE INSERT ON place
     FOR EACH ROW EXECUTE PROCEDURE place_insert();
 
-drop index idx_placex_sector;
-CREATE INDEX idx_placex_sector ON placex USING BTREE (geometry_sector,rank_address,osm_type,osm_id) {ts:address-index};
-
 DROP SEQUENCE seq_postcodes;
 CREATE SEQUENCE seq_postcodes start 1;
 
index 859faa76f1256847d18e3eb703d6da8bbe026c02..c7ce7d3ba250a7318043726f483da7e8adb03118 100644 (file)
@@ -36,7 +36,7 @@ Feature: Search queries
         Then address of result 0 contains
           | type         | value
           | house_number | 140
-          | road         | rue Don Bosco
+          | road         | [Rr]ue Don Bosco
           | city         | Saguenay
           | state        | Quebec
           | country      | Canada
@@ -50,7 +50,7 @@ Feature: Search queries
         Then address of result 0 contains
           | type         | value
           | house_number | 141
-          | road         | rue Don Bosco
+          | road         | [rR]ue Don Bosco
           | city         | Saguenay
           | state        | Quebec
           | country      | Canada
index 1062cd0277c3702a015e3a8bc64fe4f532f6dcc1..b9d06791572eadd16e4720f63c19b7b5d812b3b0 100644 (file)
@@ -83,7 +83,7 @@ Feature: Search queries
     Scenario: bounded search remains within viewbox, even with no results
         Given the request parameters
          | bounded | viewbox
-         | 1       | -5.662003,43.54285,-5.6563282,43.5403125
+         | 1       | 43.54285,-5.662003,43.5403125,-5.6563282
          When sending json search query "restaurant"
         Then less than 1 result is returned
 
index 369127d861d6e0e1b79b777008a57a45fcca9982..e86641fc7ee3b8402d5765a38186f1e5ad867d73 100644 (file)
@@ -199,7 +199,10 @@ def api_result_address_exact(step, resid):
     addr = world.results[resid]['address']
     for line in step.hashes:
         assert_in(line['type'], addr)
-        assert_equals(line['value'], addr[line['type']])
+        m = re.match("%s$" % line['value'], addr[line['type']])
+        assert_is_not_none(m, msg="field %s does not match: %s$ != %s." % (
+                                  line['type'], line['value'], addr[line['type']]))
+        #assert_equals(line['value'], addr[line['type']])
 
 @step(u'address of result (\d+) does not contain (.*)')
 def api_result_address_details_missing(step, resid, types):