-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps.py
102 lines (75 loc) · 2.27 KB
/
maps.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python
# coding: utf-8
#pip install folium
#pip install clipboard
import random
import folium
import numpy as np
#create rent stations position of N numbers
def rent_loc_data(N):
rent_loc = np.array(
[
np.random.uniform(low=55.85732210734671, high=55.86637739884676, size=N),
np.random.uniform(low=-4.263585011923924, high=-4.247555719230547, size=N),
]
).T
return rent_loc,N
#create bikes position of N numbers
def bike_loc_data(N):
bike_loc = np.array(
[
np.random.uniform(low=55.85732210734671, high=55.86637739884676, size=N),
np.random.uniform(low=-4.263585011923924, high=-4.247555719230547, size=N),
]
).T
return bike_loc,N
#draw the map for rent station
def drawMapCenter(x,y):
folium_map = folium.Map(
location=[x, y],
zoom_start=15,
attr='default'
)
return folium_map
#draw the map for bikes
def drawMapCenter_operator(x,y):
folium_map1 = folium.Map(
location=[x, y],
zoom_start=15,
attr='default'
)
return folium_map1
#draw the map for rent station data form:[[x,y],[x1,y1]]
def drawMapPoints(n,points, folium_map):
cnt = 0
i = 1
popups = [i for i in range(n + 1)]
for point in points:
#print(point)
if cnt < 30:
xx = point[0]
yy = point[1]
for i in popups:
folium.Marker([xx, yy],popup=popups[i]).add_to(folium_map)
cnt += 1
#print(folium_map)
return folium_map
#draw the map for bikes position
def drawMapBikePoints(bike_points, folium_map1):
for bike_point in bike_points:
#print(point)
xx = bike_point[0]
yy = bike_point[1]
folium.Marker([xx, yy]).add_to(folium_map1)
print(folium_map1)
return folium_map1
#draw the user position
def draw_user(folium_map):
x = random.uniform(55.85732210734671, 55.86637739884676)
y = random.uniform(-4.263585011923924,-4.247555719230547)
folium.Marker([x,y],icon=folium.Icon(color='red', icon='info-sign')).add_to(folium_map)
return folium_map
# In[3]:
#folium_map1 = drawMapCenter_operator(55.86275307588229, -4.254684920519296)
#bike_points,n = bike_loc_data(100)
#drawMapBikePoints(bike_points,folium_map1)