strava-declutter
v0.1.1
Published
Draw each road of your Strava activities only once on a map
Maintainers
Readme
strava-declutter draws each road of your Strava activities only once on a map.
Drawing every track of a long Strava history gives a map of blobs. It cuts the parts of a track following a road already drawn, so that zoomed in every street you went through is drawn once, and zoomed out the lines stay as fine and as far apart everywhere, however many times you went through a place.
It powers gatsby-strava-declutter, and it works without Gatsby too, for any static site generator or script. It reads the activities that strava-sync stores.
Installation
npm install strava-declutterNode 22.12 or later is required. The package is an ES module, which require() loads too, and it comes with its TypeScript types.
Command line
npx strava-declutter # .strava to declutter.json
npx strava-declutter --store .strava --out public/declutter.json
npx strava-declutter --min-zoom 8 --max-zoom 14It reads the store of strava-sync, keeps its work in .strava-declutter between runs (--cache), and writes an object of activity id to {hidden, reason, parts, stubs}. Run it with --help to list its options.
Usage
import {createFileStore} from "strava-sync"
import {
consoleLogger,
createDeclutterStore,
declutterActivities,
} from "strava-declutter"
const activities = await createFileStore({dir: ".strava"}).readActivities()
const {results} = await declutterActivities({
activities,
store: createDeclutterStore({dir: ".strava-declutter"}),
filter: (activity) => activity.visibility === "everyone",
minZoom: 6,
maxZoom: 12,
logger: consoleLogger,
})
results.get(activities[0].id) // {hidden, reason, parts, stubs}An activity is any object with an id, a start_date and coordinates, a list of [lng, lat] points, which is what strava-sync stores.
| Function | What it does |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| declutterActivities({activities, ...}) | Declutters the activities with a track, reusing the store. Returns {results, shownCount, hiddenCount, declutteredCount} |
| createDeclutterStore({dir}) | The files that keep the result between runs |
| declutter(activities, {minZoom, maxZoom}) | The same without a store or a filter, returns the results map |
| declutterWithState(activities, options, previous) | {results, entries, reused}, to keep the state yourself |
| simplify(coordinates, tolerance) | A full track with a few hundred points instead of thousands |
Every function that logs takes a logger with info, warn and error methods. Nothing is logged by default, consoleLogger prints to the console.
Read the declutter documentation for the options, the result and the store.
