I’ve been doing a bit of experimenting with FIT files, and C and ogr2ogr and… I’ve decided to use Python for my latest GIS project.
I was able to extract some (but not all) of the data I need from the fit file using GPSBabel and, in an unwieldy process, send it as a CSV to PostGIS via ogr2ogr, and do the final processing within the database. What GPSBabel did not get did not get me was the lap info — I’d need to write some kind of program to extract it myself , and any real processing I’d need to do — aggregating my track points into a line for example, or timestamps and GPS positions into average speed — seemed more suitable for doing in a program anyway.
Meanwhile, I had downloaded the ANT/FIT SDK, and it contained a C library as well as usage examples. These were all written to be a part of some Windows-based IDE’s build process, but they were easy enough to put into Makefile format and get running and, by modifying and re-writing the examples, I managed to extract all the necessary data from the FIT file. The next steps were to process and aggregate the data into summary form, and (using OGR libraries) to add the summarized activity data as a record into my database.
I did some Googling for advice on how to go about this, but I got few hits for doing it in C and many for Python: basically there’s a library for reading FIT files, and multiple libraries each for processing geometry data and connecting to PostGIS, and the code for my first attempt came to about two dozen lines. It feels slow, but I noticed that my C program also took some time to read and process the points in the file — the Python version isn’t really slower in comparison, and writing the code was soooo easy that using Python was worth it for that reason alone.
I need to finish my little piece of code, then I can use it on my machine as a standalone program. The next step after that is to find out how to use it from a website — there are several ways, and they all seem easy enough — and build a front end to access my activity data. Knock on wood, but the worst of the learning curve is over.