// Direction gets the direction in human readable string format
515718
func (k *Key) Direction() string {
	switch k.Dir {
	case dirIngress:
		return direction[k.Dir]
	case dirEgress:
		return direction[k.Dir]
	}
	return direction[dirUnknown]
}
196732
func (route *Route) String() string {
	return fmt.Sprintf("[%d/%d] %s -> %s",
		route.priority, route.distance, route.value, route.gate.name)
}
1077899
func (app *App) HEAD(route string, handler interface{}) *App {
	app.defaultRouter.Handle(MethodHEAD, route, handler)
	return app
}
1134579
func (q Quad) GetString(d Direction) string {
	switch d {
	case Subject:
		return StringOf(q.Subject)
	case Predicate:
		return StringOf(q.Predicate)
	case Object:
		return StringOf(q.Object)
	case Label:
		return StringOf(q.Label)
	default:
		panic(d.String())
	}
}
1350976
func NewDirections(from string, to []string) *Directions {
	return &Directions{
		From:                       from,
		To:                         to,
		Unit:                       "m",
		RouteType:                  "fastest",
		DoReverseGeocode:           true,
		NarrativeType:              "text",
		EnhancedNarrative:          false,
		MaxLinkID:                  0,
		Locale:                     "en_US",
		StateBoundaryDisplay:       true,
		CountryBoundaryDisplay:     true,
		DestinationManeuverDisplay: true,
		FullShape:                  false,
		CyclingRoadFactor:          1,
		RoadGradeStrategy:          "DEFAULT_STRATEGY",
		DrivingStyle:               "normal",
		HighwayEfficiency:          22,
		ManMaps:                    true,
		WalkingSpeed:               -1, // 2.5
		SessionID:                  "",
	}
}
451421
func (l *Line) String() string {
	return fmt.Sprintf("LINESTRING(%g %g,%g %g)", l.a[0], l.a[1], l.b[0], l.b[1])
}
587338
func (p Position) String() string {
	_prefix := ""
	if p.File != "" {
		_prefix = p.File + ": "
	}

	if p.Line == 0 {
		return fmt.Sprintf("%s+%d", _prefix, p.Offset)
	} else if p.Column == 0 {
		return fmt.Sprintf("%s%d", _prefix, p.Line)
	} else {
		return fmt.Sprintf("%s%d:%d", _prefix, p.Line, p.Column)
	}
}
432529
func (op *DTGPIOModuleOpenPin) gpioDirection(dir string) error {
	if dir != "in" && dir != "out" {
		return errors.New("direction must be in or out")
	}
	f := op.gpioBaseName + "/direction"
	e := WriteStringToFile(f, dir)

	mode := os.O_WRONLY | os.O_TRUNC
	if dir == "in" {
		mode = os.O_RDONLY
	}

	// open the value file with the correct mode. Put that file in 'op'. Note that we keep this file open
	// continuously for performance.
	// Preliminary tests on 200,000 DigitalWrites indicate an order of magnitude improvement when we don't have
	// to re-open the file each time. Re-seeking and writing a new value suffices.
	op.valueFile, e = os.OpenFile(op.gpioBaseName+"/value", mode, 0666)

	return e
}
546268
func (l *location) String() string {
	if len(l.File) == 0 {
		return ""
	}

	return fmt.Sprintf("%s:%d", l.File, l.Line)
}
1063115
func Move(x, y int) string {
	//与x;yf相同？
	return "\033[" + strconv.Itoa(x) + ";" + strconv.Itoa(y) + "H"
}
1205808
func (p Primitive) GetDirection(d quad.Direction) uint64 {
	switch d {
	case quad.Subject:
		return p.Subject
	case quad.Predicate:
		return p.Predicate
	case quad.Object:
		return p.Object
	case quad.Label:
		return p.Label
	}
	panic("unknown direction")
}
438514
func (a *Driver) Clockwise(speed int) {
	a.adaptor().drone.Clockwise(speed)
}
1274096
func (e *merryErr) Format(s fmt.State, verb rune) {
	switch verb {
	case 'v':
		if s.Flag('+') {
			io.WriteString(s, Details(e))
			return
		}
		fallthrough
	case 's':
		io.WriteString(s, e.Error())
	case 'q':
		fmt.Fprintf(s, "%q", e.Error())
	}
}
708465
func (directions Directions) URL(format string) string {
	// http://stackoverflow.com/questions/1760757/how-to-efficiently-concatenate-strings-in-go
	var (
		n        int
		routeURL bytes.Buffer
	)
	writeStringInts := func(label string, arrayInts []int) {
		n = len(arrayInts)
		if n > 0 {
			routeURL.WriteString(label)
			for i, number := range arrayInts {
				routeURL.WriteString(strconv.Itoa(number))
				if i < n-1 {
					routeURL.WriteString(",")
				}
			}
		}
	}
	routeURL.WriteString(directionURL)
	routeURL.WriteString(apiKey)
	routeURL.WriteString("&outFormat=" + format)
	routeURL.WriteString("&from=" + url.QueryEscape(directions.From))
	for _, to := range directions.To {
		routeURL.WriteString("&to=" + url.QueryEscape(to))
	}
	routeURL.WriteString("&unit=" + directions.Unit)
	routeURL.WriteString("&routeType" + directions.RouteType)
	routeURL.WriteString("&narrativeType=" + directions.NarrativeType)
	routeURL.WriteString("&enhancedNarrative=" + strconv.FormatBool(directions.EnhancedNarrative))
	routeURL.WriteString("&maxLinkId=" + strconv.Itoa(directions.MaxLinkID))
	routeURL.WriteString("&locale=" + directions.Locale)
	for _, avoids := range directions.Avoids {
		routeURL.WriteString("&avoids=" + url.QueryEscape(avoids))
	}
	writeStringInts("&mustAvoidLinkIds=", directions.MustAvoidLinkIDs)
	writeStringInts("&tryAvoidLinkIds=", directions.TryAvoidLinkIDs)
	routeURL.WriteString("&stateBoundaryDisplay=" + strconv.FormatBool(directions.StateBoundaryDisplay))
	routeURL.WriteString("&countryBoundaryDisplay=" + strconv.FormatBool(directions.CountryBoundaryDisplay))
	routeURL.WriteString("&destinationManeuverDisplay=" + strconv.FormatBool(directions.DestinationManeuverDisplay))
	routeURL.WriteString("&fullShape=" + strconv.FormatBool(directions.FullShape))
	routeURL.WriteString("&cyclingRoadFactor=" + strconv.FormatFloat(directions.CyclingRoadFactor, 'f', -1, 64))
	routeURL.WriteString("&roadGradeStrategy=" + directions.RoadGradeStrategy)
	routeURL.WriteString("&drivingStyle=" + directions.DrivingStyle)
	routeURL.WriteString("&highwayEfficiency=" + strconv.FormatFloat(directions.HighwayEfficiency, 'f', -1, 64))
	routeURL.WriteString("&manMaps=" + strconv.FormatBool(directions.ManMaps))
	routeURL.WriteString("&walkingSpeed=" + strconv.FormatFloat(directions.WalkingSpeed, 'f', -1, 64))
	if directions.SessionID != "" {
		routeURL.WriteString("&sessionId=" + directions.SessionID)
	}
	return routeURL.String()
}
426362
func (l *Line) Reverse() *Line {
	l.a, l.b = l.b, l.a
	return l
}
134237
func (loc *Location) Format(f string, a ...interface{}) string {
	if len(loc.File) > 0 {
		f = fmt.Sprintf("%v:%v: %v", loc.File, loc.Row, f)
	} else {
		f = fmt.Sprintf("%v:%v: %v", loc.Row, loc.Col, f)
	}
	return fmt.Sprintf(f, a...)
}
277599
func (l *WAL) Path() string {
	l.mu.RLock()
	defer l.mu.RUnlock()
	return l.path
}