overnight

package
v0.37.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package overnight suggests where to sleep at the end of a planned day: hotel Level 2 chargers from the NREL listing near the point where the day's drive budget runs out. It is archive-only (no Rivian call) and a static snapshot: a listed charger may be in use, broken or guests-only, so callers present these as "listed, not guaranteed".

Index

Constants

View Source
const (
	DefaultBudgetHours = 8.0
	MaxPathPoints      = 20000
)

Defaults and limits.

Variables

View Source
var ErrBadRequest = errors.New("invalid overnight request")

ErrBadRequest marks input the suggestion cannot work from.

Functions

This section is empty.

Types

type Archive

type Archive interface {
	QueryCorridor(path [][2]float64, filter chargers.Filter, opts chargers.QueryCorridorOptions) ([]chargers.POI, error)
}

Archive is the part of chargers.Archive used here.

type Candidate

type Candidate struct {
	Name         string  `json:"name"`
	Lat          float64 `json:"lat"`
	Lon          float64 `json:"lon"`
	EntityID     string  `json:"entity_id,omitempty"`
	FacilityType string  `json:"facility_type,omitempty"`
	// L2KW is the listed power, or the assumed 7 kW when the listing has none
	// (then L2KWAssumed is true and the UI says so).
	L2KW        float64 `json:"l2_kw"`
	L2KWAssumed bool    `json:"l2_kw_assumed"`
	L2Count     int     `json:"l2_count,omitempty"`
	// DetourM is the extra distance to go there and back to the route.
	DetourM float64 `json:"detour_m"`
	// AlongM is how far along the day's route the stop is.
	AlongM float64 `json:"along_m"`
	// DCFCNearby is the closest fast charger within a few miles, if any.
	DCFCNearby *DCFC `json:"dcfc_nearby"`
}

Candidate is one suggested overnight stop.

type DCFC

type DCFC struct {
	Name       string  `json:"name,omitempty"`
	DistanceM  float64 `json:"distance_m"`
	MaxPowerKW float64 `json:"max_power_kw,omitempty"`
}

DCFC is a fast charger near a candidate, for a morning top-up.

type Request

type Request struct {
	// Path is the day's route as (lat, lon) pairs, start to end.
	Path [][2]float64
	// DriveSec is the route's driving time. 0 assumes 90 km/h.
	DriveSec float64
	// BudgetHours is the most driving in the day (0 uses the default of 8).
	// BudgetMiles, when positive, is used instead.
	BudgetHours float64
	BudgetMiles float64
}

Request describes one day's route and its drive budget.

type Result

type Result struct {
	Candidates []Candidate `json:"candidates"`
	Target     Target      `json:"target"`
	RouteM     float64     `json:"route_m"`
}

Result is the suggestion.

func Suggest

func Suggest(a Archive, req Request) (*Result, error)

Suggest finds up to three hotel Level 2 stops near where the day's drive budget runs out. The result is deterministic for a given archive.

type Target

type Target struct {
	Lat    float64 `json:"lat"`
	Lon    float64 `json:"lon"`
	AlongM float64 `json:"along_m"`
	// ReachesEnd is true when the whole day fits in the budget; the stops are
	// then around the day's end.
	ReachesEnd bool `json:"reaches_end"`
}

Target is the point the budget reaches.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL