Retrieve location coordinates from an address introduced.
346778
def get_location(address=""):
    
    coordinates = None
    try:
        geolocator = Nominatim()
        location = geolocator.geocode(address)
        coordinates = (location.latitude, location.longitude)
    except Exception as ex:
        logger.error('Fail get location - {}'.format(ex))
    return coordinates
1244039
def address(obj):
    """'"""
    return "<%s @ %s>" % (obj.__class__.__name__,
                          hex(id(obj)).upper().replace('X', 'x'))
331114
def from_location(cls, location):
        
        if not location:
            return cls()
        try:
            if hasattr(location, 'isLocation'):
                # Ladybug location
                return location

            elif hasattr(location, 'Latitude'):
                # Revit's location
                return cls(city=str(location.Name.replace(",", " ")),
                           latitude=location.Latitude,
                           longitude=location.Longitude)

            elif location.startswith('Site:'):
                loc, city, latitude, longitude, time_zone, elevation = \
                    [x.strip() for x in re.findall(r'\r*\n*([^\r\n]*)[,|;]',
                                                   location, re.DOTALL)]
            else:
                try:
                    city, latitude, longitude, time_zone, elevation = \
                        [key.split(":")[-1].strip()
                         for key in location.split(",")]
                except ValueError:
                    # it's just the city name
                    return cls(city=location)

            return cls(city=city, country=None, latitude=latitude,
                       longitude=longitude, time_zone=time_zone,
                       elevation=elevation)

        except Exception as e:
            raise ValueError(
                "Failed to create a Location from %s!\n%s" % (location, e))
897398
def location(self) -> Optional[PostLocation]:
        """"""
        loc = self._field("location")
        if self._location or not loc:
            return self._location
        location_id = int(loc['id'])
        if any(k not in loc for k in ('name', 'slug', 'has_public_page', 'lat', 'lng')):
            loc = self._context.get_json("explore/locations/{0}/".format(location_id),
                                         params={'__a': 1})['graphql']['location']
        self._location = PostLocation(location_id, loc['name'], loc['slug'], loc['has_public_page'],
                                      loc['lat'], loc['lng'])
        return self._location
1152038
def geocode(self, address_data, **kwargs):
        
        if isinstance(address_data, list):
            return self.batch_geocode(address_data, **kwargs)

        return self.geocode_address(address_data, **kwargs)
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()
1257594
def get_coordinates_by_full_name(self, name):
        """"""
        person = self.get_person_by_full_name(name)
        if not person:
            return '', ''
        return person.latitude, person.longitude
1357224
def geo_location(ip_address):
    """"""
    try:
        type(ipaddress.ip_address(ip_address))
    except ValueError:
        return {}

    data = requests.get(
        'https://ipapi.co/{}/json/'.format(ip_address), timeout=5).json()
    return data
856097
def get(location, **kwargs):
    
    provider = kwargs.get('provider', 'bing').lower().strip()
    method = kwargs.get('method', 'geocode').lower().strip()
    if isinstance(location, (list, dict)) and method == 'geocode':
        raise ValueError("Location should be a string")

    if provider not in options:
        raise ValueError("Invalid provider")

    else:
        if method not in options[provider]:
            raise ValueError("Invalid method")
    return options[provider][method](location, **kwargs)
114470
def _get_location(self, regions, datacenter):
        """"""
        for region in regions:
            # list of locations
            if region['location']['location']['name'] == datacenter:
                return region

        raise SoftLayer.SoftLayerError("Could not find valid location for: '%s'" % datacenter)
498899
def address(self):
        """"""
        path = urlsplit(self.target).path
        suffix = '/' if not path or path.endswith('/') else ''
        return '%s%s/%s%s' % (self._ui_address[:-1], self._proxy_prefix,
                              self.route, suffix)
754089
function geoGetCoords($address,$depth=0) {
	    $_coords = false;
        switch($this->lookup_service) {
            case 'GOOGLE':
                $_url = sprintf('http://%s/maps/api/geocode/json?sensor=%s&address=%s',$this->lookup_server['GOOGLE'], $this->mobile==true?"true":"false", rawurlencode($address));
                if($_result = $this->fetchURL($_url)) {
                    $_result_parts = json_decode($_result);
                    if($_result_parts->status!="OK"){
                    	return false;
                    }
                    $_coords['lat'] = $_result_parts->results[0]->geometry->location->lat;
                    $_coords['lon'] = $_result_parts->results[0]->geometry->location->lng;
                }
                break;
            case 'YAHOO':
            default:        
                $_url = sprintf('http://%s/MapsService/V1/geocode?appid=%s&location=%s',$this->lookup_server['YAHOO'],$this->app_id,rawurlencode($address));
                if($_result = $this->fetchURL($_url)) {
                    preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U', $_result, $_match);
                    $_coords['lon'] = $_match[2];
                    $_coords['lat'] = $_match[1];
                }
                break;
        }         
        return $_coords;       
    }
361715
def parse_sitelist(sitelist):
    """"""
    sites = []
    for site in sitelist["Locations"]["Location"]:
        try:
            ident = site["id"]
            name = site["name"]
        except KeyError:
            ident = site["@id"] # Difference between loc-spec and text for some reason
            name = site["@name"]
        if "latitude" in site:
            lat = float(site["latitude"])
            lon = float(site["longitude"])
        else:
            lat = lon = None
        s = Site(ident, name, lat, lon)
        sites.append(s)
    return sites
777517
def getDetails(self, ip_address=None):
        """"""
        raw_details = self._requestDetails(ip_address)
        raw_details['country_name'] = self.countries.get(raw_details.get('country'))
        raw_details['ip_address'] = ipaddress.ip_address(raw_details.get('ip'))
        raw_details['latitude'], raw_details['longitude'] = self._read_coords(raw_details.get('loc'))
        return Details(raw_details)
969989
def get_grid_point_from_address(grid_address, mesh):
    """"""
    _set_no_error()

    return spg.grid_point_from_address(np.array(grid_address, dtype='intc'),
                                       np.array(mesh, dtype='intc'))
172493
public static LocationModel getLocationByCoordinates(Double latitude, Double longitude ){
        try {
            Geocoder geocoder;
            List<Address> addresses;
            geocoder = new Geocoder(QuickUtils.getContext());
            addresses = geocoder.getFromLocation(latitude, longitude, 1);

            LocationModel locationModel = new LocationModel();
            locationModel.latitude = latitude;
            locationModel.longitude = longitude;
            try{
                locationModel.address = addresses.get(0).getAddressLine(0);
            }catch(Exception ex){
                QuickUtils.log.e("empty address");
            }
            try{
                locationModel.city = addresses.get(0).getAddressLine(1);
            }catch(Exception ex){
                QuickUtils.log.e("empty city");
            }
            try{
                locationModel.country = addresses.get(0).getAddressLine(2);
            }catch(Exception ex){
                QuickUtils.log.e("empty country");
            }

            return locationModel;
        } catch (IOException e) {
            QuickUtils.log.e("empty location");
            return new LocationModel();
        }
    }
1316146
function findStoresInRangeAddress(address, range, callback) {
  range = range || 3;

  geo.geocode(address, function(err, georesult) {
    if (err) return callback(err);
    findStoresInRange(georesult, range, callback);
  });
}