// Returns the latitude and longitude of the best location match
// for the specified query.
428648
func Geocode(address string) (float64, float64, error) {
	// Query Provider
	resp, err := http.Get(geocodeURL + url.QueryEscape(address) + "&key=" + apiKey)

	if err != nil {
		return 0, 0, fmt.Errorf("Error geocoding address: <%v>", err)
	}

	defer resp.Body.Close()

	// Decode our JSON results
	var result geocodingResults
	err = decoder(resp).Decode(&result)

	if err != nil {
		return 0, 0, fmt.Errorf("Error decoding geocoding result: <%v>", err)
	}

	var lat float64
	var lng float64
	if len(result.Results[0].Locations) > 0 {
		lat = result.Results[0].Locations[0].LatLng.Lat
		lng = result.Results[0].Locations[0].LatLng.Lng
	}

	return lat, lng, nil
}
139125
func (n navigator) Location(resp *http.Response) (navigator, error) {
	_, exists := resp.Header["Location"]
	if !exists {
		return n, fmt.Errorf("Response didn't contain a Location header")
	}
	loc := resp.Header.Get("Location")
	lurl, err := makeAbsoluteIfNecessary(loc, n.rootUri)
	if err != nil {
		return n, err
	}
	return navigator{
		HttpClient: n.HttpClient,
		path:       []relation{},
		rootUri:    lurl,
	}, nil
}
835342
func QuestionLocation(loc string) string {
	if len(loc) == 0 {
		n := rand.Intn(10)
		switch n {
		case 0:
			return "Where are you?"
		case 1:
			return "Where are you now?"
		case 2:
			return "Sure thing. Where are you?"
		case 3:
			return "Sure thing. Where are you now?"
		case 4:
			return "Happy to help. Where are you?"
		case 5:
			return "Happy to help. Where are you now?"
		case 6:
			return "I can help with that. Where are you?"
		case 7:
			return "I can help with that. Where are you now?"
		case 8:
			return "I can help solve this. Where are you?"
		case 9:
			return "I can help solve this. Where are you now?"
		}
	}
	return fmt.Sprintf("Are you still near %s?", loc)
}
561163
func (client *Client) DoSimpleSearch(term, location string) (result SearchResult, err error) {

	// verify the term and location are not empty
	if location == "" {
		return SearchResult{}, errUnspecifiedLocation
	}

	// set up the query options
	params := map[string]string{
		"term":     term,
		"location": location,
	}

	// perform the search request
	_, err = client.makeRequest(searchArea, "", params, &result)
	if err != nil {
		return SearchResult{}, err
	}
	return result, nil
}
463678
func getLocation(browser, libpath string, globalInstall bool) (string, error) {
	if globalInstall {
		return getGlobalLocation(browser, libpath)
	}

	pm, found := manifestPath[runtime.GOOS]
	if !found {
		return "", fmt.Errorf("platform %s is currently not supported", runtime.GOOS)
	}
	path, found := pm[browser]
	if !found {
		return "", fmt.Errorf("browser %s on %s is currently not supported", browser, runtime.GOOS)
	}
	return path, nil
}
609327
func (c cachedGeocoder) Geocode(address string) (*geo.Location, error) {
	// Check if we've cached this response
	if cachedLoc, found := c.Cache.Get(address); found {
		return cachedLoc.(*geo.Location), nil
	}

	if loc, err := c.Geocoder.Geocode(address); err != nil {
		return loc, err
	} else {
		c.Cache.Set(address, loc, 0)
		return loc, nil
	}
}
1045970
func (c *locationCache) getLocation(offset int) *time.Location {
	c.lock.Lock()
	defer c.lock.Unlock()

	location, ok := c.cache[offset]
	if !ok {
		location = time.FixedZone("", offset)
		c.cache[offset] = location
	}

	return location
}
499019
func (buf *TrackedBuffer) ParsedQuery() *ParsedQuery {
	return &ParsedQuery{Query: buf.String(), bindLocations: buf.bindLocations}
}
5055
func GetLocation() (string, string) {
	panicBrowserDetect()
	loc := js.Global.Get("location")
	path := loc.Get("pathname").String()
	hash := loc.Get("hash").String()
	return path, hash
}
222032
func (r Location_Datacenter) GetLocationStatus() (resp datatypes.Location_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Location_Datacenter", "getLocationStatus", nil, &r.Options, &resp)
	return
}
1144922
func (r *bucketLocationCache) Get(bucketName string) (location string, ok bool) {
	r.RLock()
	defer r.RUnlock()
	location, ok = r.items[bucketName]
	return
}
99612
func NewSuggesterGeoQuery(name string, location *GeoPoint) *SuggesterGeoQuery {
	return &SuggesterGeoQuery{
		name:       name,
		location:   location,
		neighbours: make([]string, 0),
	}
}
1254444
func (c cachedGeocoder) ReverseGeocode(lat, lng float64) (*geo.Address, error) {
	// Check if we've cached this response
	locKey := fmt.Sprintf("geo.Location{%f,%f}", lat, lng)
	if cachedAddr, found := c.Cache.Get(locKey); found {
		return cachedAddr.(*geo.Address), nil
	}

	if addr, err := c.Geocoder.ReverseGeocode(lat, lng); err != nil {
		return nil, err
	} else {
		c.Cache.Set(locKey, addr, 0)
		return addr, nil
	}
}
363408
func FullGeocode(address string) (*GeocodingResult, error) {
	// Query Provider
	resp, err := http.Get(geocodeURL + url.QueryEscape(address) + "&key=" + apiKey)

	if err != nil {
		return nil, fmt.Errorf("Error geocoding address: <%v>", err)
	}

	defer resp.Body.Close()

	// Decode our JSON results
	var result GeocodingResult
	err = decoder(resp).Decode(&result)

	if err != nil {
		return nil, fmt.Errorf("Error decoding geocoding result: <%v>", err)
	}

	return &result, nil
}
234335
func (d *database) Query(ctx context.Context, query string, bindVars map[string]interface{}) (Cursor, error) {
	req, err := d.conn.NewRequest("POST", path.Join(d.relPath(), "_api/cursor"))
	if err != nil {
		return nil, WithStack(err)
	}
	input := queryRequest{
		Query:    query,
		BindVars: bindVars,
	}
	input.applyContextSettings(ctx)
	if _, err := req.SetBody(input); err != nil {
		return nil, WithStack(err)
	}
	cs := applyContextSettings(ctx, req)
	resp, err := d.conn.Do(ctx, req)
	if err != nil {
		return nil, WithStack(err)
	}
	if err := resp.CheckStatus(201); err != nil {
		return nil, WithStack(err)
	}
	var data cursorData
	if err := resp.ParseBody("", &data); err != nil {
		return nil, WithStack(err)
	}
	col, err := newCursor(data, resp.Endpoint(), d, cs.AllowDirtyReads)
	if err != nil {
		return nil, WithStack(err)
	}
	return col, nil
}
658865
func (_m *Protocol) GetLocations() ([]common.Location, error) {
	ret := _m.Called()

	var r0 []common.Location
	if rf, ok := ret.Get(0).(func() []common.Location); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]common.Location)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
196552
func PgXlogLocationDiff(db XODB, v0 pgtypes.PgLsn, v1 pgtypes.PgLsn) (float64, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_xlog_location_diff($1, $2)`

	// run query
	var ret float64
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return 0.0, err
	}

	return ret, nil
}