Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 1 addition & 129 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,129 +1 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
debugging.py
3 changes: 0 additions & 3 deletions .vs/ProjectSettings.json

This file was deleted.

1 change: 0 additions & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"ExpandedNodes": [
""
],
"SelectedNode": "\\C:\\Users\\matht\\Source\\Repos\\python-geofs",
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file added .vs/pygeofsapi/v17/.wsuo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .vs/python-geofs/v17/.wsuo
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
129 changes: 78 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,89 @@
# python-geofs
This package allows the use of an abstraction layer for the geoFS api.
This package is an abstraction layer for the GeoFS API, allowing for Python 3+ integration.

## Quick Setup
1. Install the package with ```pip install python-geofs```
2. Create a python file and add ```import geofs```
3. Your good to go.
## Quick Install
1. Install the package via pip with ```pip install python-geofs``` in the terminal.
2. Create a Python (v3.0+) file and add ```import geofs```
3. Utilize below guide for use instructions.

## Using the package
GeoFS has two different APIs.
One of them is used in game, and the other is for the map.
### Multiplayer API
```from geofs import multiplayerAPI```

Before you use the API you first have to give your account ID and session ID. (More on that later)

```myAPI = multiplayerAPI(sessionID, accountID)```

Next, you need to make a handshake with the server.

```myAPI.handshake()```

Finally, you are setup and can use the API freely.
multiplayerAPI currently allows you to send a recieve messages to the GeoFS chat.

```myAPI.sendMsg(msg)``` Sends a message to GeoFS chat.

```myAPI.getMessages(msg)``` allows you to pull the most recent messages from the server.
It will only pull messages that occured, since the last time you used this command.

### Map API
```from geofs import mapAPI```

This API is used for pulling user data from the server.

First initialize the class:

```myAPI = mapAPI()```

Now you can pull users.

```userData = myAPI.getUsers()```

GeoFS has two different backend APIs, one which powers the Map, and presents the basic information of every user (callsign, location, etc), called the MapAPI, and the MultiplayerAPI, which allows you to spawn in as a user, send and receive chat messages, and more (coming soon).

### MapAPI
You utilize the MapAPI to get basic information on every users. The following is a list of all data presented by the API for usage:
**1.** Location (latitude and longitude)
**2.** Altitude
**3.** Vertical Speed
**4.** Airspeed
**5.** User Info (callsign & GeoFS internal identifier)
**6.** Aircraft Type

To begin utilizing the MapAPI, you must initialize the ``MapAPI`` class. You may then utilize the ``getUsers()`` function to get a list of users.

#### ``MapAPI`` Class
The ``MapAPI`` class does not take in any variables.
##### Example
```python
from geofs import MapAPI
api = MapAPI()
```
With the API Class defined, you can then utilize any of the below functions & variables.

##### Functions List
``getUsers(foos:bool/NoneType)``: Returns a list of users in the form of a list of ``Player`` classes. Pass in ``False`` to ``foos`` to have no foos, ``True`` to have only foos, and ``None`` to be indescriminate of type.
``returnResponseList(reset:bool)``: Returns a list of the previous responses (if reset is ``True``, then clear the response list).
``disableResponseList()``: Disables the saving of previous responses for use in ``returnResponseList``. Do note that the list is on by default.
``enableResponseList()``: Enables the saving of previosu responses for use in ``returnResponseList``. Do note that the list is on by default.
``getUser(acid:int)``: (Coming in next version), will provide a ``Player`` class for the user who's acid is provided, if found.
##### Variables List
The ``MapAPI`` Class has no externally used variables.

#### ``Player`` Class
The ``Player`` class is an internally initialized class which provides all information about one specific player.
##### Functions List
``findUser()``: (Coming in next version), will provide a circularly initialized ``Player`` class with updated information on the player.
##### Variables List
``Player.airspeed``: (``int``) Player's airspeed in knots.
``Player.userInfo``: (``dict``) Player's callsign and internal ID (acid).
``Player.coordinates``: (``tuple``) Player's latitude [0] and longitude [1].
``Player.altitude``: (``int`` or ``float``) Player's altitude in feet (type ``float`` will be a result of conversion from meters, which GeoFS uses internally, to feet, which is offered by this module).
``Player.verticalSpeed``: (``int`` or ``float``) Player's vertical speed in feet (type ``float`` will be a result of conversion from meters, which GeoFS uses internally, to feet, which is offered by this module).
``Player.aircraft``: (``dict``) Player's aircraft type and that aircraft's GeoFS Internal ID.
``Player.grounded``: (``bool``) Coming in next update, tells if a player is grounded or not.

### MapAPI Example
The below example gets a list of all non-foo users, and prints all of their callsigns followed by their altitudes
#### Code
```python
from geofs import MapAPI

data = MapAPI().getUsers(foos=False)
for player in data:
print (player.userInfo['callsign']+': '+str(player.altitude))
```
#### Output
```BVW-00: 1971.08
Venom583: 26.37
davidpietro: 23414.06
WN-1529: 17493.09
SomebodyaddtheF35: 526.4
NICARAGUAN-2[FAN][ACIR][626]: 34000.2
fiumba: 2005.44
DXA212: 69.0
TCHALA[M4AF][FIGHTER][AIRSHOW]: 156.2
Eagle-7[18][3UM][USAF]: 4582.4
N999UA: 1155.33
BJ-120: 4425.64
626076: 474.72
SubtoBrianisawesome2927: 8.19
```
#### Output
## Getting Session and Account IDs
### Account IDs
The account ID identifies the account that you are using to connect to the server.
This is found on the account page on the website: https://www.geo-fs.com/pages/account.php?action=edit

This is refered to as your "user ID" on the website.

### Session ID
The session ID is stored on your computer in the cookies.
1. Sign into your account and log into the server.
2. Open Chrome Console with ctrl+shift+j
3. Paste this code into the console, and it will return the session ID
```
const cookies = document.cookie.split(';');
const sessionIdCookie = cookies.find(cookie => cookie.trim().startsWith('PHPSESSID='));
const sessionId = sessionIdCookie ? sessionIdCookie.split('=')[1] : null;
console.log(sessionId);
```
4. If you are having trouble connecting to the server, it may be that your session ID has expired, so be sure to check that.
## MultiplayerAPI
The MultiplayerAPI exists in the code, but is currently being redone.
Loading