Fetch visitor country & region

REST: POST /me/geolocation
18399
public OvhContinentCountryLocation geolocation_POST() throws IOException {
		String qPath = "/me/geolocation";
		StringBuilder sb = path(qPath);
		String resp = execN(qPath, "POST", sb.toString(), null);
		return convertTo(resp, OvhContinentCountryLocation.class);
	}
1185427
public SetAnyLocationsResponse postAnyLocations(String region, SettingsData data) throws ApiException {
        ApiResponse<SetAnyLocationsResponse> resp = postAnyLocationsWithHttpInfo(region, data);
        return resp.getData();
    }
800353
def modLocationPort(self, location):
        
        components = urlparse.urlparse(location)
        reverse_proxy_port = self.father.getHost().port
        reverse_proxy_host = self.father.getHost().host
        # returns an ordered dict of urlparse.ParseResult components
        _components = components._asdict()
        _components['netloc'] = '%s:%d' % (
            reverse_proxy_host, reverse_proxy_port
        )
        return urlparse.urlunparse(_components.values())
34112
def render_post_field_geolocalization(post_field, key)
      value_object = post_field.value ? eval(post_field.value) : nil
      render(
        'lato_blog/back/post_fields/fields/geolocalization',
        post_field: post_field,
        key: key,
        lat: value_object ? value_object[:lat] : nil,
        lng: value_object ? value_object[:lng] : nil,
        address: value_object ? value_object[:address] : nil
      )
    end
864606
def fetch(self, endpoint, data = None):
        
        payload = {
            "lastServerChangeId": "-1",
            "csrf": self.__csrf,
            "apiClient": "WEB"
        }
        if data is not None:
            payload.update(data)

        return self.post(endpoint, payload)
917771
def _querystring(self):
        """"""

        kw = {"studyoid": self.studyoid}
        if self.location_oid is not None:
            kw["locationoid"] = self.location_oid
        return kw
711455
def GetLocation(session=None):
        
        if session is not None:
            return session['location']

        if not clc.LOCATION:  clc.v2.API._Login()
        return(clc.LOCATION)
1088820
def geo(*params):
    
    api = 'http://www.gpsspg.com/apis/maps/geo/'
    headers = {
        'Accept':'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
        'Accept-Encoding':'gzip, deflate',
        'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
        'Cookie':'ARRAffinity=7996acd7385beb55da51ad553ab9df60d6b742a8d0840faa612d0bd27f840017; Hm_lvt_15b1a40a8d25f43208adae1c1e12a514=1507564728; Hm_lpvt_15b1a40a8d25f43208adae1c1e12a514=1507564728; AJSTAT_ok_pages=1; AJSTAT_ok_times=1',
        'Host':'www.gpsspg.com',
        'Referer':'http://www.gpsspg.com/iframe/maps/qq_161128.htm?mapi=2',
        'User-Agent': random_user_agent(),
        'X-Requested-With':'XMLHttpRequest',
    }
    query_params = {
        'output': 'jsonp',
        'lat': params[0],
        'lng': params[1],
        'type': '0',
        'callback': 'jQuery110207091189337888508_1507564728439',
        '_': int(get_current_timestamp()),
    }
    http = HTTP()
    t, h, c, hi, s = http.get(api, headers=headers, params=query_params)
    rp = ReParser()
    real_data = rp.compute(r'address":".*","rids', t).replace('address":"', '').replace('","rids', '')
    return real_data
11260
def location(ip=None, key=None, field=None):
    '''  
    '''

    if field and (field not in field_list):
        return 'Invalid field'

    if field:
        if ip:
            url = 'https://ipapi.co/{}/{}/'.format(ip, field)
        else:
            url = 'https://ipapi.co/{}/'.format(field)
    else:
        if ip:
            url = 'https://ipapi.co/{}/json/'.format(ip)
        else:
            url = 'https://ipapi.co/json/'

    if key or API_KEY:
        url = '{}?key={}'.format(url, (key or API_KEY))

    response = get(url, headers=headers)

    if field:
        return response.text
    else:
        return response.json()
