go_huawei

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 12 Imported by: 0

README

go-huawei

HUAWEI HMS Core Map-kit

Documentation

Index

Constants

View Source
const (
	RouteServiceDriving   = RouteService("driving")
	RouteServiceWalking   = RouteService("walking")
	RouteServiceBicycling = RouteService("bicycling")
)

Travel mode preferences.

View Source
const (
	AvoidTolls    = Avoid(1)
	AvoidHighways = Avoid(2)
)

Features to avoid.

View Source
const (
	TrafficModeBestGuess   = TrafficMode(0)
	TrafficModeOptimistic  = TrafficMode(2)
	TrafficModePessimistic = TrafficMode(1)
)

Traffic prediction model when requesting future directions.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	End             Action = "end"
	ForkLeft        Action = "fork-left"
	ForkRight       Action = "fork-right"
	RampRight       Action = "ramp-right"
	RampLeft        Action = "ramp-left"
	RoundaboutRight Action = "roundabout-right"
	RoundaboutLeft  Action = "roundabout-left"
	Straight        Action = "straight"
	TurnLeft        Action = "turn-left"
	TurnRight       Action = "turn-right"
	TurnSlightLeft  Action = "turn-slight-left"
	TurnSlightRight Action = "turn-slight-right"
)

type Avoid

type Avoid int

Avoid is for specifying routes that avoid certain features.

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...ClientOption) (*Client, error)

func (*Client) Directions

func (c *Client) Directions(ctx context.Context, directionsRequest *DirectionsRequest) ([]Route, error)

Directions issues the Directions request and retrieves the Response

type ClientOption

type ClientOption func(*Client) error

ClientOption is the type of constructor options for NewClient(...).

func WithAPIKey

func WithAPIKey(apiKey string) ClientOption

WithAPIKey configures a Maps API client with an API Key

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL configures a Maps API client with a custom base url

func WithHTTPClient

func WithHTTPClient(c *http.Client) ClientOption

WithHTTPClient configures a Maps API client with a http.Client to make requests over.

func WithMetricReporter

func WithMetricReporter(reporter metrics.Reporter) ClientOption

func WithRateLimit

func WithRateLimit(requestsPerSecond int) ClientOption

WithRateLimit configures the rate limit for back end requests. Default is to limit to 50 requests per second. A value of zero disables rate limiting.

type CommonResponse

type CommonResponse struct {
	ReturnCode ReturnCode `json:"returnCode"`
	ReturnDesc ReturnDesc `json:"returnDesc"`
}

func (*CommonResponse) StatusError

func (c *CommonResponse) StatusError() error

type Coordinate

type Coordinate struct {
	Lng float64 `json:"lng"`
	Lat float64 `json:"lat"`
}

func ParseCoordinate

func ParseCoordinate(str string) *Coordinate

func (*Coordinate) String

func (c *Coordinate) String() string

type CoordinateBounds

type CoordinateBounds struct {
	Southwest Coordinate `json:"southwest"`
	Northeast Coordinate `json:"northeast"`
}

type DirectionsRequest

type DirectionsRequest struct {
	Origin      *Coordinate   `json:"origin"`
	Destination *Coordinate   `json:"destination"`
	Waypoints   []*Coordinate `json:"waypoints,omitempty"`

	//Indicates whether to optimize the waypoint. false (default): no true: yes
	Optimize bool `json:"optimize,omitempty"`

	//Time estimation mode. The options are as follows: 0 (default): best guess 1: The traffic condition is worse than the
	//historical average. 2: The traffic condition is better than the historical average
	TrafficMode TrafficMode `json:"trafficMode,omitempty"`

	// Waypoint type. The options are as follows: false (default): stopover true: via (pass-by)
	ViaType bool `json:"viaType,omitempty"`

	// Indicates whether to return multiple planned routes. The options are as follows: true: yes false (default): no Note:
	//This parameter is unavailable when waypoints are set.
	Alternatives bool `json:"alternatives,omitempty"`

	//Indicates the specified type of roads to be avoided. The options are as follows: 1: Avoid toll roads. 2: Avoid
	//expressways. If this parameter is not included in the request, the route taking the least time will be returned by
	//default
	Avoid []Avoid `json:"avoid,omitempty"`

	//Estimated departure time, in seconds since 00:00 on January 1, 1970 (UTC). The value must be the current time or a
	//future time.
	DepartAt int `json:"departAt,omitempty"`

	// Language of the distance and journey time descriptions in the returned result. Currently, only zh_CN and en are supported
	Language string `json:"language,omitempty"`

	RouteService RouteService `json:"-"`
}

