### Initialize Clerk server Source: https://github.com/larsen/rando-planner/blob/master/README.md Setup code to start the Clerk HTTP server for viewing notebooks. ```clojure (ns user) (require '[nextjournal.clerk :as clerk]) (clerk/serve! {:watch-paths ["notebooks" "src"]}) ``` -------------------------------- ### Complete Clerk Notebook Example with Rando Planner Source: https://context7.com/larsen/rando-planner/llms.txt A comprehensive example demonstrating how to set up a Clerk notebook using Rando Planner components. It includes defining a trip plan, calculating total distance, and displaying elevation profiles, plan diagrams, and interactive maps. ```clojure (ns notebooks.my-trip {:nextjournal.clerk/toc true} (:require [rando-planner.diagram :as diagram] [rando-planner.gpx :as gpx] [rando-planner.leaflet :as leaflet] [nextjournal.clerk :as clerk])) ;; Define your route plan (def berlin-rostock-plan {:gpx "gpx/be-rostock.gpx" :average-speed 18 :daily-plans [{:date "2024-04-01" :label "Day 1: Berlin to Neuruppin" :color "red" :activities [{:start "08:00" :type :ride :length 3} {:start "12:00" :type :ride :length 4}]} {:date "2024-04-02" :label "Day 2: Neuruppin to Rostock" :color "blue" :activities [{:start "08:00" :type :ride :length 4} {:start "13:00" :type :ride :length 4}]}]}) ;; Check total distance (gpx/total-distance "gpx/be-rostock.gpx") ;; => ~261 km ;; Display elevation profile with daily breakdown (clerk/with-viewer diagram/elevation-viewer berlin-rostock-plan) ;; Display schematic plan diagram (clerk/with-viewer diagram/plan-viewer berlin-rostock-plan) ;; Display interactive map (clerk/with-viewer leaflet/leaflet-gpx-viewer berlin-rostock-plan) ;; Compare two different plans side by side (merge {:nextjournal/width :full} (clerk/row (clerk/col (clerk/html [:h3 "Conservative Plan"]) (clerk/with-viewer diagram/elevation-viewer conservative-plan) (clerk/with-viewer diagram/plan-viewer conservative-plan)) (clerk/col (clerk/html [:h3 "Aggressive Plan"]) (clerk/with-viewer diagram/elevation-viewer aggressive-plan) (clerk/with-viewer diagram/plan-viewer aggressive-plan)))) ``` -------------------------------- ### Extract Daily Pause Information Source: https://context7.com/larsen/rando-planner/llms.txt Calculates break times and durations within a single day's plan. Returns a list of pause objects containing start times and durations. ```clojure (require '[rando-planner.plan :as plan]) (def day-plan {:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 3} {:start "15:00" :type :ride :length 5}]}) (plan/pauses day-plan) ``` -------------------------------- ### Get GPX Route Bounding Box (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Returns the bounding box coordinates (minimum and maximum latitude/longitude) for a set of points. This is useful for setting map zoom levels to encompass the entire route. ```clojure (require '[rando-planner.gpx :as gpx]) ;; Get bounding box for map zoom (let [points (gpx/points "gpx/be-rostock.gpx")] (gpx/bounds points)) ``` -------------------------------- ### plan/daily-distance Source: https://context7.com/larsen/rando-planner/llms.txt Calculates statistics for each day in a plan, including total kilometers, starting points, and elevation gain. ```APIDOC ## POST /plan/daily-distance ### Description Returns statistics for each day including kilometers, starting point, and elevation gain based on the provided plan. ### Method POST ### Endpoint /plan/daily-distance ### Request Body - **gpx** (string) - Required - Path to the GPX file - **average-speed** (number) - Required - Average speed in km/h - **daily-plans** (array) - Required - List of daily activities ### Request Example { "gpx": "gpx/be-rostock.gpx", "average-speed": 20, "daily-plans": [{ "date": "2024-04-01", "activities": [{ "start": "10:00", "length": 8 }] }] } ### Response #### Success Response (200) - **day** (number) - Day index - **kilometers** (number) - Total distance for the day - **elevation** (number) - Total elevation gain #### Response Example [{ "day": 1, "kilometers": 160, "elevation": 375.7 }] ``` -------------------------------- ### Get Elevation Data per Kilometer (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Returns elevation data grouped by kilometer intervals along the route. This is essential for generating elevation profiles and analyzing altitude changes. ```clojure (require '[rando-planner.gpx :as gpx]) ;; Get elevation data per kilometer (gpx/elevation "gpx/be-rostock.gpx") ``` -------------------------------- ### Render Plan Viewer Source: https://context7.com/larsen/rando-planner/llms.txt Renders a schematic SVG diagram showing hourly progress with daylight indicators and pause markers. It displays hourly km counts, daylight coloring, pause markers, and daily totals. ```clojure (require '[rando-planner.diagram :as diagram]) (require '[nextjournal.clerk :as clerk]) (def my-plan {:gpx "gpx/be-rostock.gpx" :description "Berlin to Rostock Spring Tour" :average-speed 18 :daily-plans [{:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 3} {:start "15:00" :type :ride :length 5}]} {:date "2024-04-02" :label "Second day" :activities [{:start "10:00" :type :ride :length 4} {:start "16:00" :type :ride :length 2.5}]}]}) (clerk/with-viewer diagram/plan-viewer my-plan) ``` -------------------------------- ### Define Rando Planner Data Structure (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Defines the complete structure for a multi-day bikepacking plan, including GPX file path, average speed, and daily activities with optional overrides for speed and color. ```clojure (def my-plan {:gpx "gpx/be-rostock.gpx" :average-speed 18 :daily-plans [{:date "2024-04-01" :label "First day" :color "red" :average-speed 20 :activities [{:start "10:00" :type :ride :length 3} {:start "15:00" :type :ride :length 5}]} {:date "2024-04-02" :label "Second day" :activities [{:start "10:00" :type :ride :length 4} {:start "16:00" :type :ride :length 2.5}]}]}) ``` -------------------------------- ### Render Elevation Profile Viewer Source: https://context7.com/larsen/rando-planner/llms.txt Renders an SVG elevation profile with daily statistics, pause markers, and an elevation legend. It takes a GPX file path and optional daily plan data as input. ```clojure (require '[rando-planner.diagram :as diagram]) (require '[nextjournal.clerk :as clerk]) ;; Simple elevation profile without plan (clerk/with-viewer diagram/elevation-viewer {:gpx "gpx/be-rostock.gpx"}) ;; Elevation profile with daily breakdown and pause markers (clerk/with-viewer diagram/elevation-viewer {:gpx "gpx/be-rostock.gpx" :average-speed 18 :daily-plans [{:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 3} {:start "15:00" :type :ride :length 5}]} {:date "2024-04-02" :label "Second day" :activities [{:start "10:00" :type :ride :length 4} {:start "16:00" :type :ride :length 2.5}]}]}) ``` -------------------------------- ### Add rando-planner dependency Source: https://github.com/larsen/rando-planner/blob/master/README.md Configuration for including rando-planner in a Clojure project using deps.edn. ```clojure {:paths ["src"] :deps {org.clojure/clojure {:mvn/version "1.12.0"} rando-planner/rando-planner {:git/url "https://github.com/larsen/rando-planner.git" :git/tag "tagname" :git/sha "xxxxxxxx"}}} ``` -------------------------------- ### plan/daily-stats Source: https://context7.com/larsen/rando-planner/llms.txt Returns comprehensive daily statistics including GPS coordinates and pause information. ```APIDOC ## POST /plan/daily-stats ### Description Returns comprehensive statistics for each day including GPS coordinates and pause information. ### Method POST ### Endpoint /plan/daily-stats ### Request Body - **gpx** (string) - Required - Path to the GPX file - **average-speed** (number) - Required - Average speed in km/h - **daily-plans** (array) - Required - List of daily activities ### Response #### Success Response (200) - **lat** (number) - End-of-day latitude - **lon** (number) - End-of-day longitude - **pauses** (array) - List of pause objects ``` -------------------------------- ### Define a cycling plan Source: https://github.com/larsen/rando-planner/blob/master/README.md Data structure definition for a multi-day cycling plan, including GPX source, daily schedules, speeds, and activities. ```clojure (def example-plan {:gpx "gpx/be-rostock.gpx" :daily-plans [{:date "2024-04-01" :label "First day" :average-speed 20 :color "red" :activities [{:start "10:00" :type :ride :length 3} {:start "17:00" :type :ride :length 2} {:start "20:00" :type :ride :length 3}]} {:date "2024-04-02" :label "Second day" :average-speed 18 :activities [{:start "10:00" :type :ride :length 4} {:start "16:00" :type :ride :length 2.5}]}]}) ``` -------------------------------- ### Calculate Daily Distance Statistics Source: https://context7.com/larsen/rando-planner/llms.txt Computes daily metrics such as total distance, covered distance, and elevation gain based on a plan map. It requires a GPX file path and a list of daily activities. ```clojure (require '[rando-planner.plan :as plan]) (def my-plan {:gpx "gpx/be-rostock.gpx" :average-speed 20 :daily-plans [{:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 8}]} {:date "2024-04-02" :label "Second day" :activities [{:start "10:00" :type :ride :length 6}]}]}) (plan/daily-distance my-plan) ``` -------------------------------- ### Retrieve Comprehensive Daily Statistics Source: https://context7.com/larsen/rando-planner/llms.txt Generates detailed daily stats including GPS coordinates, elevation, and pause intervals. Useful for detailed route reporting. ```clojure (require '[rando-planner.plan :as plan]) (def my-plan {:gpx "gpx/be-rostock.gpx" :average-speed 20 :daily-plans [{:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 3} {:start "17:00" :type :ride :length 2} {:start "20:00" :type :ride :length 3}]}]}) (plan/daily-stats my-plan) ``` -------------------------------- ### Parse GPX File Points (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Parses a GPX file and returns a sequence of track points, each containing latitude, longitude, and elevation data. This is a fundamental step for route analysis. ```clojure (require '[rando-planner.gpx :as gpx]) ;; Parse GPX file and get all track points (gpx/points "gpx/my-route.gpx") ``` -------------------------------- ### Calculate Daily Kilometers Source: https://context7.com/larsen/rando-planner/llms.txt Determines the total distance covered in a day based on activity length and average speed. ```clojure (require '[rando-planner.plan :as plan]) (def day-plan {:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 3} {:start "15:00" :type :ride :length 5}]}) (plan/kilometers-in-a-day day-plan 20) ``` -------------------------------- ### Render Interactive Leaflet GPX Map Source: https://context7.com/larsen/rando-planner/llms.txt Uses Clerk to render an interactive map with GPX data. Supports route visualization, day-specific segment coloring, and map focusing. ```clojure (require '[rando-planner.leaflet :as leaflet] '[nextjournal.clerk :as clerk]) (clerk/with-viewer leaflet/leaflet-gpx-viewer {:gpx "gpx/be-rostock.gpx" :average-speed 18 :daily-plans [{:date "2024-04-01" :label "First day" :color "red" :activities [{:start "10:00" :type :ride :length 3} {:start "15:00" :type :ride :length 5}]} {:date "2024-04-02" :label "Second day" :color "blue" :activities [{:start "10:00" :type :ride :length 4} {:start "16:00" :type :ride :length 2.5}]}]}) ``` -------------------------------- ### Calculate Sunrise and Sunset Times Source: https://context7.com/larsen/rando-planner/llms.txt Calculates sunrise and sunset times for a given location and date using a Unix timestamp, latitude, longitude, and an optional timezone. Returns a vector of datetime objects. ```clojure (require '[rando-planner.suncalc :as suncalc]) ;; Calculate sunrise/sunset for Veneto, Italy on Feb 6, 2024 ;; ts is Unix timestamp in seconds (suncalc/sunset-sunrise-times 1707225141 45.485717 11.315627 0) ;; => [#time/datetime "2024-02-06T07:23:45" #time/datetime "2024-02-06T17:32:18"] ;; With timezone specification (suncalc/sunset-sunrise-times 1707225141 45.485717 11.315627 0 "Europe/Rome") ;; => [#time/datetime "2024-02-06T08:23:45" #time/datetime "2024-02-06T18:32:18"] ``` -------------------------------- ### leaflet/leaflet-gpx-viewer Source: https://context7.com/larsen/rando-planner/llms.txt Renders an interactive Leaflet map with the GPX route and markers. ```APIDOC ## POST /leaflet/leaflet-gpx-viewer ### Description Renders an interactive Leaflet map with the GPX route, start/end markers, and day-end markers with popups. ### Method POST ### Endpoint /leaflet/leaflet-gpx-viewer ### Request Body - **gpx** (string) - Required - Path to the GPX file - **average-speed** (number) - Optional - Average speed for segment calculation - **daily-plans** (array) - Optional - Daily plan details - **focus-on** (string) - Optional - Label of the day to center the map on ``` -------------------------------- ### Calculate Geographic Center of Points (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Calculates the geographic center (latitude and longitude) of a given set of points. This is useful for centering maps on the route. ```clojure (require '[rando-planner.gpx :as gpx]) ;; Get center coordinates for map display (let [points (gpx/points "gpx/be-rostock.gpx")] (gpx/center points)) ``` -------------------------------- ### Calculate Hourly Cumulative Distances Source: https://context7.com/larsen/rando-planner/llms.txt Returns a sequence of cumulative distances calculated at the end of each riding hour for a specific day. ```clojure (require '[rando-planner.plan :as plan]) (def day-plan {:date "2024-04-01" :label "First day" :activities [{:start "10:00" :type :ride :length 4} {:start "16:00" :type :ride :length 4}]}) (plan/hourly-cumulative-distances-in-a-day day-plan 20) ``` -------------------------------- ### Calculate Elevation Gain Over Distance (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Calculates the total elevation gain between two specified kilometer markers within the elevation data of a GPX route. It helps in understanding the climbing effort over specific segments. ```clojure (require '[rando-planner.gpx :as gpx]) ;; Calculate elevation gain for first 100km (let [elevation-data (gpx/elevation "gpx/be-rostock.gpx")] (gpx/elevation-gain elevation-data 0 100)) ``` -------------------------------- ### GPX Processing API Source: https://context7.com/larsen/rando-planner/llms.txt Functions for parsing and analyzing GPX track data, including distance, elevation, and geographic bounds. ```APIDOC ## FUNCTION gpx/points ### Description Parses a GPX file and returns a sequence of track points with latitude, longitude, and elevation. ### Parameters - **path** (string) - Required - Path to the GPX file in resources/ ### Response - **points** (list) - A sequence of maps containing :lat, :lon, and :ele keys. ## FUNCTION gpx/total-distance ### Description Calculates the total distance of a GPX route in kilometers using the Haversine formula. ### Parameters - **path** (string) - Required - Path to the GPX file ### Response - **distance** (float) - Total distance in kilometers. ## FUNCTION gpx/elevation ### Description Returns elevation data grouped by kilometer, useful for creating elevation profiles. ### Parameters - **path** (string) - Required - Path to the GPX file ### Response - **elevation-data** (list) - A sequence of maps containing :kilometer, :elevation, and :elevation-gain. ## FUNCTION gpx/elevation-gain ### Description Calculates total elevation gain between two kilometer markers. ### Parameters - **elevation-data** (list) - Required - Data returned from gpx/elevation - **start** (number) - Required - Start kilometer - **end** (number) - Required - End kilometer ### Response - **gain** (float) - Total meters gained. ``` -------------------------------- ### Calculate Total GPX Route Distance (Clojure) Source: https://context7.com/larsen/rando-planner/llms.txt Calculates the total distance of a GPX route in kilometers. It utilizes the Haversine formula for accurate distance measurement between points. ```clojure (require '[rando-planner.gpx :as gpx]) ;; Get total route distance (gpx/total-distance "gpx/be-rostock.gpx") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.