コード例 #1
0
func parseLocation(location string, r *maps.QueryAutocompleteRequest) {
	if location != "" {
		l, err := maps.ParseLatLng(location)
		check(err)
		r.Location = &l
	}
}
コード例 #2
0
func parseLocation(location string, r *maps.TextSearchRequest) {
	if location != "" {
		l, err := maps.ParseLatLng(location)
		check(err)
		r.Location = &l
	}
}
コード例 #3
0
ファイル: main.go プロジェクト: zeroed/alphazerobot
func parseLocation(location string, r *maps.TimezoneRequest) {
	if location != "" {
		l, err := maps.ParseLatLng(location)
		check(err)
		r.Location = &l
	} else {
		usageAndExit("location is required")
	}
}
コード例 #4
0
ファイル: speedlimits.go プロジェクト: zeroed/alphazerobot
// parsePath takes a location argument string and decodes it.
func parsePath(path string, r *maps.SpeedLimitsRequest) {
	if path != "" {
		ls := strings.Split(path, "|")
		for _, l := range ls {
			ll, err := maps.ParseLatLng(l)
			check(err)
			r.Path = append(r.Path, ll)
		}
	}
}
コード例 #5
0
ファイル: snaptoroad.go プロジェクト: zeroed/alphazerobot
// parsePath takes a location argument string and decodes it.
func parsePath(path string, r *maps.SnapToRoadRequest) {
	if path != "" {
		ls := strings.Split(path, "|")
		for _, l := range ls {
			ll, err := maps.ParseLatLng(l)
			check(err)
			r.Path = append(r.Path, ll)
		}
	} else {
		usageAndExit("Path required")
	}
}
コード例 #6
0
ファイル: main.go プロジェクト: zeroed/alphazerobot
// decodeLocations takes a location argument string and decodes it.
// This argument has three different forms, as per documentation at
// https://developers.google.com/maps/documentation/elevation/#Locations
func decodeLocations(location string) ([]maps.LatLng, error) {
	if strings.HasPrefix(location, "enc:") {
		return maps.DecodePolyline(location[len("enc:"):]), nil
	}

	if strings.Contains(location, "|") {
		return maps.ParseLatLngList(location)
	}

	// single location
	ll, err := maps.ParseLatLng(location)
	check(err)
	return []maps.LatLng{ll}, nil
}
コード例 #7
0
ファイル: main.go プロジェクト: zeroed/alphazerobot
// decodePath takes a location argument string and decodes it.
// This argument has two different forms, as per documentation at
// https://developers.google.com/maps/documentation/elevation/#Paths
func decodePath(path string) ([]maps.LatLng, error) {
	if strings.HasPrefix(path, "enc:") {
		return maps.DecodePolyline(path[len("enc:"):]), nil
	}
	result := []maps.LatLng{}
	if strings.Contains(path, "|") {
		// | delimited list of locations
		ls := strings.Split(path, "|")
		for _, l := range ls {
			ll, err := maps.ParseLatLng(l)
			check(err)
			result = append(result, ll)
		}
		return result, nil
	}
	return result, fmt.Errorf("Invalid Path argument: '%s'", path)
}