ジオコーディング
住所を元に地理情報を返す（緯度経度など）

@param string $address 検索対象の住所文字列
@return Dm_Geocoder_Address[]
481533
public static function geocode($address)
	{
		if(!is_string($address)) return array();
		
		$query = new Dm_Geocoder_Query($address);
		$finded = Dm_Geocoder_GISCSV_Finder::find($query);
		
		return $finded;
		
	}
1067121
public static function address($coordinates)
	{
		$adapter  = new \Geocoder\HttpAdapter\CurlHttpAdapter();

		$p = array();

		// Get a list of providers
		if ($providers = \Event::trigger('geocode.onGeocodeProvider', array('geocode.address', $adapter)))
		{
			foreach ($providers as $provider)
			{
				if ($provider)
				{
					$p[] = $provider;
				}
			}
		}

		if (!count($p))
		{
			return '';
		}

		$latitude =  isset($coordinates['latitude'])  ? $coordinates['latitude']  : $coordinates[0];
		$longitude = isset($coordinates['longitude']) ? $coordinates['longitude'] : $coordinates[1];

		// Instantiate the Geocoder service and pass it the list of providers
		$geocoder = new \Geocoder\Geocoder();
		$geocoder->registerProvider(new \Geocoder\Provider\ChainProvider($p));

		// Try to get some data...
		return $geocoder->reverse($latitude, $longitude);
	}
788372
public function getPathForAddress($address) {
        $decoded = $this->addressReader->fromString($address);
        if ($decoded instanceof CashAddress) {
            $address = $decoded->getLegacyAddress();
        }

        return $this->sdk->getPathForAddress($this->identifier, $address);
    }
630635
public function getCoordinates($address)
    {
        if (! empty($this->country)) {
            $address = trim($address) . ' ' . $this->country;
        }

        // Sanitize the address:
        $search_code = urlencode($address);

        // Retrieve the latitude and longitude
        $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $search_code . '&sensor=false';

        // If Google Maps API fails, catch it and throw a better error
        $json = $this->api->fetch($url);

        if(!empty($json->results)) {
            $lat = $json->results[0]->geometry->location->lat;
            $lng = $json->results[0]->geometry->location->lng;

            return [
                'latitude'  => $lat,
                'longitude' => $lng
            ];
        }

        // We must have nothing if we've got here
        return [];
    }
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];
	}
418377
protected function _extractAddressData(Mage_Customer_Model_Address_Abstract $address)
    {
        return array(
            'street' => $address->getStreet(),
            'city' => $address->getCity(),
            'region_code' => $address->getRegionCode(),
            'country_id' => $address->getCountryId(),
            'postcode' => $address->getPostcode(),
        );
    }
1016346
public function address(ComLocationsDomainEntityLocation $location)
    {
        $text = array();

        if ($location->address) {
            $text[] = $location->address;
        }

        if ($location->city) {
            $text[] = $location->city;
        }

        if ($location->state_province) {
            $text[] = $location->state_province;
        }

        if ($location->country) {
            $text[] = LibBaseTemplateHelperSelector::$COUNTRIES[$location->country];
        }

        if ($location->postalcode) {
            $text[] = $location->postalcode;
        }

        return implode(', ', $text);
    }
657219
public function geolocateIPAddress(AddressInterface $address)
    {
        $result = new GeolocationResult();
        try {
            switch ($address->getRangeType()) {
                case IPRangeType::T_PUBLIC:
                    $addressString = (string) $address;
                    $session = $this->app->make('session');
                    $sessionKey = 'ccm/geolocation/' . $this->geolocator->getGeolocatorHandle() . '/' . $this->geolocator->getGeolocatorID() . '/' . md5(serialize($this->geolocator->getGeolocatorConfiguration())) . '/' . $addressString;
                    if ($session->has($sessionKey)) {
                        $result = $session->get($sessionKey);
                    } else {
                        $result = $this->performGeolocation($address);
                        $session->set($sessionKey, $result);
                    }
                    break;
                default:
                    $result->setError(GeolocationResult::ERR_IPNOTPUBLIC);
                    break;
            }
        } catch (Exception $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', $x);
        } catch (Throwable $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', new Exception($x->getMessage(), $x->getCode()));
        }

        return $result;
    }
63034
static public function getYandexCoordinatesByAdress($addressString)
    {
        if ($data = static::getYandexFirstFutureMemeber($addressString))
        {
            if ($coordinates = ArrayHelper::getValue($data, 'GeoObject.Point.pos'))
            {
                if ($coordinates)
                {
                    $data = explode(" ", $coordinates);
                    return [$data[1], $data[0]];
                }
            }
        }

        return [];
    }
447390
public function getStatusOfDepositToAddress(string $address): stdClass
    {
        return $this->get(sprintf('%s/%s', Resources::RECENT_DEPOSIT_TRANSACTION_STATUS, $address));
    }
801322
protected function mapTheliaAddress($address, $locale = null)
    {
        $country = $address->getCountry();
        if (null === $locale) {
            $locale = Lang::getDefaultLanguage()->getLocale();
        }
        $customerTitle = $address->getCustomerTitle()
            ->setLocale($this->denormalizeLocale($locale))
            ->getShort()
        ;

        $addressModel = new Address();
        $addressModel = $addressModel
            ->withCountryCode($country->getIsoalpha2())
            ->withAddressLine1($address->getAddress1())
            ->withAddressLine2($address->getAddress2())
            ->withPostalCode($address->getZipcode())
            ->withLocality($address->getCity())
            ->withOrganization($address->getCompany())
            ->withRecipient(
                sprintf(
                    '%s %s %s',
                    $customerTitle,
                    $address->getLastname(),
                    $address->getFirstname()
                )
            )
        ;


        if ($country->getHasStates() && \intval($address->getStateId()) !== 0) {
            $addressModel = $addressModel->withAdministrativeArea(
                sprintf(
                    '%s-%s',
                    $country->getIsoalpha2(),
                    $address->getState()->getIsocode()
                )
            );
        }

        return $addressModel;
    }
7601
public static function lookUpHostIp($address)
    {

        $ipAddress = null;
        if (function_exists('dns_get_record')) {
            $records = dns_get_record(trim($address));
            foreach ($records as $record) {
                if ($record['type'] == 'A') {
                    $ipAddress = $record['ip'];
                }
            }
        }
        return $ipAddress;
    }
1322199
public static function formatAddress(array $address, $sep = ', ')
    {
        $address = array_merge(
            [
                'firstname' => '',
                'lastname' => '',
                'address1' => '',
                'address2' => '',
                'address3' => '',
                'postcode' => '',
                'city' => '',
                'country_code' => '',
            ],
            $address
        );

        $values = array_map('trim', [
                sprintf('%s %s', $address['firstname'], $address['lastname']),
                $address['address1'],
                $address['address2'],
                $address['address3'],
                $address['postcode'],
                $address['city'],
            ]);

        foreach ($values as $key => $val) {
            if (!$val) {
                unset($values[$key]);
            }
        }

        $fullAddress = implode($sep, $values);

        if ($countryCode = trim($address['country_code'])) {
            if ($fullAddress) {
                $fullAddress .= ' ';
            }

            $fullAddress .= sprintf('(%s)', $countryCode);
        }

        return $fullAddress;
    }
877746
protected function parseAddresses($value)
    {
        return collect($value)->map(function ($address, $name) {
            return [$address, is_numeric($name) ? null : $name];
        })->values()->all();
    }
970892
public function getMageRegionByAddress($address)
    {
        $map = $this->getIsoToMagentoMapping();

        $state = preg_replace("/{$address->getCountry()}\-/", "", $address->getState());

        /** @var \Magento\Directory\Model\ResourceModel\Region\Collection $set */
        /** @var \Magento\Directory\Model\Region $region */
        $set    = $this->regionFactory->create()->getCollection();
        $region = $set->addCountryFilter($address->getCountry())
                      ->addFieldToFilter('main_table.code', $state)
                      ->getFirstItem();

        // If no region was found
        if (!$region->getId() && !empty($state) && isset($map[$address->getCountry()][$state])) {
            $regionCode = $map[$address->getCountry()][$state];

            $set    = $this->regionFactory->create()->getCollection();
            $region = $set->addRegionCodeFilter($regionCode)->addCountryFilter($address->getCountry())->getFirstItem();
        }

        if (!$region->getId()) {
            $this->logger->error('Region not found, state provided: ' . $state . ' country: ' . $address->getCountry());
        }

        return $region;
    }
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;
    }
183309
public function setCryptoAddress($address)
    {
        if (!$this->checkAddress($address) || !preg_match(static::CRYPTO_ADDRESS_VALIDATION_REGEX, $address)) {
            throw new ErrorParameter('Invalid crypto address provided');
        }

        $this->crypto_address = $address;

        return $this;
    }