]> git.openstreetmap.org Git - nominatim.git/blob - mytests/reverse_tiger_functional.py
Implement geocoding and reverse geocoding with tiger interpolation lines instead...
[nominatim.git] / mytests / reverse_tiger_functional.py
1 import numpy as np
2 import urllib2 as url
3 import json as json
4 import random_points_bbox
5
6 def test_compare(strUrl1, strUrl2, iPoints):
7     #define bounding box for test
8     # sw: left-lower corner
9     sw_lng= -100.815
10     sw_lat= 46.789
11     # ne right-top corner
12     ne_lng= -100.717
13     ne_lat= 46.84
14     #first get some random points in the bbox
15     aPoints = random_points_bbox.getPoints(iPoints, -100.815, 46.789, -100.717, 46.84)
16     same = 0
17     differ = 0
18     differ_street=0
19     missing_housenumber_1=0
20     missing_housenumber_2=0
21     for point in aPoints:
22         response = url.urlopen( strUrl1 % (point[1],point[0]))
23         data1 = json.load(response)
24         response = url.urlopen(strUrl2 % (point[1],point[0]))
25         data2 = json.load(response)
26         if data1['address'] == data2['address']:
27             same+=1
28         elif 'road' in data1['address'] and 'road' in data2['address']:
29             differ+=1
30             print 'different: '+str(data1['address'])+' - ' + str(data2['address'])
31             if data1['address']['road'] != data2['address']['road']:
32                 differ_street +=1
33         if 'house_number' not in data1['address']:
34             missing_housenumber_1 +=1
35             print 'missing housenumber in Line: '+str(data1['address'])
36         if 'house_number' not in data2['address']:
37             missing_housenumber_2 +=1
38             print 'missing housenumber in Old: '+str(data2['address'])
39             
40             
41     print 'Number of same values: '+str(same)
42     print 'Number of different values: '+str(differ)
43     print 'Number of different streets: '+str(differ_street)
44     print 'Points without housenumber in Line: '+str(missing_housenumber_1)
45     print 'Points without housenumber in Old: '+str(missing_housenumber_2)
46 strUrlLine = "http://localhost/nominatim/reverse.php?format=json&lat=%f&lon=%f"
47 strUrlOld = "http://localhost/nominatim_old/reverse.php?format=json&lat=%f&lon=%f"
48
49 test_compare(strUrlLine,strUrlOld, 100)