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 ¶
const ( DefaultBudgetHours = 8.0 MaxPathPoints = 20000 )
Defaults and limits.
const ( KindHotel = "hotel" KindCampground = "campground" )
Kinds of stay a candidate can be.
const ( ConnJ1772 = "j1772" ConnNEMA1450 = "nema_14_50" ConnTT30 = "nema_tt_30" ConnNEMA520 = "nema_5_20" )
Connectors a candidate is reached through.
const ( Attribution = "Data: Recreation.gov (RIDB), CC BY 4.0; filtered by Rivolt" AttributionSourceURL = "https://catalog.data.gov/dataset/recreation-information-database-ridb" AttributionLicenseURL = "https://creativecommons.org/licenses/by/4.0/" )
The credit CC BY 4.0 needs for the Recreation.gov data: the name, a link to the licence and to the source, and a note that we changed it (we keep a few facts per campground and plan the power ourselves). A page shows Attribution with "Recreation.gov (RIDB)" linked to AttributionSourceURL and "CC BY 4.0" linked to AttributionLicenseURL.
Variables ¶
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"`
// Kind is KindHotel or KindCampground.
Kind string `json:"kind"`
// Connector, NeedsAdapter, ElectricSites, Sites, ReservationRequired, Fee,
// Source, SourceURL, AsOf and Attribution are set for campgrounds. A 30 A
// TT-30 site needs an adapter Rivian's Portable Charger does not ship.
// ReservationRequired is null when the listing does not say.
Connector string `json:"connector,omitempty"`
NeedsAdapter bool `json:"needs_adapter,omitempty"`
ElectricSites int `json:"electric_sites,omitempty"`
Sites int `json:"sites,omitempty"`
ReservationRequired *bool `json:"reservation_required,omitempty"`
Fee string `json:"fee,omitempty"`
Source string `json:"source,omitempty"`
SourceURL string `json:"source_url,omitempty"`
AsOf string `json:"asof,omitempty"`
Attribution string `json:"attribution,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
// Kinds are the stays to suggest: KindHotel, KindCampground. Empty means
// hotels only, as before.
Kinds []string
}
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.
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.