size = '320x320'; $this->siret = $siret; $c = Zend_Registry::get('config'); $this->path = $c->profil->path->shared.'/persist/streetview'; } /** * * @param unknown $lattitude * @param unknown $longitude */ public function setLocationGeo($lattitude, $longitude) { $this->mode = self::MODE_GPS; $this->location = $lattitude.','.$longitude; } /** * * @param string $adresse */ public function setLocationTxt($adresse) { $this->mode = self::MODE_ADDRESS; $this->location = $adresse; } /** * * @param int $num */ public function setHeading($num) { $this->heading = $num; } /** * * @return multitype:number */ public function getNumDeg() { $mark = array(); $deg = 360/$this->nbImage; $i=$calc=0; while ($calc<360) { $mark[$i] = $calc; $calc+=$deg; $i++; } return $mark; } /** * Construct the image URL * @return string */ public function urlImg() { $url = ''; $params = array( 'size', 'location', 'fov', 'pitch', 'sensor', 'heading' ); foreach ($params as $param) { if ( $this->{$param} !== null ) { $url.= '&'.$param.'='. urlencode($this->{$param}); } } return $this->url . substr($url,1); } /** * */ public function fileImg() { if ($this->mode == self::MODE_GPS) { $filename = $this->siret.'-'.$this->heading . '.' . $this->extension; } else if ($this->mode == self::MODE_ADDRESS) { $filename = $this->siret.'-ADDRESS' . $this->extension; } return $filename; } /** * */ public function getImg() { try { $client = new Zend_Http_Client($this->url); $client->setStream(); $response = $client->request('GET'); if ( $response->isSuccessful() ) { if (!copy($response->getStreamName(), $this->pathImg())) { Zend_Registry::get('firebug')->info('Erreur copie image !'); return false; } } } catch (Zend_Http_Client_Exception $e) { Zend_Registry::get('firebug')->info('HTTP Exception : '.$e->getMessage()); return false; } } /** * * @return string */ public function pathImg() { $filename = $this->path . '/' . $this->fileImg(); if (file_exists($filename)) { return $this->path . '/' . $filename; } return false; } }