get the geocode lat/lon points from given address
look in cache first, otherwise get from Yahoo

@param string $address
@return array GeoCode information
559612
function getGeocode($address) {
        if(empty($address))
            return false;
        $_geocode = false;  
        if(($_geocode = $this->getCache($address)) === false) {
        	if(($_geocode = $this->geoGetCoords($address)) !== false) {
            	$this->putCache($address, $_geocode['lon'], $_geocode['lat']);
            }
        }
        return $_geocode;
    }
785753
public function getCoordinatesForAddress($street = null, $zip = null, $city = null, $country = ''): array
    {
        $addressParts = [];
        foreach ([$street, $zip . ' ' . $city, $country] as $addressPart) {
            if (empty($addressPart)) {
                continue;
            }
            $addressParts[] = trim($addressPart);
        }
        $address = ltrim(implode(',', $addressParts), ',');
        if (empty($address)) {
            return [];
        }
        $cacheObject = $this->initializeCache();
        $cacheKey = 'geocode-' . strtolower(str_replace(' ', '-', preg_replace('/[^0-9a-zA-Z ]/m', '', $address)));
        // Found in cache? Return it.
        if ($cacheObject->has($cacheKey)) {
            return $cacheObject->get($cacheKey);
        }
        $result = $this->getApiCallResult(
            $this->geocodingUrl . '&address=' . urlencode($address)
        );
        if (empty($result) || empty($result['results']) || empty($result['results'][0]['geometry'])) {
            return [];
        }
        $geometry = $result['results'][0]['geometry'];
        $result = [
            'latitude' => $geometry['location']['lat'],
            'longitude' => $geometry['location']['lng'],
        ];
        // Now store the $result in cache and return
        $cacheObject->set($cacheKey, $result, [], $this->cacheTime);
        return $result;
    }
35838
private function justAddress($address)
    {
        if (($pos = strpos($address, '<')) === false) {
            return $address;
        }

        $n = strlen($address);
        if ($address[$n - 1] == '>') {
            $address = substr($address, $pos + 1, -1);
        }

        return $address;
    }
226018
public function retrieve($address) {
		/** @var \Geo\Model\Entity\GeocodedAddress $entity */
		$entity = $this->find()->where(['address' => $address])->first();
		if ($entity) {
			return $entity;
		}

		$result = $this->_execute($address);
		$address = $this->newEntity([
			'address' => $address
		]);
		if ($result) {
			$address->lat = $result->getLatitude();
			$address->lng = $result->getLongitude();
			$address->country = $result->getCountry()->getCode();

			$formatter = new StringFormatter();
			$address->formatted_address = $formatter->format($result, '%S %n, %z %L');
			$address->data = $result;
		}

		return $this->save($address);
	}
1271302
public function geocode($address)
    {
        $query = $this->buildQuery('address', $address);

        $response = $this->validateResponse(
            $this->getResponse($query)
        );

        return $this->buildResults($response['results']);
    }
108171
public function geocodeAddress($address)
	{
		$url = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' . urlencode($address);
		$response = $this->http->get($url);

		if ($response->code < 200 || $response->code >= 300)
		{
			throw new RuntimeException('Error code ' . $response->code . ' received geocoding address: ' . $response->body . '.');
		}

		$data = json_decode($response->body, true);

		if (!$data)
		{
			throw new RuntimeException('Invalid json received geocoding address: ' . $response->body . '.');
		}

		if ($data['status'] != 'OK')
		{
			return null;
		}

		return $data['results'][0];
	}
788372
public function getPathForAddress($address) {
        $decoded = $this->addressReader->fromString($address);
        if ($decoded instanceof CashAddress) {
            $address = $decoded->getLegacyAddress();
        }

        return $this->sdk->getPathForAddress($this->identifier, $address);
    }
913093
protected function getComplement(array $address)
    {
        $complement = [];

        if (array_key_exists('complemento', $address)) {
            $complement[] = $address['complemento'];
        }

        if (array_key_exists('complemento2', $address)) {
            $complement[] = $address['complemento2'];
        }

        return $complement;
    }
565116
public function trimAddress($address)
    {
        $address = trim($address);

        return (($address[0] == '<') && (substr($address, -1) == '>'))
            ? substr($address, 1, -1)
            : $address;
    }
764753
public function address($address) {
        $response = $this->dataClient->get($this->converter->getUrlForAddress($address));
        return $this->converter->convertAddress($response->body());
    }
722672
function getCache($address) {
        if(!isset($this->dsn))
            return false;
        
        $_ret = array();
        
        // PEAR DB
        require_once('DB.php');          
        $_db =& DB::connect($this->dsn);
        if (PEAR::isError($_db)) {
            die($_db->getMessage());
        }
        $_res =& $_db->query("SELECT lon,lat FROM {$this->_db_cache_table} where address = ?", $address);
        if (PEAR::isError($_res)) {
            die($_res->getMessage());
        }
        if($_row = $_res->fetchRow()) {            
            $_ret['lon'] = $_row[0];
            $_ret['lat'] = $_row[1];
        }
        
        $_db->disconnect();
        
        return !empty($_ret) ? $_ret : false;
    }
191970
protected function _execute($address) {
		$this->_Geocoder = new Geocoder();
		try {
			$addresses = $this->_Geocoder->geocode($address);
		} catch (InconclusiveException $e) {
			return null;
		} catch (NotAccurateEnoughException $e) {
			return null;
		}

		if (!$addresses || $addresses->count() < 1) {
			return null;
		}
		$address = $addresses->first();
		return $address;
	}
718867
public static function normalizeMailAddress($address) {
		if (self::isBrokenEmailEnvironment() && FALSE !== ($pos1 = strrpos($address, '<'))) {
			$pos2 = strpos($address, '>', $pos1);
			$address = substr($address, $pos1 + 1, ($pos2 ? $pos2 : strlen($address)) - $pos1 - 1);
		}
		return $address;
	}
203275
protected function extractAddressValues(AddressInterface $address)
    {
        $values = [];
        foreach (AddressField::getAll() as $field) {
            $getter = 'get' . ucfirst($field);
            $values[$field] = $address->$getter();
        }

        return $values;
    }
290770
public function getCoordinatesByObject(AddressInterface $address) : CoordinatesInterface
    {
        $url = $this->addressQuery($address->getFormattedAddress());
        $json = $this->fetchUrl($url);

        // convert google data to coordinates
        $coordinates = CoordinatesBuild::create($json->results[0]);

        return $coordinates;
    }
398246
public function getZonesFromAddress(AddressInterface $address)
    {
        return $this
            ->zoneRepository
            ->getActiveZones()
            ->filter(function (ZoneInterface $zone) use ($address) {

                return $this
                    ->zoneMatcher
                    ->isAddressContainedInZone(
                        $address,
                        $zone
                    );
            });
    }
257246
public function geocodeAddress($address)
	{
		$uri = new Uri('https://maps.googleapis.com/maps/api/geocode/json');

		$uri->setVar('address', urlencode($address));

		if (($key = $this->getKey()))
		{
			$uri->setVar('key', $key);
		}

		$response = $this->http->get($uri->toString());

		if ($response->code < 200 || $response->code >= 300)
		{
			throw new RuntimeException('Error code ' . $response->code . ' received geocoding address: ' . $response->body . '.');
		}

		$data = json_decode($response->body, true);

		if (!$data)
		{
			throw new RuntimeException('Invalid json received geocoding address: ' . $response->body . '.');
		}

		if ($data['status'] != 'OK')
		{
			return;
		}

		return $data['results'][0];
	}