-
Notifications
You must be signed in to change notification settings - Fork 21
Windows Setup Instructions
Note: Many thanks to Matteng0 for putting this together!
-
First things first install PostgreSql from this link. Install version 9.5.3 selecting either Win x86-32 or Win x86-64 depending if you are 32 bit or 64 bit windows.
-
Go to the location where you installed PostgreSql and goto the data directory (default is
C:\\Program Files\\PostgreSQL\\9.5\\data
) From there right clickpg_hba.conf
and select “Open With...” then select notepad. At the bottom of the file add:host all all [YOUR IP ADDRESS]/32 md5
-
Save the file.
-
The version of PostgreSql allows us to add to the package easily via an inbuilt application stack builder. Go to “All Programs” select PostgreSql and select “Application Stack Builder” then select your database from the drop down menu. Click on the expand button beside “Spatial Extensions” and select the most appropriate PostGIS bundle for your operation system (32bit/64bit)
-
Next open “PgAdmin III” from “All Programs”. On “Login Roles” right click and select “New Login Role”. In “Role name” type “pokemon_go_role” then select “Role privileges” along the top. Make sure all available check boxes are selected on this time then select “OK”.
-
On “Databases” right click and select “New Database…”. In name type “pokemon_go” and select the owner as “pokemon_go_role”. Go to the definition tab and for "Encoding" select UTF8.
-
Right click the newly created database and select “Restore…” Download the pokemon_go_db_backup.tar file from the Pokelyzer Github repo.
-
Now for the final check go through the pokemon_go database tree to check that there are 5 tables (pokemon_go > Schemas > public > Tables).
-
That’s the database setup.
Pokemon Go Map installation – Note this has been taken from here
-
Download Python here and install. Then download pip (right click that link and choose "Save Link As"), and double click the file you downloaded, assuming you installed Python correctly.
-
Download NodeJS here and install.
-
Create a Pokemon Club account on their official website to be used by the program to search for Pokemon. This generally shouldn't be the same as your main Trainer account you personally use. As of 7/21/2016 this page is unavailable most of the time, refresh the page every 5-10 minutes and it should allow signups eventually. You can also use a Google account. For both services, you can login without ever connecting to the actual game.
-
Then, download one of the following branches below:
-
Download master (Stable builds)
-
Download dev branch (Active development)
The dev branch will have latest features from the development team, however it may be unstable at some times.
-
Extract this zip file to any location.
-
There is a one-click setup for Windows. After you've installed Python, go into the Easy Setup folder and run setup.bat. This should install pip and the dependencies for you, and put your Google API key into the right place (follow this wiki entry to obtain a API key)
-
From where ever you have extracted the Pokemon Go Map open a command prompt (usually by selecting File > Open Command Prompt)
-
To start the server, run the following command: python runserver.py -u [USERNAME] -p [PASSWORD] -st 10 -k [Google Maps API key] -l "[LOCATION]"
Or for Google account: python runserver.py -a google -u [USERNAME] -p [PASSWORD] -st 10 -k [Google Maps API key] -l "[LOCATION]"
Replacing [USERNAME]
and [PASSWORD]
with the Pokemon Club credentials you created previously, and [LOCATION] with any location, for example Washington, D.C or latitude and longitude coordinates, such as 38.9072, 77.0369
.
-
Additionally, you can change the 10 after -st to any number. This number indicates the number of steps away from your location it should look, higher numbers being farther.
-
You can now access the map by opening your browser to http://localhost:5000
Editing the Pokemon Go Map files to add to the Pokelyzer Database
In the repository (where Windows users have extracted the Pokemon Go Map files, go into the pogom directory and find the utils.py file.
In the get_args()
function, after all the add_argument lines, add two more for --pokel-pass
and --pokel-era
as shown here:
def get_args():
[A bunch of stuff]
parser.add_argument('--pokel-pass', help='Password for Pokelizer database')
parser.add_argument('--pokel-era', help='Current Migration Era',type=int, default=2)
This will allow us to pass in our database password when we start PokemonGo-Map so that we don't need to store a record of it. It will also label all the data with the current "Era", which is a period of time between major Pokemon Go changes, like the rearranging of all the nests that happened on July 29th.
Next, go to the file customLog.py in the pogom directory. At the top, add a line to import the psycopg2 and random libraries:
from .utils import get_pokemon_name
from pogom.utils import get_args
from datetime import datetime
import psycopg2
import random
Back in the customLog.py file, add the following lines after args = get_args(). It will create the cursor used to access the database:
conn = psycopg2.connect(dbname="pokemon_go", user="pokemon_go_role", password=args.pokel_pass, host="127.0.0.1")
conn.autocommit = True
cursor = conn.cursor()
And add the following function at the bottom of the same file. This function transforms the data from each discovered Pokemon and stores it in the database. The database itself is equipped with triggers that automatically update all of the remaining columns not listed near the bottom of this function.
def logPokemonDb(p):
pokemon_id = int(p['pokemon_data']['pokemon_id'])
pokemon_name = get_pokemon_name(str(pokemon_id)).lower()
last_modified_time = int(p['last_modified_timestamp_ms'])
time_until_hidden_ms = int(p['time_till_hidden_ms'])
hidden_time_unix_s = int((p['last_modified_timestamp_ms'] + p['time_till_hidden_ms']) / 1000.0)
hidden_time_utc = datetime.utcfromtimestamp(hidden_time_unix_s)
encounter_id = str(p['encounter_id'])
spawnpoint_id = str(p['spawnpoint_id'])
longitude = float(p['longitude'])
latitude = float(p['latitude'])
longitude_jittered = longitude + (random.gauss(0, 0.3) - 0.15) * 0.0005
latitude_jittered = latitude + (random.gauss(0, 0.3) - 0.15) * 0.0005
pokemon_go_era = args.pokel_era
query = "INSERT INTO spotted_pokemon (name, encounter_id, last_modified_time, time_until_hidden_ms, hidden_time_unix_s, hidden_time_utc, spawnpoint_id, longitude, latitude, pokemon_id, longitude_jittered, latitude_jittered, pokemon_go_era) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) ON CONFLICT (encounter_id) DO UPDATE SET last_modified_time = EXCLUDED.last_modified_time, time_until_hidden_ms = EXCLUDED.time_until_hidden_ms, hidden_time_unix_s = EXCLUDED.hidden_time_unix_s, hidden_time_utc = EXCLUDED.hidden_time_utc;"
data = (pokemon_name, encounter_id, last_modified_time, time_until_hidden_ms, hidden_time_unix_s, hidden_time_utc, spawnpoint_id, longitude, latitude, pokemon_id, longitude_jittered, latitude_jittered, pokemon_go_era)
cursor.execute(query, data)
Open the models.py file in the pogom folder, and modify the line near the top that imports .customLog to import our new function:
from .customLog import printPokemon, logPokemonDb
Finally, find the parse_map()
function in models.py, and
put logPokemonDb(p)
just under where it says printPokemon(...)
in the
cell loop. This will call our function any time a Pokemon is found.
def parse_map(map_dict, iteration_num, step, step_location):
pokemons = {}
pokestops = {}
gyms = {}
scanned = {}
cells = map_dict['responses']['GET_MAP_OBJECTS']['map_cells']
for cell in cells:
for p in cell.get('wild_pokemons', []):
d_t = datetime.utcfromtimestamp(
(p['last_modified_timestamp_ms'] +
p['time_till_hidden_ms']) / 1000.0)
printPokemon(p['pokemon_data']['pokemon_id'],p['latitude'],p['longitude'],d_t)
logPokemonDb(p)
pokemons[p['encounter_id']] = {
'encounter_id': b64encode(str(p['encounter_id'])),
'spawnpoint_id': p['spawnpoint_id'],
'pokemon_id': p['pokemon_data']['pokemon_id'],
'latitude': p['latitude'],
'longitude': p['longitude'],
'disappear_time': d_t
}
[More code...]
Now if you save everything and run the PokemonGo-Map server with the --pokel-pass parameter, it should start logging everything to your database!
python runserver.py -a ptc -u [YOUR USERNAME] -p [YOUR PASS] -l`"45.95845 -66.662327" -st 25 -H 0.0.0.0 --google-maps-key [YOUR GOOGLE MAPS KEY] --pokel-pass "[YOUR DB PASSWORD]"`=
If you go back into pgAdmin, right click the spotted_pokemon
table and view the top 100 rows of data, you should see it being populated!
- Getting Started
- Ubuntu Setup
- Windows Setup
- Apple OS X Setup
- Patches and Fixes
- Applying Patches
- Fixing Timezones
- Advanced Configuration
- Multiple Time Zone Support
- Using with Tableau
- Mapping
- Dimensions and Online Hosting
- Using with Microsoft's Power BI
- Basic Charting and Mapping