Pretty-print address and return lat, lon tuple.
963558
def _format_structured_address(address):
        
        latitude = address['metadata'].get('latitude')
        longitude = address['metadata'].get('longitude')
        return Location(
            ", ".join((address['delivery_line_1'], address['last_line'])),
            (latitude, longitude) if latitude and longitude else None,
            address
        )
1025230
def _format_lon(self, lon):
        '''  '''

        lonf = self._map_center('long', lon)
        st = str(lonf).split('.')
        loncenter = ''.join(("{0:0>3}".format(st[0]), st[1]))
        return loncenter
1186531
def distance_to(self, address, measure="Miles", httpclient=None):
        
        if isinstance(address, Address) and self.latlng and address.latlng:
            lat1, lon1 = map(float, self.latlng)
            lat2, lon2 = map(float, address.latlng)
        elif self.latlng and type(address) is tuple:
            lat1, lon1 = map(float, self.latlng)
            lat2, lon2 = address
        else:
            raise ValueError(":address must be type tuple or Address")
            
        radius = 6371 # km          
        dlat = math.radians(lat2 - lat1)
        dlon = math.radians(lon2 - lon1)
        a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) \
          * math.cos(math.radians(lat2)) * math.sin(dlon / 2) * math.sin(dlon / 2)
        c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
        d = radius * c
        # d is in kilometers
        if measure == self.KILOMETERS:
            return d
        elif measure == self.METERS:
            return d / 1000
        elif measure == self.MILES:
            return d * .621371
        else:
            return d
1211327
def _get_addresses(self, text):
        ''''''
        # find addresses
        addresses = []
        matches = utils.findall(
            self.rules,
            text,
            flags=re.VERBOSE | re.U)

        if(matches):
            for match in matches:
                addresses.append(match[0].strip())
        return addresses
970777
def pretty_str(p, decimal_places=2, print_zero=True, label_columns=False):
    ''''''
    if len(p.shape) == 1:
        return vector_str(p, decimal_places, print_zero)
    if len(p.shape) == 2:
        return matrix_str(p, decimal_places, print_zero, label_columns)
    raise Exception('Invalid array with shape {0}'.format(p.shape))
1299999
def _get_geocoding(self, key, location):
        """"""

        url = self._location_query_base % quote_plus(key)
        if self.api_key:
            url += "&key=%s" % self.api_key
        data = self._read_from_url(url)
        response = json.loads(data)
        if response["status"] == "OK":
            formatted_address = response["results"][0]["formatted_address"]
            pos = formatted_address.find(",")
            if pos == -1:
                location.name = formatted_address
                location.region = ""
            else:
                location.name = formatted_address[:pos].strip()
                location.region = formatted_address[pos + 1 :].strip()

            geo_location = response["results"][0]["geometry"]["location"]
            location.latitude = float(geo_location["lat"])
            location.longitude = float(geo_location["lng"])
        else:
            raise AstralError("GoogleGeocoder: Unable to locate %s. Server Response=%s" %
                              (key, response["status"]))
437335
def address(self):
		""
		_ = struct.pack('L', self.address_num)
		return struct.unpack('!L', _)[0]
29289
def address_to_coords(self, address):
        """"""

        base_coords = self.BASE_COORDS[self.region]
        get_cord = self.COORD_SERVERS[self.region]
        url_options = {
            "q": address,
            "lang": "eng",
            "origin": "livemap",
            "lat": base_coords["lat"],
            "lon": base_coords["lon"]
        }

        response = requests.get(self.WAZE_URL + get_cord, params=url_options, headers=self.HEADERS)
        for response_json in response.json():
            if response_json.get('city'):
                lat = response_json['location']['lat']
                lon = response_json['location']['lon']
                bounds = response_json['bounds']  # sometimes the coords don't match up
                if bounds is not None:
                    bounds['top'], bounds['bottom'] = max(bounds['top'], bounds['bottom']), min(bounds['top'], bounds['bottom'])
                    bounds['left'], bounds['right'] = min(bounds['left'], bounds['right']), max(bounds['left'], bounds['right'])
                else:
                    bounds = {}
                return {"lat": lat, "lon": lon, "bounds": bounds}
        raise WRCError("Cannot get coords for %s" % address)
456340
def _write_lat_lon(data_out_nc, rivid_lat_lon_z_file):
        
        # only add if user adds
        if rivid_lat_lon_z_file and os.path.exists(rivid_lat_lon_z_file):
            # get list of COMIDS
            lookup_table = np.loadtxt(
                rivid_lat_lon_z_file,
                delimiter=",",
                usecols=(0, 1, 2),
                skiprows=1,
                dtype={
                    'names': ('rivid', 'lat', 'lon'),
                    'formats': ('i8', 'f8', 'f8'),
                },
            )

            # Get relevant arrays while we update them
            nc_rivids = data_out_nc.variables['rivid'][:]
            lats = data_out_nc.variables['lat'][:]
            lons = data_out_nc.variables['lon'][:]

            lat_min = None
            lat_max = None
            lon_min = None
            lon_max = None

            # Process each row in the lookup table
            for nc_index, nc_rivid in enumerate(nc_rivids):
                try:
                    lookup_index = \
                        np.where(lookup_table['rivid'] == nc_rivid)[0][0]
                except Exception:
                    raise Exception('rivid {0} misssing in '
                                    'comid_lat_lon_z file'.format(nc_rivid))

                lat = float(lookup_table['lat'][lookup_index])
                lats[nc_index] = lat
                if lat_min is None or lat < lat_min:
                    lat_min = lat
                if lat_max is None or lat > lat_max:
                    lat_max = lat

                lon = float(lookup_table['lon'][lookup_index])
                lons[nc_index] = lon
                if lon_min is None or lon < lon_min:
                    lon_min = lon
                if lon_max is None or lon > lon_max:
                    lon_max = lon

            # Overwrite netCDF variable values
            data_out_nc.variables['lat'][:] = lats
            data_out_nc.variables['lon'][:] = lons

            # Update metadata
            if lat_min is not None:
                data_out_nc.geospatial_lat_min = lat_min
            if lat_max is not None:
                data_out_nc.geospatial_lat_max = lat_max
            if lon_min is not None:
                data_out_nc.geospatial_lon_min = lon_min
            if lon_max is not None:
                data_out_nc.geospatial_lon_max = lon_max
        else:
            print('No comid_lat_lon_z file. Not adding values ...')
719179
def onelineaddress(self, address, **kwargs):
        '''
        '''
        fields = {
            'address': address,
        }

        return self._fetch('onelineaddress', fields, **kwargs)
1251556
def geocode(lat, lon, options = {})
      new(options.merge(lat: lat, lon: lon)).retrieve
    end
901764
def lonlat2xyz(lon, lat):
    """"""
    lat = xu.deg2rad(lat)
    lon = xu.deg2rad(lon)
    x = xu.cos(lat) * xu.cos(lon)
    y = xu.cos(lat) * xu.sin(lon)
    z = xu.sin(lat)
    return x, y, z
1120683
def pretty_print_list(lst, name = 'features', repr_format=True):
    
    if not lst or len(lst) < 8:
        if repr_format:
            return lst.__repr__()
        else:
            return ', '.join(map(str, lst))
    else:
        topk = ', '.join(map(str, lst[:3]))
        if repr_format:
            lst_separator = "["
            lst_end_separator = "]"
        else:
            lst_separator = ""
            lst_end_separator = ""

        return "{start}{topk}, ... {last}{end} (total {size} {name})".format(\
                topk = topk, last = lst[-1], name = name, size = len(lst),
                start = lst_separator, end = lst_end_separator)
80641
def location_check(lat, lon):
        """"""
        if not (isinstance(lat, number_types) and -90 <= lat <= 90):
            raise ValueError("Latitude: '{latitude}' invalid".format(latitude=lat))

        if not (isinstance(lon, number_types) and -180 <= lon <= 180):
            raise ValueError("Longitude: '{longitude}' invalid".format(longitude=lon))
1128110
def getaddress(self, address: str) -> dict:
        ''''''

        return cast(dict, self.ext_fetch('getaddress/' + address))
166906
def output(value, address):
    '''
    
    '''
    script = addr.to_output_script(address)
    value = utils.i2le_padded(value, 8)
    return tb._make_output(value, script)
577174
def getPrintAddress(self):
        
        address_lines = []

        addresses = [
            self.getPostalAddress(),
            self.getPhysicalAddress(),
            self.getBillingAddress(),
        ]

        for address in addresses:
            city = address.get("city", "")
            zip = address.get("zip", "")
            state = address.get("state", "")
            country = address.get("country", "")

            if city:
                address_lines = [
                    address["address"].strip(),
                    "{} {}".format(city, zip).strip(),
                    "{} {}".format(state, country).strip(),
                ]
                break

        return address_lines