Documentation
¶
Index ¶
- Constants
- type Admin
- type Annotation
- type Annotations
- type Approach
- type Approaches
- type ArriveBy
- type BannerInstruction
- type BoundingBox
- type Client
- func (c *Client) Directions(ctx context.Context, req *DirectionsRequest) (*DirectionsResponse, error)
- func (c *Client) DirectionsMatrix(ctx context.Context, req *DirectionsMatrixRequest) (*DirectionsMatrixResponse, error)
- func (c *Client) ForwardGeocode(ctx context.Context, req *ForwardGeocodeRequest) (*GeocodeResponse, error)
- func (c *Client) ForwardGeocodeBatch(ctx context.Context, req ForwardGeocodeBatchRequest) (*GeocodeBatchResponse, error)
- func (c *Client) ReverseGeocode(ctx context.Context, req *ReverseGeocodeRequest) (*GeocodeResponse, error)
- func (c *Client) ReverseGeocodeBatch(ctx context.Context, req ReverseGeocodeBatchRequest) (*GeocodeBatchResponse, error)
- func (c *Client) SearchboxReverse(ctx context.Context, req *SearchboxReverseRequest) (*SearchboxReverseResponse, error)
- type Component
- type Context
- type Coordinate
- type Coordinates
- type DepartAt
- type DepartureTime
- type Destinations
- type DirectionWaypoint
- type DirectionWaypoints
- type DirectionsAnnotation
- type DirectionsMatrixRequest
- type DirectionsMatrixResponse
- type DirectionsRequest
- type DirectionsResponse
- type Endpoint
- type ErrorResponse
- type Exclude
- type Excludes
- type ExtendedCoordinate
- type FallbackSpeed
- type Feature
- type ForwardGeocodeBatchRequest
- type ForwardGeocodeBatchResponse
- type ForwardGeocodeRequest
- type GeocodeBatchResponse
- type GeocodeResponse
- type Geometries
- type Geometry
- type HTTPClient
- type Include
- type Includes
- type Instruction
- type Intersection
- type Maneuver
- type MapboxConfig
- type MapboxError
- type MatchCode
- type MatchCodeConfidence
- type MatchCodeValue
- type Maxspeed
- type Overview
- type Profile
- type Properties
- type RateLimit
- type ReverseGeocodeBatchRequest
- type ReverseGeocodeRequest
- type RoutablePoint
- type Route
- type RouteLeg
- type SearchboxReverseFeature
- type SearchboxReverseProperties
- type SearchboxReverseRequest
- type SearchboxReverseResponse
- type Sources
- type Step
- type Type
- type Types
- type ViaWaypoint
- type VoiceInstruction
- type VoiceUnits
- type Waypoint
- type WaypointName
- type WaypointNames
- type WaypointTarget
- type WaypointTargets
Constants ¶
const ( GeocodingRateLimit = "geocoding" MatrixRateLimit = "matrix" DirectionsRateLimit = "directions" SearchboxRateLimit = "searchbox" )
const ( GeometryLngIdx = 0 GeometryLatIdx = 1 )
const ( GeocodingBatchEndpoint = "/search/geocode/v6/batch" GeocodingReverseEndpoint = "/search/geocode/v6/reverse" GeocodingForwardEndpoint = "/search/geocode/v6/forward" )
const ( MatchCodeConfidenceExact MatchCodeConfidence = "exact" MatchCodeConfidenceHigh MatchCodeConfidence = "high" MatchCodeConfidenceMedium MatchCodeConfidence = "medium" MatchCodeConfidenceLow MatchCodeConfidence = "low" MatchCodeValueMatched MatchCodeValue = "matched" MatchCodeValueUnmatched MatchCodeValue = "unmatched" MatchCodeValueNotApplicable MatchCodeValue = "not_applicable" MatchCodeValueInferred MatchCodeValue = "inferred" MatchCodeValuePlausible MatchCodeValue = "plausible" )
const ( ProfileDriving = Profile("mapbox/driving") ProfileWalking = Profile("mapbox/walking") ProfileCycling = Profile("mapbox/cycling") ProfileDrivingTraffic = Profile("mapbox/driving-traffic") AnnotationDuration = Annotation("duration") AnnotationDistance = Annotation("distance") AnnotationSpeed = Annotation("speed") AnnotationCongestion = Annotation("congestion") ApproachUnrestricted = Approach("unrestricted") ApproachCurb = Approach("curb") TypeCountry = Type("country") TypeRegion = Type("region") TypePostcode = Type("postcode") TypeDistrict = Type("district") TypePlace = Type("place") TypeLocality = Type("locality") TypeNeighborhood = Type("neighborhood") TypeStreet = Type("street") TypeBlock = Type("block") TypeAddress = Type("address") TypeSecondaryAddress = Type("secondary_address") TypePOI = Type("poi") TypePOILandmark = Type("poi.landmark") ExcludeMotorway = Exclude("motorway") ExcludeToll = Exclude("toll") ExcludeFerry = Exclude("ferry") ExcludeUnpaved = Exclude("unpaved") ExcludeCashOnlyTolls = Exclude("cash_only_tolls") GeometriesGeoJSON = Geometries("geojson") GeometriesPolyline = Geometries("polyline") GeometriesPolyline6 = Geometries("polyline6") IncludeHov2 = Include("hov2") IncludeHov3 = Include("hov3") IncludeHot = Include("hot") OverviewFull = Overview("full") OverviewSimplified = Overview("simplified") OverviewFalse = Overview("false") VoiceUnitsImpreial = VoiceUnits("imperial") VoiceUnitsMetric = VoiceUnits("metric") )
const (
ArriveByFormat = "2006-01-02T15:04:05Z"
)
const (
DepartAtFormat = "2006-01-02T15:04:05Z"
)
const (
DepartureTimeFormat = "2006-01-02T15:04:05Z"
)
const (
ResponseOK = "Ok"
)
const (
SearchboxReverseEndpoint = "/search/searchbox/v1/reverse"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct { ISO_3166_1_alpha3 string `json:"iso_3166_1_alpha3"` // The ISO 3166-1 alpha-3 country code. ISO_3166_1 string `json:"iso_3166_1"` // The ISO 3166-1 alpha-2 country code. }
Admin represents administrative region information.
type Annotation ¶
type Annotation string
type Annotations ¶
type Annotations []Annotation
type Approaches ¶
type Approaches []Approach
type BannerInstruction ¶
type BannerInstruction struct { DistanceAlongGeometry float64 `json:"distanceAlongGeometry"` // The distance from the current step at which to show the instruction. Primary Instruction `json:"primary"` // The primary instruction for this step. Secondary *Instruction `json:"secondary,omitempty"` // An optional secondary instruction. }
BannerInstruction represents a visual instruction for navigation.
type BoundingBox ¶
type BoundingBox struct { Min Coordinate Max Coordinate }
type Client ¶
type Client struct { // Referer is needed when URL restrictions are enforced, see https://docs.mapbox.com/accounts/guides/tokens/#url-restrictions Referer string // contains filtered or unexported fields }
func NewClient ¶
func NewClient(config *MapboxConfig) (*Client, error)
NewClient instantiates a new Mapbox client.
func (*Client) Directions ¶
func (c *Client) Directions(ctx context.Context, req *DirectionsRequest) (*DirectionsResponse, error)
func (*Client) DirectionsMatrix ¶
func (c *Client) DirectionsMatrix(ctx context.Context, req *DirectionsMatrixRequest) (*DirectionsMatrixResponse, error)
func (*Client) ForwardGeocode ¶
func (c *Client) ForwardGeocode(ctx context.Context, req *ForwardGeocodeRequest) (*GeocodeResponse, error)
func (*Client) ForwardGeocodeBatch ¶
func (c *Client) ForwardGeocodeBatch(ctx context.Context, req ForwardGeocodeBatchRequest) (*GeocodeBatchResponse, error)
func (*Client) ReverseGeocode ¶
func (c *Client) ReverseGeocode(ctx context.Context, req *ReverseGeocodeRequest) (*GeocodeResponse, error)
func (*Client) ReverseGeocodeBatch ¶
func (c *Client) ReverseGeocodeBatch(ctx context.Context, req ReverseGeocodeBatchRequest) (*GeocodeBatchResponse, error)
func (*Client) SearchboxReverse ¶
func (c *Client) SearchboxReverse(ctx context.Context, req *SearchboxReverseRequest) (*SearchboxReverseResponse, error)
type Component ¶
type Component struct { Text string `json:"text"` // The component text. Type string `json:"type"` // The type of component, e.g., "text" or "icon". }
Component represents a part of the instruction, useful for highlighting parts of the text.
type Context ¶
type Context struct { // Always present MapboxID string `json:"mapbox_id"` Name string `json:"name"` // Optional but shared between many context types WikidataID string `json:"wikidata_id,omitempty"` // Region fields RegionCode string `json:"region_code,omitempty"` RegionCodeFull string `json:"region_code_full,omitempty"` // Address fields AddressNumber string `json:"address_number,omitempty"` StreetName string `json:"street_name,omitempty"` // Country fields CountryCode string `json:"country_code,omitempty"` CountryCodeAlpha3 string `json:"country_code_alpha_3,omitempty"` }
There are many different types of context objects, which are all mashed together here. https://docs.mapbox.com/api/search/geocoding/#the-context-object
type Coordinate ¶
func (Coordinate) IsZero ¶
func (c Coordinate) IsZero() bool
func (Coordinate) WGS84Format ¶
func (c Coordinate) WGS84Format() string
type Coordinates ¶
type Coordinates []Coordinate
func (Coordinates) WGS84Format ¶
func (c Coordinates) WGS84Format() string
type DepartureTime ¶
func (DepartureTime) IsZero ¶
func (t DepartureTime) IsZero() bool
type Destinations ¶
type Destinations []int
type DirectionWaypoint ¶
type DirectionWaypoint string
type DirectionWaypoints ¶
type DirectionWaypoints []DirectionWaypoint
type DirectionsAnnotation ¶
type DirectionsAnnotation struct { Distance []float64 `json:"distance"` // Array of distances between each pair of coordinates. Duration []float64 `json:"duration"` // Array of expected travel times from each coordinate to the next. Speed []float64 `json:"speed"` // Array of travel speeds. Congestion []string `json:"congestion"` // Array of congestion levels. Maxspeed []Maxspeed `json:"maxspeed"` }
Annotation contains additional details about each point along the route leg.
type DirectionsMatrixRequest ¶
type DirectionsMatrixRequest struct { // required Profile Profile Coordinates Coordinates // optional Annotations Annotations Approaches Approaches Destinations Destinations Sources Sources FallbackSpeed FallbackSpeed DepartureTime DepartureTime }
type DirectionsRequest ¶
type DirectionsRequest struct { // required Profile Profile Coordinates Coordinates // optional Alternatives *bool Annotations Annotations AvoidManeuverRadius int // Possible values are in the range from 1 to 1000 ContinueStraight *bool Excludes Excludes Geometries Geometries Includes Includes Overview Overview Approaches Approaches Steps *bool BannerInstructions *bool Language string RoundaboutExits *bool VoiceInstructions *bool VoiceUnits VoiceUnits Waypoints DirectionWaypoints WaypointsPerRoute *bool WaypointNames WaypointNames WaypointTargets WaypointTargets // Optional parameters for the mapbox/walking profile WalkingSpeed float32 WalkwayBias float32 // Optional parameters for the mapbox/driving profile AlleyBias float32 ArriveBy ArriveBy DepartAt DepartAt MaxHeight int MaxWidth int MaxWeight int // Optional parameters for the mapbox/driving-traffic profile SnappingIncludeClosures *bool SnappingIncludeStaticClosures *bool }
type DirectionsResponse ¶
type ErrorResponse ¶
type ExtendedCoordinate ¶
type ExtendedCoordinate struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Accuracy string `json:"accuracy"` RoutablePoints []RoutablePoint `json:"routable_points,omitempty"` }
type FallbackSpeed ¶
type FallbackSpeed float64
type Feature ¶
type Feature struct { ID string `json:"id"` Type string `json:"type"` Geometry *Geometry `json:"geometry"` // The center of Properties.BoundingBox Properties *Properties `json:"properties,omitempty"` }
type ForwardGeocodeBatchRequest ¶
type ForwardGeocodeBatchRequest []ForwardGeocodeRequest
type ForwardGeocodeBatchResponse ¶
type ForwardGeocodeBatchResponse struct {
Batch []GeocodeResponse `json:"batch"`
}
type ForwardGeocodeRequest ¶
type ForwardGeocodeRequest struct { SearchText string AddressLine1 string Postcode string Place string Autocomplete bool BBox BoundingBox Country string Language string Limit int Proximity Coordinate Types Types }
func (ForwardGeocodeRequest) MarshalJSON ¶
func (r ForwardGeocodeRequest) MarshalJSON() ([]byte, error)
type GeocodeBatchResponse ¶
type GeocodeBatchResponse struct {
Batch []GeocodeResponse `json:"batch"`
}
type GeocodeResponse ¶
type Geometries ¶
type Geometries string
type Geometry ¶
type Instruction ¶
type Instruction struct { Text string `json:"text"` // The instruction text. Type string `json:"type"` // The type of maneuver. Modifier string `json:"modifier"` // An additional modifier to provide more detail. Components []Component `json:"components"` // Components of the instruction. }
Instruction contains the details of a navigation instruction.
type Intersection ¶
type Intersection struct { Location []float64 `json:"location"` // The location of the intersection [longitude, latitude]. Bearings []int `json:"bearings"` // The bearings at the intersection, in degrees. Entry []bool `json:"entry"` // A boolean flag indicating the availability of the corresponding bearing. In int `json:"in,omitempty"` // The index into the bearings/entry array that denotes the incoming bearing to the intersection. Out int `json:"out,omitempty"` // The index into the bearings/entry array that denotes the outgoing bearing from the intersection. }
Intersection represents an intersection along a step.
type Maneuver ¶
type Maneuver struct { BearingAfter float64 `json:"bearing_after"` // The clockwise angle from true north to the direction of travel after the maneuver. BearingBefore float64 `json:"bearing_before"` // The clockwise angle from true north to the direction of travel before the maneuver. Location []float64 `json:"location"` // A [longitude, latitude] pair describing the location of the maneuver. Type string `json:"type"` // A string signifying the type of maneuver. Example: "turn". Modifier string `json:"modifier"` // An additional modifier to provide more detail. Example: "left". Instruction string `json:"instruction"` // Verbal instruction for the maneuver. }
Maneuver contains information about the required maneuver for a step, including type and bearing.
type MapboxConfig ¶
type MapboxConfig struct { Timeout time.Duration APIKey string // Optional http.Client can be defined in config if specific options are needed // If not provided will default to the stdlib http.Client Client HTTPClient }
type MapboxError ¶
func NewMapboxError ¶
func NewMapboxError(statusCode int, message string) MapboxError
func (MapboxError) Error ¶
func (e MapboxError) Error() string
type MatchCode ¶
type MatchCode struct { AddressNumber MatchCodeValue `json:"address_number"` Street MatchCodeValue `json:"street"` Postcode MatchCodeValue `json:"postcode"` Place MatchCodeValue `json:"place"` Region MatchCodeValue `json:"region"` Locality MatchCodeValue `json:"locality"` Country MatchCodeValue `json:"country"` Confidence MatchCodeConfidence `json:"confidence"` }
type MatchCodeConfidence ¶
type MatchCodeConfidence string
type MatchCodeValue ¶
type MatchCodeValue string
type Properties ¶
type Properties struct { MapboxID string `json:"mapbox_id"` FeatureType Type `json:"feature_type"` Name string `json:"name"` NamePreferred string `json:"name_preferred"` PlaceFormatted string `json:"place_formatted"` FullAddress string `json:"full_address"` Coordinates ExtendedCoordinate `json:"coordinates"` Context map[Type]Context `json:"context,omitempty"` BoundingBox []float64 `json:"bbox,omitempty"` MatchCode *MatchCode `json:"match_code,omitempty"` }
type RateLimit ¶
type RateLimit string
RateLimit represents a set of operations that share a rate limit see https://docs.mapbox.com/api/overview/#rate-limits
type ReverseGeocodeBatchRequest ¶
type ReverseGeocodeBatchRequest []ReverseGeocodeRequest
type ReverseGeocodeRequest ¶
type ReverseGeocodeRequest struct { Coordinate // optional Country string `json:"country,omitempty"` Language string `json:"language,omitempty"` Limit int `json:"limit,omitempty"` Types Types `json:"types,omitempty"` }
type RoutablePoint ¶
type Route ¶
type Route struct { Duration float64 `json:"duration"` Distance float64 `json:"distance"` WeightName string `json:"weight_name"` Weight float64 `json:"weight"` DurationTypical float64 `json:"duration_typical,omitempty"` WeightTypical float64 `json:"weight_typical,omitempty"` Geometry string `json:"geometry,omitempty"` Legs []RouteLeg `json:"legs"` VoiceLocale string `json:"voiceLocale,omitempty"` Waypoints []Waypoint `json:"waypoints,omitempty"` }
type RouteLeg ¶
type RouteLeg struct { Distance float64 `json:"distance"` // The distance traveled by the leg, in meters. Duration float64 `json:"duration"` // The estimated travel time, in seconds. Summary string `json:"summary"` // A summary of the leg, containing the names of the significant roads. Weight float64 `json:"weight"` // The weight of the leg. The weight value is similar to the duration but includes additional factors like traffic. Steps []Step `json:"steps"` // An array of RouteStep objects, each representing a step in the leg. Annotation DirectionsAnnotation `json:"annotation"` // Additional details about the leg. Admins []Admin `json:"admins"` // Array of administrative region objects traversed by the leg. VoiceInstructions []VoiceInstruction `json:"voiceInstructions"` // An array of VoiceInstruction objects. BannerInstructions []BannerInstruction `json:"bannerInstructions"` // An array of BannerInstruction objects. ViaWaypoints []ViaWaypoint `json:"via_waypoints"` }
RouteLeg represents a leg of the route between two waypoints.
type SearchboxReverseFeature ¶
type SearchboxReverseFeature struct { ID string `json:"id"` Type string `json:"type"` Geometry *Geometry `json:"geometry"` Properties *SearchboxReverseProperties `json:"properties,omitempty"` }
type SearchboxReverseProperties ¶
type SearchboxReverseProperties struct { MapboxID string `json:"mapbox_id"` FeatureType Type `json:"feature_type"` Name string `json:"name"` NamePreferred string `json:"name_preferred"` PlaceFormatted string `json:"place_formatted"` FullAddress string `json:"full_address"` Coordinates ExtendedCoordinate `json:"coordinates"` Context map[Type]Context `json:"context,omitempty"` BoundingBox []float64 `json:"bbox,omitempty"` Language string `json:"language"` Maki string `json:"maki"` POICategory []string `json:"poi_category"` POICategoryIDs []string `json:"poi_category_ids"` Brand []string `json:"brand"` BrandID []string `json:"brand_id"` ExternalIDs map[string]string `json:"external_ids,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
type SearchboxReverseRequest ¶
type SearchboxReverseRequest struct { Coordinate // optional Country string `json:"country,omitempty"` Language string `json:"language,omitempty"` Limit int `json:"limit,omitempty"` Types Types `json:"types,omitempty"` }
type SearchboxReverseResponse ¶
type SearchboxReverseResponse struct { Type string `json:"type"` Features []*SearchboxReverseFeature `json:"features"` Attribution string `json:"attribution"` }
type Step ¶
type Step struct { Distance float64 `json:"distance"` // The distance for this step in meters. Duration float64 `json:"duration"` // The estimated travel time for this step in seconds. Geometry string `json:"geometry"` // An encoded polyline string or GeoJSON LineString representing the step geometry. Name string `json:"name"` // The name of the road or path used in the step. Maneuver Maneuver `json:"maneuver"` // The maneuver required to move from this step to the next. Mode string `json:"mode"` // The travel mode of the step. Weight float64 `json:"weight"` // Similar to duration but includes additional factors like traffic. Intersections []Intersection `json:"intersections"` // An array of Intersection objects. }
Step represents a single step in a leg of a route, containing maneuver instructions and distance/duration.
type ViaWaypoint ¶
type VoiceInstruction ¶
type VoiceInstruction struct { DistanceAlongGeometry float64 `json:"distanceAlongGeometry"` // The distance from the current step at which to provide the instruction. Announcement string `json:"announcement"` // The verbal instruction. SSMLAnnouncement string `json:"ssmlAnnouncement"` // The instruction in SSML format for text-to-speech engines. }
VoiceInstruction represents a single voice instruction for navigation.
type VoiceUnits ¶
type VoiceUnits string
type WaypointName ¶
type WaypointName string
type WaypointNames ¶
type WaypointNames []WaypointName
type WaypointTarget ¶
type WaypointTarget string
type WaypointTargets ¶
type WaypointTargets []WaypointTarget