func SearchNearestStations() {

	if len(os.Args) < 3 {
		fmt.Println("Try nearest <lat>,<lon>")
		return
	}

	latlon := strings.Split(os.Args[2], ",")
	if len(latlon) != 2 {
		fmt.Println("Try nearest <lat>,<lon>")
		return
	}
	coords := [2]float64{}
	for i, c := range latlon {
		coords[i], _ = strconv.ParseFloat(c, 64)
	}

	x, y := openapi.GeodeticToGrid(coords[0], coords[1])

	api := openapi.NewOpenAPI()

	result, err := api.NearestStation(x, y, 1000)
	if err != nil {
		fmt.Println(err)
		return
	}

	PrintNearestStopAreas(result.NearestStopAreas)
}
예제 #2
0
func GetApiClient(req *http.Request) (api openapi.OpenApi) {

	c := appengine.NewContext(req)
	client := urlfetch.Client(c)

	api = openapi.NewOpenAPI()
	api.SetHTTPClient(client)
	return api
}
func SearchStation() {

	if len(os.Args) < 3 {
		fmt.Println("Try search <query>")
		return
	}

	q := os.Args[2]

	api := openapi.NewOpenAPI()

	result, err := api.QueryStation(q)
	if err != nil {
		fmt.Println(err)
		return
	}

	PrintPoints(result.StartPoints)
}
func SearchStartEndPoints() {

	if len(os.Args) < 4 {
		fmt.Println("Try points <start> <end>")
		return
	}

	start := os.Args[2]
	end := os.Args[3]

	api := openapi.NewOpenAPI()

	result, err := api.QueryPage(start, end)
	if err != nil {
		fmt.Println(err)
		return
	}

	PrintPoints(result.StartPoints)
	PrintPoints(result.EndPoints)

}