]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge branch 'tigerlines' of /home/markus/Nominatim into tiger
authorMarkus Gail <markus.gail.94@gmail.com>
Mon, 21 Mar 2016 13:26:39 +0000 (14:26 +0100)
committerMarkus Gail <markus.gail.94@gmail.com>
Tue, 22 Mar 2016 10:26:39 +0000 (11:26 +0100)
Conflicts:
lib/Geocode.php
lib/ReverseGeocode.php
lib/lib.php

1  2 
lib/Geocode.php
lib/PlaceLookup.php
lib/ReverseGeocode.php
settings/settings.php
tests-php/Nominatim/NominatimTest.php

diff --cc lib/Geocode.php
index 8eaa540263c0fc825bc368a077325c4264305520,c24c84ae9cf98e76619f5f5e8b5315689eae4143..4b15b3c814980588f7849f5428f8f574ffd7dad1
  
                                                        if ($aSearch['sClass'] && sizeof($aPlaceIDs))
                                                        {
--                                                              $sPlaceIDs = join(',', aPlaceIDs);
++                                                              $sPlaceIDs = join(',', $aPlaceIDs);
                                                                $aClassPlaceIDs = array();
  
                                                                if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'name')
index f62ca6275a73941c8ad1c7bbde29c6af7c619628,55e0f11cf50c68731cf04e498273ce1e07aa2018..985ed224a64213f46ddcfd9d5e0d9fa1dbd0b4fd
                                $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, 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, housenumber,$sLanguagePrefArraySQL) as langaddress,";
++                              $sSQL .= " get_address_by_language(place_id, housenumber, $sLanguagePrefArraySQL) as langaddress,";
                                $sSQL .= " null as placename,";
                                $sSQL .= " null as ref,";
                                if ($this->bExtraTags) $sSQL .= " null as extra,";
index 9eb7f7f2834f003e7f9b63abd7fcc6e30e4c5ef8,2a901e3b36ea4213ede6f89c4ba3d5910e7b8b0d..3dff161e4136a443b6362171c719057b8d8f5b39
                                $sSQL .= ' AND ST_DWithin('.$sPointSQL.', linegeo, '.$fSearchDiam.')';  //no centroid anymore in Tiger data, now we have lines
                                $sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', linegeo) ASC limit 1';
  
--
--                              // print all house numbers in the parent (street)
--                              /*if (CONST_Debug)
++                              if (CONST_Debug)
                                {
                                        $sSQL = preg_replace('/limit 1/', 'limit 100', $sSQL);
                                        var_dump($sSQL);
                                        {
                                                echo $i['housenumber'] . ' | ' . $i['distance'] * 1000 . ' | ' . $i['lat'] . ' | ' . $i['lon']. ' | '. "<br>\n";
                                        }
--                              }*/
++                              }
  
                                $aPlaceTiger = $this->oDB->getRow($sSQL);
                                if (PEAR::IsError($aPlace))
                        }
  
                        return array('place_id' => $iPlaceID,
-                                    'type' => $bPlaceIsTiger ? 'tiger' : 'osm');
 -                                               'type' => $bPlaceIsTiger ? 'tiger' : 'osm',
 -                                               'fraction' => $bPlaceIsTiger ? $iFraction : -1 );
++                                              'type' => $bPlaceIsTiger ? 'tiger' : 'osm',
++                                              'fraction' => $bPlaceIsTiger ? $iFraction : -1);
                }
 +              
        }
  ?>
index 7285ee66995553f722f1dbc2c6fe5e6757fc2f48,3427d5e0f4ea4c615e4a6fc03b1e15c5c2e549cc..d48aff7340192b3b9ad4038686e06cd6324545f9
@@@ -6,7 -4,7 +6,7 @@@
  
        // General settings
        @define('CONST_Debug', false);
--    @define('CONST_Database_DSN', 'pgsql://@/nominatim'); // <driver>://<username>:<password>@<host>:<port>/<database>
++      @define('CONST_Database_DSN', 'pgsql://@/nominatim'); // <driver>://<username>:<password>@<host>:<port>/<database>
        @define('CONST_Database_Web_User', 'www-data');
        @define('CONST_Max_Word_Frequency', '50000');
        @define('CONST_Limit_Reindexing', true);
