route

package
v0.0.0-...-c486877 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHEREPlannerHP

func NewHEREPlannerHP(client httpGetter, geocodeEndpoint string, routeEndpoint string, appID string, appCode string) herePlanner

nolint - this is duplicated to return a herePlanner rather than a Planner interface

Types

type DTODPlannerMileage

type DTODPlannerMileage interface {
	DTODZip5Distance(appCtx appcontext.AppContext, pickup string, destination string) (int, error)
}

DTODPlannerMileage is the interface for connecting to DTOD SOAP service and requesting distance mileage NOTE: Placing this in a separate package/directory to avoid a circular dependency from an existing mock.

func NewDTODZip5Distance

func NewDTODZip5Distance(username string, password string, soapClient SoapCaller) DTODPlannerMileage

NewDTODZip5Distance returns a new DTOD Planner Mileage interface

func NewMockDTODZip5Distance

func NewMockDTODZip5Distance() DTODPlannerMileage

NewMockDTODZip5Distance is a mock (but deterministic) implementation of a DTOD call to calculate mileage

type Error

type Error interface {
	error
	Code() ErrorCode
}

Error is used for handling errors from the Route package

func NewAddressLookupError

func NewAddressLookupError(statusCode int, a *models.Address) Error

NewAddressLookupError returns a known error for failed address lookups

func NewGeocodeResponseDecodingError

func NewGeocodeResponseDecodingError(r GeocodeResponseBody) Error

NewGeocodeResponseDecodingError creates a new geocodeResponseDecodingError error.

func NewRoutingResponseDecodingError

func NewRoutingResponseDecodingError(r RoutingResponseBody) Error

NewRoutingResponseDecodingError creates a new routingResponseDecodingError error.

func NewShortHaulError

func NewShortHaulError(source LatLong, dest LatLong, moveDistance int) Error

NewShortHaulError is the new short haul error

func NewUnknownAddressLookupError

func NewUnknownAddressLookupError(statusCode int, a *models.Address) Error

NewUnknownAddressLookupError returns an unknown error for failed address lookups

func NewUnknownRoutingError

func NewUnknownRoutingError(statusCode int, source LatLong, dest LatLong) Error

NewUnknownRoutingError returns an error for failed postal code lookups

func NewUnroutableRouteError

func NewUnroutableRouteError(statusCode int, source LatLong, dest LatLong) Error

NewUnroutableRouteError creates a new responseError error.

type ErrorCode

type ErrorCode string

ErrorCode contains error codes for the route package

const (
	// UnroutableRoute happens when a valid route can't be calculated between two locations
	UnroutableRoute ErrorCode = "UNROUTABLE_ROUTE"
	// AddressLookupError happens when doing a LatLong lookup of an address
	AddressLookupError ErrorCode = "ADDRESS_LOOKUP_ERROR"
	// GeocodeResponseDecodingError happens when attempting to decode a geocode response
	GeocodeResponseDecodingError ErrorCode = "GEOCODE_RESPONSE_DECODE_ERROR"
	// RoutingResponseDecodingError happens when attempting to decode a routing response
	RoutingResponseDecodingError ErrorCode = "ROUTING_RESPONSE_DECODE_ERROR"
	// ShortHaulError - no moves under 50 miles
	ShortHaulError ErrorCode = "SHORT_HAUL_ERROR"
	// UnknownError is for when the cause of the error can't be ascertained
	UnknownError ErrorCode = "UNKNOWN_ERROR"
)

type GeocodeResponse

type GeocodeResponse struct {
	View []HereSearchResultsViewType `json:"View"`
}

GeocodeResponse is the json structure returned as "Response" in HERE geocode request

type GeocodeResponseBody

type GeocodeResponseBody struct {
	Response GeocodeResponse `json:"Response"`
}

GeocodeResponseBody is the json structure returned from HERE geocode request

type HerePosition

type HerePosition struct {
	Lat  float32 `json:"Latitude"`
	Long float32 `json:"Longitude"`
}

HerePosition is a lat long position in the json response from HERE

type HereRoute

type HereRoute struct {
	Summary HereRouteSummary `json:"summary"`
}

HereRoute is one of the Route responses from the HERE routing API

type HereRouteSummary

