MCPcopy Create free account
hub / github.com/RocketMap/RocketMap / api_login

Function api_login

contrib/fake-pgo-api.py:113–162  ·  view source on GitHub ↗
(lat, lng, r)

Source from the content-addressed store, hash-verified

111
112@app.route('/login/<lat>/<lng>/<r>')
113def api_login(lat, lng, r):
114 global forts
115
116 if len(forts):
117 # already generated
118 return jsonify(forts)
119
120 # coerce types
121 r = int(r) # radius in meters
122 lat = float(lat)
123 lng = float(lng)
124
125 forts = []
126 area = 3.14 * (r * r)
127
128 # One gym every N sq.m
129 gymCount = int(math.ceil(area / 25000))
130
131 # One pks every N sq.m
132 pksCount = int(math.ceil(area / 15000))
133
134 # Gyms
135 for i in range(gymCount):
136 coords = getRandomPoint(location=(lat, lng), maxMeters=r)
137 forts.append({
138 'enabled': True,
139 'guard_pokemon_id': randint(1, 140),
140 'gym_points': randint(1, 30000),
141 'id': 'gym-{}'.format(i),
142 'is_in_battle': not getrandbits(1),
143 'last_modified_timestamp_ms': int((time() - 10) * 1000),
144 'latitude': coords[0],
145 'longitude': coords[1],
146 'owned_by_team': randint(0, 3)
147 })
148
149 # Pokestops
150 for i in range(pksCount):
151 coords = getRandomPoint(location=(lat, lng), maxMeters=r)
152 forts.append({
153 'enabled': True,
154 'id': 'pks-{}'.format(i),
155 'last_modified_timestamp_ms': int((time() - 10) * 1000),
156 'latitude': coords[0],
157 'longitude': coords[1],
158 'type': 1
159 })
160
161 log.info('Login for location %f,%f generated %d gyms, %d pokestop', lat, lng, gymCount, pksCount)
162 return jsonify(forts)
163
164
165@app.route('/scan/<lat>/<lng>')

Callers

nothing calls this directly

Calls 2

getRandomPointFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected