]> git.openstreetmap.org Git - nominatim.git/blob - test/php/Nominatim/ClassTypesTest.php
use address rank for address forming when available
[nominatim.git] / test / php / Nominatim / ClassTypesTest.php
1 <?php
2
3 namespace Nominatim;
4
5 require_once(CONST_BasePath.'/lib/ClassTypes.php');
6
7 class ClassTypesTest extends \PHPUnit\Framework\TestCase
8 {
9     public function testGetLabelTag()
10     {
11         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
12                    'rank_address' => '4', 'place_type' => 'city');
13         $this->assertEquals('city', ClassTypes\getLabelTag($aPlace));
14
15         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
16                    'rank_address' => '10');
17         $this->assertEquals('state_district', ClassTypes\getLabelTag($aPlace));
18
19         $aPlace = array('class' => 'boundary', 'type' => 'administrative');
20         $this->assertEquals('administrative', ClassTypes\getLabelTag($aPlace));
21
22         $aPlace = array('class' => 'place', 'type' => 'hamlet', 'rank_address' => '20');
23         $this->assertEquals('hamlet', ClassTypes\getLabelTag($aPlace));
24
25         $aPlace = array('class' => 'highway', 'type' => 'residential',
26                    'rank_address' => '26');
27         $this->assertEquals('road', ClassTypes\getLabelTag($aPlace));
28
29         $aPlace = array('class' => 'place', 'type' => 'house_number',
30                    'rank_address' => '30');
31         $this->assertEquals('house_number', ClassTypes\getLabelTag($aPlace));
32
33         $aPlace = array('class' => 'amenity', 'type' => 'prison',
34                    'rank_address' => '30');
35         $this->assertEquals('amenity', ClassTypes\getLabelTag($aPlace));
36     }
37
38     public function testGetLabel()
39     {
40         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
41                    'rank_address' => '4', 'place_type' => 'city');
42         $this->assertEquals('City', ClassTypes\getLabel($aPlace));
43
44         $aPlace = array('class' => 'boundary', 'type' => 'administrative',
45                    'rank_address' => '10');
46         $this->assertEquals('State District', ClassTypes\getLabel($aPlace));
47
48         $aPlace = array('class' => 'boundary', 'type' => 'administrative');
49         $this->assertEquals('Administrative', ClassTypes\getLabel($aPlace));
50
51         $aPlace = array('class' => 'amenity', 'type' => 'prison');
52         $this->assertEquals('Prison', ClassTypes\getLabel($aPlace));
53
54         $aPlace = array('class' => 'amenity', 'type' => 'foobar');
55         $this->assertNull(ClassTypes\getLabel($aPlace));
56     }
57
58     public function testGetBoundaryLabel()
59     {
60         $this->assertEquals('City', ClassTypes\getBoundaryLabel(8, null));
61         $this->assertEquals('Administrative', ClassTypes\getBoundaryLabel(18, null));
62         $this->assertEquals('None', ClassTypes\getBoundaryLabel(18, null, 'None'));
63         $this->assertEquals('State', ClassTypes\getBoundaryLabel(4, 'de', 'None'));
64         $this->assertEquals('County', ClassTypes\getBoundaryLabel(4, 'se', 'None'));
65         $this->assertEquals('Municipality', ClassTypes\getBoundaryLabel(7, 'se', 'None'));
66     }
67
68     public function testGetDefRadius()
69     {
70         $aResult = array('class' => '', 'type' => '');
71         $this->assertEquals(0.00005, ClassTypes\getDefRadius($aResult));
72
73         $aResult = array('class' => 'place', 'type' => 'country');
74         $this->assertEquals(7, ClassTypes\getDefRadius($aResult));
75     }
76
77     public function testGetIcon()
78     {
79         $aResult = array('class' => '', 'type' => '');
80         $this->assertNull(ClassTypes\getIcon($aResult));
81
82         $aResult = array('class' => 'place', 'type' => 'airport');
83         $this->assertEquals('transport_airport2', ClassTypes\getIcon($aResult));
84     }
85
86     public function testGetImportance()
87     {
88         $aResult = array('class' => '', 'type' => '');
89         $this->assertNull(ClassTypes\getImportance($aResult));
90
91         $aResult = array('class' => 'place', 'type' => 'airport');
92         $this->assertGreaterThan(0, ClassTypes\getImportance($aResult));
93     }
94 }