No description
Find a file
Ray Miller f09fd9a418 Set a custom user-agent header when fetching CTC Cambridge stops data
This is required because their hosting provider is returning a 503
"service unavailable" when the user agent is Go-http-client.
2024-04-17 17:19:42 +01:00
cmd Improvements to duplicate suppression, cafe stop search, and configurability. 2023-01-19 16:21:32 +00:00
pkg Set a custom user-agent header when fetching CTC Cambridge stops data 2024-04-17 17:19:42 +01:00
scripts Increase the search radius for cafe stops 2021-06-18 11:56:16 +01:00
.git-semver Add git-semver config 2020-04-26 20:20:19 +01:00
.gitattributes Add counties to output (% of ride spent in each county) 2020-10-31 16:17:36 +00:00
.gitignore Add generate file to version control 2020-04-22 15:24:27 +01:00
.gitlab-ci.yml Call the executable exe 2021-04-10 14:22:22 +01:00
go.mod Add gpx-anomalies command 2021-04-10 14:01:23 +01:00
go.sum Add gpx-anomalies command 2021-04-10 14:01:23 +01:00
README.md Add information about refreshment stops to README. 2020-04-22 15:00:33 +01:00

GPX Utils

Utilities for analyzing and indexing GPX routes.

Compiling placenames.bin

This step extracts bounding boxes for populated places from the OS Open Names dataset, which is available for free download: https://www.ordnancesurvey.co.uk/business-government/products/open-map-names

go run ./cmd/save-gob/... opname_csv_gb.zip ./pkg/placenames/placenames.bin

I have included a compiled extract in this repository so you can skip this step.

Binary embedding

We use mule to embed the gob data in the compiled binaries:

go get github.com/wlbr/mule

Make sure the mule command is on your PATH before running go generate.

Compiling

mkdir -p bin
go generate ./...
go build -o bin ./...

Usage

analyze-gpx

To analyze a single GPX track:

./bin/analyze-gpx FILENAME

This will write a JSON summary to STDOUT.

To analyze an entire directory:

./bin/analyze-gpx DIRNAME

This will scan the directory and, for each file with suffix .gpx, will output the analysis to a corresponding file with suffix .json.

serve-rwgps

This will start a small server to analyze RideWithGPS tracks.

./bin/serve-rwgps

It defaults to listening on port 8000, override by setting the LISTEN_ADDR environment variable:

LISTEN_ADDR=127.0.0.1:3000 ./bin/serve-rwgps

Then to query a route:

curl http://localhost:3000/rwgps?routeId=30165378  

To include CTC Cambridge refreshment stops in the output:

curl 'http://localhost:8000/rwgps?routeId=29766778&stops=ctccambridge'

See https://ctccambridge.org.uk/waypoints for information about this data source.

For stops farther afield, you can try the stops maintained by https://cafes.cyclingmaps.net/

curl 'http://localhost:8000/rwgps?routeId=29766778&stops=cyclingmaps'

Attribution

Contains OS data © Crown copyright and database right 2018

MIT License

Copyright © 2020 Raymond Miller

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.