-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
372f42d
commit 189c106
Showing
9 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
__pycache__ | ||
*.kml | ||
*.pyc | ||
footprints.py | ||
strava_*.py | ||
gpxinfo.py | ||
gpxinfo.py | ||
Building Footprints.kml | ||
basemap* | ||
.idea | ||
venv | ||
shadegpx.egg-info | ||
build | ||
dist/ | ||
temp/ | ||
CherryBlossom2019.gpx | ||
get_sun_cherryblossom.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Download GPX from a running-race page in Strava | ||
For example, let's consider the Brooklyn Half. The link to the race and course map is here: | ||
https://www.strava.com/running-races/2018-popular-brooklyn-half | ||
But there is no option to download the GPX from here. If you visit the page and examine the HTML source code, you'll see this: | ||
var runningRaceJson = { | ||
"id": 1669, | ||
"name": "Popular Brooklyn Half", | ||
"distance": 21097.0, | ||
"city": "Brooklyn", | ||
"state": "NY", | ||
"measurement_preference": null, | ||
"url": "2018-popular-brooklyn-half", | ||
"start_date_local": "2018-05-19T07:00:00Z", | ||
"vanity": "2018-popular-brooklyn-half" | ||
}; | ||
This gives us a route ID of 1669. We can use this to download the GPX data. | ||
""" | ||
|
||
import requests | ||
import time | ||
|
||
# Visit https://www.strava.com/settings/api to get all this info | ||
CLIENT_ID = 'SEE LINK ABOVE' | ||
ACCESS_TOKEN = 'SEE LINK ABOVE' | ||
|
||
headers = {'Authorization': 'Bearer {}'.format(ACCESS_TOKEN)} | ||
|
||
########################### | ||
|
||
ROUTE_ID = 1669 | ||
filename = 'brooklynhalf.gpx' | ||
|
||
# save to file | ||
url = 'https://www.strava.com/api/v3/routes/{}/export_gpx'.format(ROUTE_ID) | ||
r = requests.get(url, headers=headers) | ||
with open(filename, 'wb') as fd: | ||
for chunk in r.iter_content(chunk_size=128): | ||
fd.write(chunk) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import io | ||
import os | ||
|
||
from setuptools import setup | ||
|
||
# Package meta-data. | ||
NAME = 'shadegpx' | ||
DESCRIPTION = 'Compute "shade factor" on a runner during a race using GPX data and solar positions.' | ||
URL = 'https://github.com/benmayersohn' | ||
EMAIL = '[email protected]' | ||
AUTHOR = 'Ben Mayersohn' | ||
REQUIRES_PYTHON = '>=3.6.0' | ||
VERSION = None | ||
|
||
# What packages are required for this module to be executed? | ||
REQUIRED = ['matplotlib>=3.0', 'pandas>=0.24', 'scipy>=1.2', 'seaborn>=0.9', 'numpy>=1.16', 'pysolar==0.8', | ||
'pytz>=2018', 'gpxpy>=1.3', 'requests>=2.21'] | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
# Import the README and use it as the long-description. | ||
try: | ||
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: | ||
long_description = '\n' + f.read() | ||
except FileNotFoundError: | ||
long_description = DESCRIPTION | ||
|
||
# Load the package's __version__.py module as a dictionary. | ||
about = {} | ||
if not VERSION: | ||
project_slug = NAME.lower().replace("-", "_").replace(" ", "_") | ||
with open(os.path.join(here, project_slug, '__version__.py')) as f: | ||
exec(f.read(), about) | ||
else: | ||
about['__version__'] = VERSION | ||
|
||
|
||
# Where the magic happens: | ||
setup( | ||
name=NAME, | ||
version=about['__version__'], | ||
description=DESCRIPTION, | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
author=AUTHOR, | ||
author_email=EMAIL, | ||
python_requires=REQUIRES_PYTHON, | ||
url=URL, | ||
py_modules=['shadegpx'], | ||
install_requires=REQUIRED, | ||
include_package_data=True, | ||
license='Freely Distributable', | ||
classifiers=[ | ||
# Trove classifiers | ||
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
'License :: Freely Distributable', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6' | ||
] | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__title__ = 'shadegpx' | ||
__description__ = 'Compute "shade factor" on a runner during a race using GPX data and solar positions.' | ||
__url__ = 'https://www.github.com/benmayersohn' | ||
__version__ = '0.0.1' | ||
__author__ = 'Ben Mayersohn' | ||
__author_email__ = '[email protected]' | ||
__copyright__ = 'Copyright 2019 Ben Mayersohn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters