Find valuable gems 💎 in your tracked sport 🚴 activity!
Project description
sportgems
Sportgems finds valuable gems 💎 in your tracked sport 🚴 activity!
What is it?
Sportgems is a tiny library which lets you efficiently parse your activity data. It will search and find your fastest sections. It will determine the start, end and speed of whatever fastest sections you are interested, e.g. 1km, 2km and 10km. This repo is a tiny rust reincarnation of the C++ implementation of the sportgems algorithm.
Sportgems is (or will be) used in workoutizer to find your fastest 1km (and other 💎) in all your activities and ultimately visualize it.
Get Started
Sportgems is bundled in a python package using pyo3. Simply install it with pip:
pip install sportgems
In order to search for gems 💎 in your activity, you need to pass the coordinates as
list of tuples of floats (lat, lon)
and the timestamps as a list of floats as
seconds since the Unix epoch:
from sportgems import find_gems
fastest_1km = 1000 # in meter
coordinates = [(48.123, 9.35), (48.123, 9.36), (48.123, 9.37), (48.123, 9.38)]
times = [1608228953.8, 1608228954.8, 1608228955.8, 1608228956.8]
result = find_gems(fastest_1km, times, coordinates)
The result will be a tuple consisting of (int, int, float)
where
- the first element is the start index
- the second element is the end index of the fastest section
- the last element is the found velocity In the above example this would lead to
found_section = result[0]
start_index = result[1]
end_index = result[2]
velocity = result[3]
print(f"Found fastest {int(fastest_1km / 1000)}km: ")
print(f"Fastest section ranges from index {start_index} to {end_index} with a velocity of {velocity}m/s.")
which prints
The fastest 1km is from index 1 to 2 with a velocity of 743.0908195788583m/s.
How does it work?
The following diagram illustrates how the core algorithm (implemented in gem_finder.cpp
) works:
Running the tests
In order to run the rust unit tests simply run
cargo test
To run the python test, which obviously also covers the import of the python package you first need to install the requirements
pip install -r requirements.txt
and subsequently run the tests
pytest tests/
Contributing
Contributions are welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for sportgems-0.2.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0f19f90f38a483cf8226e8f402a0816f4531a3c764400aa35266b0485bdd586 |
|
MD5 | b326d4a101d798f4f5e23c58c45db645 |
|
BLAKE2b-256 | 83d990adc86b7c6e4a0d1a7dd60074b7328603f150bad2af326309f796b5648d |
Hashes for sportgems-0.2.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c43054dfc7cc34f1a868c25466c7c3c03cc9138dd404485945434e47696ab898 |
|
MD5 | 2948f48297cc9e0aae0d7d707fc7b9c2 |
|
BLAKE2b-256 | 2803d907a5d2ceba6b6f733176c5d61269f4a04ad69e062a669859f18ead6019 |
Hashes for sportgems-0.2.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 667b41e841ab11e398679fa95905493c6721e4f0f5df03649dcca2a777cbe0f9 |
|
MD5 | 48f285b67d74fa8791730acd018c2da3 |
|
BLAKE2b-256 | 4e1e1c623d582341f868ae7511bf0b0d47d1a08f03eb9c10dd18a2c7fb754eb3 |
Hashes for sportgems-0.2.2-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80b9ae621cc9a6e5279d123b39dda2dcfc61c887226a72b47f123e9a56fc9b5c |
|
MD5 | 74fa8a6ea045dca1f7b050e1781e5761 |
|
BLAKE2b-256 | 0856b686dc4fd3a86bea3d131db471ddf66a2c4f9d69ea58ff318c935103bd75 |
Hashes for sportgems-0.2.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6119af500a8dcb22d7ee21e707a450d61944f791616cade8e77579172cfe218e |
|
MD5 | a016a17f115686b343989f77329a9a2e |
|
BLAKE2b-256 | 0441d919664bc0995b3caa4ca637717d24fc84d1f5091f1ba3d69ba8ef16f4e4 |
Hashes for sportgems-0.2.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de33b45e4600589f8024b79ebf902d60792a9bbc4c3b804aab02bc9cf926a637 |
|
MD5 | 8d00ecfaf60234bdce1ea8c4521a4676 |
|
BLAKE2b-256 | 344ee3f5a4e6614b890038359765d85e3fa8d052cb9c1c10d4b1e8269910f15e |
Hashes for sportgems-0.2.2-cp38-cp38-linux_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e121b270b8b635cd4470befbf02bac90ef6d23ec222fd6e21d34a2c1bcfb621a |
|
MD5 | 018b2057eae0a7f8cfcc1573a52a6099 |
|
BLAKE2b-256 | 2802c71f9c95a2bdb17dfdfe9e2f36d7126393c1e3c8963a7df52e562a59df70 |
Hashes for sportgems-0.2.2-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db6ae327803471b7942a87fe1ab9ad4dd76571b35c534eaf83709055f33be61f |
|
MD5 | 4708a60618fd2bf276bdcef6fbe71f08 |
|
BLAKE2b-256 | 938a64770d0f28ab23413744d7a5633143e0feacfcd0bf31537eff2b581d2cbf |
Hashes for sportgems-0.2.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d4351c675a973cfb9183834011fe233257e31904653b0a27dfe082f5b07633f |
|
MD5 | f0347a9b91688822d4c4565b379bb161 |
|
BLAKE2b-256 | f99c486349ef2b31cf35f4c50dd94bda6007be685c5198063487deabd0db691d |
Hashes for sportgems-0.2.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 038479c928ad3c6087ef3540cc8b25516553ab3429c2faff35ec8586ceb11b48 |
|
MD5 | f405718afb000c322425947a15efdb95 |
|
BLAKE2b-256 | 07dccce1dbc0404fc08c5511b53189d24c7e80772713a67c0758e4d8abb70ae1 |
Hashes for sportgems-0.2.2-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11f670c3b0a1b5c606cb5eab11e0f1e84de88f31c9696ef0a2efdf854a57b73e |
|
MD5 | 56b58ed47837b8ed1cd6e8ee6f4b7857 |
|
BLAKE2b-256 | 0dbf80626fa1d2eb2e061be3270687ad7198032f23e20b8b58ebb02525074465 |
Hashes for sportgems-0.2.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e42edb1271aaa8cabb50fcd1bdbabb584279db669cc6d27f9c8b48764f3df68 |
|
MD5 | 4c64467ebba0530c03ea8631ab3b0c70 |
|
BLAKE2b-256 | e08911490643726575ab954f3567cf651081e1aff56294ec6e950b18cb0de9ff |
Hashes for sportgems-0.2.2-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b89fc94851879a8d2e4a32b81a409a4ef0406f0abb96fbb3b60d6b0dd5fde58 |
|
MD5 | a625d9d00e3b217389b161c5375b7a11 |
|
BLAKE2b-256 | ad5963e26b518080a6ecd6c4536efce868d32587023117ae0a7b0d06447c7d51 |
Hashes for sportgems-0.2.2-cp36-cp36m-linux_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4135a6363ab6b710fbc68fea3eec497c198e9392a7d673bdf999c62f8ec345b6 |
|
MD5 | bc7670b96808fb8d4bd68a69c940cfd4 |
|
BLAKE2b-256 | 99d1f77cfb8897815b8f8007567b5f65b22b3cb81d08044a575469411ef74c22 |