-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasscountTest.py
54 lines (41 loc) · 1.35 KB
/
passcountTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pygeohash as pgh
import random
import math
# Initialize variables for the previous Geohash value and its count
prev_geohash = None
prev_count = 0
lat, lon = 0, 0
# Define the range of latitudes and longitudes
min_lat, max_lat = -37.91451, -37.91450
min_lon, max_lon = 145.12731, 145.12730
# Initialize an empty hash table to keep track of duplicate geohashes
duplicate_counts = {}
def get_next_coordinate():
# Generate a random latitude and longitude
lat = round(random.uniform(min_lat, max_lat),6)
lon = round(random.uniform(min_lon, max_lon),6)
return lat, lon
lat, lon = get_next_coordinate()
# Process incoming latitude and longitude coordinates
#while True:
for i in range (10):
if (i%3) == 0:
#print('repeated {}'.format(pgh.encode(lat, lon)))
pass
else:
lat, lon = get_next_coordinate()
#print('{}.{}'.format(lat, lon))
print('geohash {}'.format(pgh.encode(lat, lon)))
geohash_val = pgh.encode(lat, lon, precision=12)
if geohash_val != prev_geohash:
if geohash_val in duplicate_counts:
duplicate_counts[geohash_val] += 1
else:
duplicate_counts[geohash_val] = 1
else:
if geohash_val in duplicate_counts:
pass
else:
duplicate_counts[geohash_val] = 1
prev_geohash = geohash_val
print(duplicate_counts)