type HereRouteSummary struct {
	Distance int `json:"distance"` // Distance in meters
}

HereRouteSummary is the json object containing the summary of the route a HERE routing API response

type HereSearchLocation

type HereSearchLocation struct {
	NavigationPosition []HerePosition `json:"NavigationPosition"`
}

HereSearchLocation is part of the json response from the geocoder

type HereSearchResultType

type HereSearchResultType struct {
	Location HereSearchLocation `json:"Location"`
}

HereSearchResultType is part of the json response from the geo

type HereSearchResultsViewType

type HereSearchResultsViewType struct {
	Result []HereSearchResultType `json:"Result"`
}

HereSearchResultsViewType is part of the json response from the geocoder

type LatLong

type LatLong struct {
	Latitude  float32
	Longitude float32
}

LatLong is used to hold latitude and longitude as floats

func Zip5ToLatLong

func Zip5ToLatLong(zip5 string) (LatLong, error)

Zip5ToLatLong looks up a zip code and returns the Lat Long from the census data

func Zip5ToZip3LatLong

func Zip5ToZip3LatLong(zip5 string) (LatLong, error)

Zip5ToZip3LatLong looks up a zip code and returns the Lat Long from the census data

func (LatLong) Coords

func (ll LatLong) Coords() string

Coords returns a string with the comma separated co-ordinares, e.g "47.610,-122.107"

type Planner

type Planner interface {
	TransitDistance(appCtx appcontext.AppContext, source *models.Address, destination *models.Address) (int, error)
	LatLongTransitDistance(appCtx appcontext.AppContext, source LatLong, destination LatLong) (int, error)
	// Zip5TransitDistanceLineHaul is used by PPM flow and checks for minimum distance restriction as PPM doesn't allow short hauls
	// New code should probably make the minimum checks after calling Zip5TransitDistance over using this method
	Zip5TransitDistanceLineHaul(appCtx appcontext.AppContext, source string, destination string) (int, error)
	ZipTransitDistance(appCtx appcontext.AppContext, source string, destination string) (int, error)
	Zip3TransitDistance(appCtx appcontext.AppContext, source string, destination string) (int, error)
	Zip5TransitDistance(appCtx appcontext.AppContext, source string, destination string) (int, error)
}

Planner is the interface needed by Handlers to be able to evaluate the distance to be used for move accounting

func InitDTODRoutePlanner

func InitDTODRoutePlanner(appCtx appcontext.AppContext, v *viper.Viper, tlsConfig *tls.Config) (Planner, error)

InitDTODRoutePlanner creates a new DTOD route planner that adheres to the Planner interface

func InitHHGRoutePlanner

func InitHHGRoutePlanner(appCtx appcontext.AppContext, v *viper.Viper, tlsConfig *tls.Config) (Planner, error)

InitHHGRoutePlanner creates a new HHG route planner that adheres to the Planner interface

func InitRoutePlanner

func InitRoutePlanner(v *viper.Viper) Planner

InitRoutePlanner creates a new HERE route planner that adheres to the Planner interface

func NewDTODPlanner

func NewDTODPlanner(dtodPlannerMileage DTODPlannerMileage) Planner

NewDTODPlanner constructs and returns a Planner for GHC routing.

func NewHEREPlanner

func NewHEREPlanner(client httpGetter, geocodeEndpoint string, routeEndpoint string, appID string, appCode string) Planner

NewHEREPlanner constructs and returns a Planner which uses the HERE Map API to plan routes.

func NewHHGPlanner

func NewHHGPlanner(dtodPlannerMileage DTODPlannerMileage) Planner

NewHHGPlanner constructs and returns a Planner for GHC routing.

type RoutingResponse

type RoutingResponse struct {
	Routes []HereRoute `json:"route"`
}

RoutingResponse is the top level object in the response from the HERE routing API

type RoutingResponseBody

type RoutingResponseBody struct {
	Response RoutingResponse `json:"response"`
}

RoutingResponseBody is the json structure returned from HERE routing request

type SoapCaller

type SoapCaller interface {
	Call(m string, p gosoap.SoapParams) (res *gosoap.Response, err error)
}

SoapCaller provides an interface for the Call method of the gosoap Client so it can be mocked. NOTE: Placing this in a separate package/directory to avoid a circular dependency from an existing mock.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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