index d50a8da4a4a0f487ca1686cdfc450da36fd86415,129fa01201f9a5c96a205b3652daf5063afa4852..8213be0049a62c7230f55ef944244dcc35c4a563
@@@ -187,74 -142,72 +187,136 @@@ class NominatimTest extends \PHPUnit_Fr
                        65536,
                        count( getWordSets(array_fill( 0, 18, 'a'),0) )
                );
 +      }
  
+       }
+       public function test_geometryText2Points()
+       {
+               $fRadius = 1;
+               // invalid value
+               $this->assertEquals(
+                       NULL,
+                       geometryText2Points('', $fRadius)
+               );
+               // POINT
+               $aPoints = geometryText2Points('POINT(10 20)', $fRadius);
+               $this->assertEquals(
+                       101,
+                       count($aPoints)
+               );
+               $this->assertEquals(
+               array(
+                       ['', 10, 21],
+                       ['', 10.062790519529, 20.998026728428],
+                               ['', 10.125333233564, 20.992114701314]
+                       ),
+                       array_splice($aPoints, 0,3)
+               );
+               // POLYGON
+               $this->assertEquals(
+                       array(
+                               ['30 10', '30', '10'],
+                               ['40 40', '40', '40'],
+                               ['20 40', '20', '40'],
+                               ['10 20', '10', '20'],
+                               ['30 10', '30', '10']
+                       ),
+                       geometryText2Points('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))', $fRadius)
+               );
+               // MULTIPOLYGON
+               // only the first polygon is used
+               $this->assertEquals(
+                       array(
+                               ['30 20', '30', '20'],
+                               ['45 40', '45', '40'],
+                               ['10 40', '10', '40'],
+                               ['30 20', '30', '20'],
+                               // ['15 5' , '15', '5' ],
+                               // ['45 10', '45', '10'],
+                               // ['10 20', '10', '20'],
+                               // ['5 10' , '5' , '10'],
+                               // ['15 5' , '15', '5' ]
+                       ),
+                       geometryText2Points('MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))', $fRadius)
+               );
  
 +      // you might say we're creating a circle
 +      public function test_createPointsAroundCenter()
 +      {
 +              $aPoints = createPointsAroundCenter(0, 0, 2);
  
 +              $this->assertEquals(
 +                      101,
 +                      count($aPoints)
 +              );
 +              $this->assertEquals(
 +                      array(
 +                              ['', 0, 2],
 +                              ['', 0.12558103905863, 1.9960534568565],
 +                              ['', 0.25066646712861, 1.984229402629]
 +                      ),
 +                      array_splice($aPoints, 0, 3)
 +              );
        }
  
 +      public function test_geometryText2Points()
 +      {
 +              $fRadius = 1;
 +              // invalid value
 +              $this->assertEquals(
 +                      NULL,
 +                      geometryText2Points('', $fRadius)
 +              );
 +
 +              // POINT
 +              $aPoints = geometryText2Points('POINT(10 20)', $fRadius);
 +              $this->assertEquals(
 +                      101,
 +                      count($aPoints)
 +              );
 +              $this->assertEquals(
 +                      array(
 +                              [10, 21],
 +                              [10.062790519529, 20.998026728428],
 +                              [10.125333233564, 20.992114701314]
 +                      ),
 +                      array_splice($aPoints, 0,3)
 +              );
 +
 +              // POLYGON
 +              $this->assertEquals(
 +                      array(
 +                              ['30', '10'],
 +                              ['40', '40'],
 +                              ['20', '40'],
 +                              ['10', '20'],
 +                              ['30', '10']
 +                      ),
 +                      geometryText2Points('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))', $fRadius)
 +              );
 +
 +              // MULTIPOLYGON
 +              $this->assertEquals(
 +                      array(
 +                              ['30', '20'], // first polygon only
 +                              ['45', '40'],
 +                              ['10', '40'],
 +                              ['30', '20'],
 +                      ),
 +                      geometryText2Points('MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))', $fRadius)
 +              );
 +      }
  
  }