def test4_resolve(self): r = redis.Redis(self.redisHost, self.redisPort, self.redisDB) #resolve by coords loc = City.getByLatLon(34.05223, -118.24368, r) self.assertTrue(loc is not None) self.assertTrue(loc.country == 'United States') self.assertTrue(loc.state == 'CA' or loc.state == 'California') #resolve by ip ip = '4.3.68.1' loc = IPRange.getCity(ip, r) self.assertTrue(loc is not None) self.assertTrue(loc.country == 'United States') self.assertTrue(loc.state == 'CA' or loc.state == 'California') #resolve zip by lat,lon loc = ZIPCode.getByLatLon(34.0452, -118.284, r) self.assertTrue(loc is not None) self.assertTrue(loc.name == '90006') self.assertTrue(loc.country == 'United States') self.assertTrue(loc.state == 'CA' or loc.state == 'California') #resolve zip bu ip loc = IPRange.getZIP(ip, r) self.assertTrue(loc is not None) self.assertTrue(loc.name == '90001') self.assertTrue(loc.country == 'United States') self.assertTrue(loc.state == 'CA' or loc.state == 'California')
def benchResolveCoords(num): coords = [(-3.03333,53.47778), (40.7226,-74.66544), (31.78199,35.2196), (0,0),(45,45)] r = redis.Redis() ncoords = len(coords) for i in xrange(num): lat,lon = coords[i % ncoords] loc = City.getByLatLon(lat,lon, r) return num
def benchResolveCoords(num): coords = [(-3.03333, 53.47778), (40.7226, -74.66544), (31.78199, 35.2196), (0, 0), (45, 45)] r = redis.Redis() ncoords = len(coords) for i in xrange(num): lat, lon = coords[i % ncoords] loc = City.getByLatLon(lat, lon, r) return num
def resolveCoords(lat, lon): global redis_host, redis_port, redis_db r = redis.Redis(host=redis_host, port=redis_port, db=redis_db) loc = City.getByLatLon(lat, lon, r) print loc
def resolveCoords(lat, lon): global redis_host, redis_port, redis_db r = redis.Redis(host=redis_host, port=redis_port, db=redis_db) loc = City.getByLatLon(lat, lon, r)