4 import random_points_bbox
8 #first get some random points in the bbox
9 aPoints = random_points_bbox.getPoints(num, -100.815, 46.789, -100.717, 46.84)
11 sReverseUrl = "http://localhost/nominatim_old/reverse.php?format=json&lat=%f&lon=%f"
14 response = url.urlopen(sReverseUrl % (point[1], point[0]))
15 aAddresses.append(json.load(response)['address'])
17 # now we have all the addresses of the points in a list
18 # lets forward geocode this list
19 sOldUrl = "http://localhost/nominatim_old/search.php?format=json&city=%s&street=%s&addressdetails=1"
20 sLineUrl = "http://localhost/nominatim/search.php?format=json&city=%s&street=%s&addressdetails=1"
21 start_old = time.time()
22 for address in aAddresses:
23 if 'house_number' in address and 'road' in address:
24 responseOld = url.urlopen(sOldUrl % (address['city'], address['house_number']+' '+address['road']))
25 #dataOld = json.load(responseOld)
26 #print dataOld[0]['display_name']
27 elif 'road' in address:
28 responseOld = url.urlopen(sOldUrl % (address['city'], address['road']))
29 #dataOld = json.load(responseOld)
30 #print dataOld[0]['display_name']
32 for address in aAddresses:
33 if 'house_number' in address and 'road' in address:
34 responseLine = url.urlopen(sLineUrl % (address['city'], address['house_number']+' '+address['road']))
35 elif 'road' in address:
36 responseLine = url.urlopen(sLineUrl % (address['city'], address['road']))
37 end_line = time.time()
39 print "Seconds old search for %d elements: %f" % (num,end_old-start_old)
40 print "Seconds line search for %d elements: %f" % (num,end_line-end_old)
44 # 100 points: old: 7.11 sec, new: 7.47 sec
45 # 1000 points: old: 65.69 sec, new: 66.96 sec