227702
private static function _latLngFromAddress_Here ($token, $address, $country)
	{
		$url = 'https://geocoder.api.here.com/6.2/geocode.json';
		$url .= '?app_id=' . $token['appId'];
		$url .= '&app_code=' . $token['appCode'];
		$url .= '&language=' . \Craft::$app->locale->getLanguageID();
		$url .= '&searchtext=' . rawurlencode($address);

		if ($country !== null)
		{
			if (static::_validateCountryCode($country))
				$url .= '&country=' . rawurlencode(strtoupper($country));
			else
				$url .= rawurlencode(', ' . $country);
		}

		$data = (string) static::_client()->get($url)->getBody();
		$data = Json::decodeIfJson($data);

		if (!is_array($data) || empty($data['Response']['View']))
			return null;

		$pos = $data['Response']['View'][0]['Result'][0]['Location']['DisplayPosition'];

		return [
			'lat' => $pos['Latitude'],
			'lng' => $pos['Longitude'],
		];
	}
870829
def get_country(self):
        """"""

        doc = self._request(self.ws_prefix + ".getInfo", True)

        country = _extract(doc, "country")

        if country is None or country == "None":
            return None
        else:
            return Country(country, self.network)
687773
function ( ) {
			if ( ! options.exist ) {
				// http request to Nominatim to performs the Geocoding of the pin.
				// To avoid to much call to Nominatim with the same position,
				// the call is only performed when it's a new pin
				var NominatimUrl = 
					'http://nominatim.openstreetmap.org/reverse?format=json&lat=' +
					latlng.lat +
					'&lon=' +
					latlng.lng +
					'&zoom=' +
					Map.getZoom ( ) +
					'&addressdetails=1&accept-language=' +
					_Translator.UserLanguage +
					'&osm_type=W';
				var XmlHttpRequest = new XMLHttpRequest ( );
				XmlHttpRequest.onreadystatechange = function ( ) { 
					if ( XmlHttpRequest.readyState == 4 && XmlHttpRequest.status == 200 ) {
						_NominatimCallback ( XmlHttpRequest.responseText );
					}
				};  
				XmlHttpRequest.open ( "GET", NominatimUrl, true );
				XmlHttpRequest.send ( null );
			}
		}
502829
def get_data(self):
        """"""
        url = self.build_url()
        self.locationApiData = requests.get(url)
        if not self.locationApiData.status_code == 200:
            raise self.locationApiData.raise_for_status()
871623
function (position) {
			this.writeDebug('autoGeocodeQuery',arguments);
			var _this = this,
				distance = null,
				$distanceInput = $('#' + this.settings.maxDistanceID),
				originAddress;

			// Query string parameters
			if (this.settings.querystringParams === true) {
				// Check for distance query string parameters
				if (this.getQueryString(this.settings.maxDistanceID)){
					distance = this.getQueryString(this.settings.maxDistanceID);

					if ($distanceInput.val() !== '') {
						distance = $distanceInput.val();
					}
				}
				else{
					// Get the distance if set
					if (this.settings.maxDistance === true) {
						distance = $distanceInput.val() || '';
					}
				}
			}
			else {
				// Get the distance if set
				if (this.settings.maxDistance === true) {
					distance = $distanceInput.val() || '';
				}
			}

			// The address needs to be determined for the directions link
			var r = new this.reverseGoogleGeocode(this);
			var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
			r.geocode({'latLng': latlng}, function (data) {
				if (data !== null) {
					originAddress = addressInput = data.address;
					olat = mappingObj.lat = position.coords.latitude;
					olng = mappingObj.lng = position.coords.longitude;
					mappingObj.origin = originAddress;
					mappingObj.distance = distance;
					_this.mapping(mappingObj);

					// Fill in the search box.
					if (typeof originAddress !== 'undefined') {
						$('#' + _this.settings.addressID).val(originAddress);
					}
				} else {
					// Unable to geocode
					_this.notify(_this.settings.addressErrorAlert);
				}
			});
		}
251677
public static GeoLocationRequest getHttpServletRequestGeoLocation(final HttpServletRequest servletRequest) {
        if (servletRequest != null) {
            return HttpRequestUtils.getHttpServletRequestGeoLocation(servletRequest);
        }
        return null;
    }
983356
function makeLocation(req, origin) {
  var protocol = !!req.connection.verifyPeer ? 'https://' : 'http://',
      reqOrigin = origin || (protocol + req.headers.host);
  return url.parse(reqOrigin + req.originalUrl);
}
1050699
function(responseObject) {
                var location = this._getLocationHeader(responseObject);
                return location ? location.substr(location.lastIndexOf('/') + 1) : undefined;
            }