python - Find out if a GPS waypoint has been passed -
think of several runners on marathon. athletes wearing gps devices. track has no sensors, , need know when each athlete crosses predetermined set of gps coordinates. however, each athlete may cross waypoint @ different lat/long, since track/road might wide enough different parts of track/road used.
what best way determine whether athlete has passed waypoint?
i'm using python, , open using external library. i'm working pre-processed gps data, have latitude , longitude @ each time point (and few other bits , pieces speed , distance travelled).
imho there few ways of solving problem. first 1 came mind this:
from shapely.geometry import linestring line1 = linestring([(i, i) in range(5)]) line2 = zip(range(5)[::-1], range(5)) if line1.crosses(line2): print 'yeah!' add loop , iterate every waypoint-line
other possible options:
- simple math calculation using intersection of 2 strait lines - high school stuff
- import data postgres postgis , use postgis function eg st_crosses (if postgres heavy give spatiallite-sqlite try)
- pyshp, shapely, gdal/geos, geodjango, geoalchemy
- combine of above , write bit more fancy algo creating buffer around 1 line/point , check if "st_contains" gps position checking if later positions off buffer zone(?)
Comments
Post a Comment