func (*DirectionsRequest) Marshal

func (r *DirectionsRequest) Marshal() ([]byte, error)

type DirectionsResponse

type DirectionsResponse struct {
	Routes []Route `json:"routes"`
	CommonResponse
}

type Distance

type Distance struct {
	// HumanReadable is the human friendly distance. This is rounded and in an
	// appropriate unit for the request. The units can be overridden with a request
	// parameter.
	HumanReadable string `json:"text"`
	// Meters is the numeric distance, always in meters. This is intended to be used
	// only in algorithmic situations, e.g. sorting results by some user specified
	// metric.
	Meters int `json:"value"`
}

Distance is the API representation for a distance between two points.

type Path

type Path struct {
	Duration              float64    `json:"duration"`
	DurationText          string     `json:"durationText"`
	DurationInTrafficText string     `json:"durationInTrafficText"`
	DurationInTraffic     float64    `json:"durationInTraffic"`
	Distance              float64    `json:"distance"`
	StartLocation         Coordinate `json:"startLocation"`
	StartAddress          string     `json:"startAddress"`
	DistanceText          string     `json:"distanceText"`
	Steps                 []Step     `json:"steps"`
	EndLocation           Coordinate `json:"endLocation"`
	EndAddress            string     `json:"endAddress"`
}

func (*Path) Overview

func (p *Path) Overview() []Coordinate

func (*Path) OverviewPolyline

func (p *Path) OverviewPolyline() []byte

type ReturnCode

type ReturnCode string
const (
	// Success
	ReturnCodeOK ReturnCode = "0"
	// Invalid API key or token
	ReturnCodeInvalidAPI ReturnCode = "6"
	// The requested URL is incorrect
	ReturnCodeRequestedURLIncorrect ReturnCode = "5"

	// The authentication service is abnormal
	ReturnCodeInvalidAuth ReturnCode = "010001"
	// Route data does not exist
	ReturnCodeRouteDataDoesNotExist ReturnCode = "010008"
	// Route data does not exist
	ReturnCodeAPICallQuotaUsedUp ReturnCode = "010006"
	// Route data does not exist
	ReturnCodeAuthenticationFailed ReturnCode = "010005"
	// Invalid parameter
	ReturnCodeInvalidRequest ReturnCode = "010010"
	// Invalid parameter
	ReturnCodeUnauthorizedAPICall ReturnCode = "010003"
	// The linear distance between the departure  place and destination exceeds the upper limit.
	ReturnCodeDistanceBetweenExceedsLimit ReturnCode = "010020"

	ReturnCodeInternalServiceError ReturnCode = "110"
)

type ReturnDesc

type ReturnDesc string
const (
	ReturnDescOK             ReturnDesc = "OK"
	ReturnDescInvalidRequest ReturnDesc = "INVALID_REQUEST"
	ReturnDescUnknownError   ReturnDesc = "UNKNOWN_ERROR"
	ReturnDescNotFound       ReturnDesc = "NOT_FOUND"
	ReturnDescZeroResults    ReturnDesc = "ZERO_RESULTS"
	ReturnDescRequestDenied  ReturnDesc = "REQUEST_DENIED"
	ReturnDescOverQueryLimit ReturnDesc = "OVER_QUERY_LIMIT"
)

type Route

type Route struct {
	Paths  []Path           `json:"paths"`
	Bounds CoordinateBounds `json:"bounds"`
}

type RouteService

type RouteService string

RouteService is for specifying travel mode.

type Step

type Step struct {
	Duration      float64      `json:"duration"`
	Orientation   int64        `json:"orientation"`
	DurationText  string       `json:"durationText"`
	Distance      float64      `json:"distance"`
	StartLocation Coordinate   `json:"startLocation"`
	Instruction   string       `json:"instruction"`
	Action        Action       `json:"action"`
	DistanceText  string       `json:"distanceText"`
	EndLocation   Coordinate   `json:"endLocation"`
	Polyline      []Coordinate `json:"polyline"`
	RoadName      string       `json:"roadName"`
}

type TrafficMode

type TrafficMode int

TrafficMode specifies traffic prediction model when requesting future directions.

type TransitMode

type TransitMode string

TransitMode is for specifying a transit mode for a request

Directories

Path Synopsis
examples
directions/cmd command

Jump to

Keyboard shortcuts

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