-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeatMap.py
53 lines (43 loc) · 1.38 KB
/
HeatMap.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
53
import ssl
from pygame import *
import os
from pymongo import MongoClient
# Setting MongoDB
password = os.getenv("mongoPass")
client = MongoClient("mongodb+srv://Armaan:" + password + "@cluster-1-dnqxb.mongodb.net/test?retryWrites=true&w=majority", ssl_cert_reqs=ssl.CERT_NONE)
db = client.Twitter
hashtagCollection = db.Hashtags
# Getting coordinates
coordinateDict = hashtagCollection.find_one({})
coordinates = []
coordinates2 = []
coordinates3 = []
num = 1
while True:
try:
line = coordinateDict[str(num)]
firstBracket = line.find('[')
lastBracket = line.find(']')
coordinates.append(line[firstBracket+1:lastBracket])
num += 1
except:
break
for coord in coordinates:
coordinates2.append(list(map(float,coord.split(", "))))
for coord in coordinates2:
coordinates3.append((2*(coord[0]+180),2*(-1*(coord[1])+90)))
os.environ['SDL_VIDEO_CENTERED'] = '1' # Centering the screen
init() # Starting up pygame
size = width, height = 720, 360
screen = display.set_mode(size)
map = transform.scale(image.load("map.png"),(720,360))
logo = transform.scale(image.load("logo.png"),(20,20))
running = True
while running:
for evnt in event.get():
if evnt.type == QUIT:
running = False
screen.blit(map,(0,0))
for coord in coordinates3:
screen.blit(logo,(int(coord[0]-20),int(coord[1])))
display.flip()