def test_single(self): geotrie = GeoTrie(precision=6) point = (51.528642, -0.101599) geotrie.add(point, data='foo') assert geotrie.trie.has('gcpvjs') assert geotrie.trie.values('gcpvjs') == [ ((51.528642, -0.101599), 'foo') ]
def test_search(self, precision, search): points, expected_hits = search geotrie = GeoTrie(precision=precision) for p in points: geotrie.add(p) center = (51.513284, -0.136539) hits = geotrie.radius_search(center, 500) assert len(hits) == len(expected_hits) hits = map(operator.itemgetter(0), hits) for i in expected_hits: assert points[i] in hits
def test_multiple(self): geotrie = GeoTrie(precision=6) point = (51.528642, -0.101599) geotrie.add(point) assert geotrie.trie.has('gcpvjs') assert geotrie.trie.values('gcpvjs') == [ ((51.528642, -0.101599), None) ] point = (51.7505017, -1.3177993) geotrie.add(point) assert geotrie.trie.has('gcpn6h') assert geotrie.trie.values('gcpn6h') == [ ((51.7505017, -1.3177993), None) ]