Fix Issue #0001876 : Solve bad merge on file Menu.php and Streetview.php
This commit is contained in:
parent
7b8f3bd07b
commit
918c42d7c9
@ -1267,7 +1267,7 @@ class IdentiteController extends Zend_Controller_Action
|
||||
if ( $mode == 'address' && $adresse !== null ) {
|
||||
$streetview = new Scores_Google_Streetview($siret);
|
||||
$streetview->setLocationTxt($adresse);
|
||||
$url = $streetview->urlImg();
|
||||
$url = $streetview->serveUrl();
|
||||
$this->view->assign('url', $url);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class Scores_Google_Streetview
|
||||
|
||||
/**
|
||||
* GPS ou Adresse
|
||||
* @var strign
|
||||
* @var string
|
||||
*/
|
||||
protected $location = null;
|
||||
|
||||
@ -53,7 +53,7 @@ class Scores_Google_Streetview
|
||||
/**
|
||||
* Indicates the compass heading of the camera (0 to 360)
|
||||
*/
|
||||
protected $heading = 0;
|
||||
protected $heading = null;
|
||||
|
||||
/**
|
||||
* Number of image by the circle (360°)
|
||||
@ -74,14 +74,51 @@ class Scores_Google_Streetview
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public function __construct()
|
||||
protected $siret;
|
||||
|
||||
/**
|
||||
* Maximum request per day
|
||||
* @var int
|
||||
*/
|
||||
protected $maxRequestPerDay = 25000;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var unknown
|
||||
*/
|
||||
protected $mode;
|
||||
|
||||
/**
|
||||
* Mode GPS
|
||||
* @var unknown
|
||||
*/
|
||||
const MODE_GPS = 1;
|
||||
|
||||
/**
|
||||
* Mode Adresse
|
||||
* @var unknown
|
||||
*/
|
||||
const MODE_ADDRESS = 2;
|
||||
|
||||
/**
|
||||
* Google Streetview
|
||||
* Get image by GPS coord or by adresse
|
||||
* Save image reference in a database
|
||||
* GpsLat, GpsLong, Adresse, Image, Date
|
||||
* Save request that give no imagery
|
||||
* Siren, Nic, Date
|
||||
* Save in database, with a counter the number of request by day
|
||||
*/
|
||||
public function __construct($siret)
|
||||
{
|
||||
$this->size = '320x320';
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$ths->path = realpath($c->profil->path->data).'/google/streetview';
|
||||
$this->siret = $siret;
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->path = realpath($c->profil->path->data).'/google/streetview';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,18 +128,23 @@ class Scores_Google_Streetview
|
||||
*/
|
||||
public function setLocationGeo($lattitude, $longitude)
|
||||
{
|
||||
$this->mode = self::MODE_GPS;
|
||||
$this->location = $lattitude.','.$longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $adresse
|
||||
* @param string $adresse
|
||||
*/
|
||||
public function setLocationTxt($adresse){}
|
||||
public function setLocationTxt($adresse)
|
||||
{
|
||||
$this->mode = self::MODE_ADDRESS;
|
||||
$this->location = $adresse;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $num
|
||||
* @param int $num
|
||||
*/
|
||||
public function setHeading($num)
|
||||
{
|
||||
@ -127,7 +169,7 @@ class Scores_Google_Streetview
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Construct the image URL
|
||||
* @return string
|
||||
*/
|
||||
public function urlImg()
|
||||
@ -137,7 +179,7 @@ class Scores_Google_Streetview
|
||||
$params = array( 'size', 'location', 'fov', 'pitch', 'sensor', 'heading' );
|
||||
foreach ($params as $param) {
|
||||
if ( $this->{$param} !== null ) {
|
||||
$url.= '&'.$param.'='. $this->{$param};
|
||||
$url.= '&'.$param.'='. urlencode($this->{$param});
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,12 +191,19 @@ class Scores_Google_Streetview
|
||||
*/
|
||||
public function getImg()
|
||||
{
|
||||
require_once 'common/curl.php';
|
||||
$page = getUrl($this->url, '', '', '', false);
|
||||
|
||||
if ( !in_array($page['code'], array(400, 408, 403)) ) {
|
||||
$body = $page['body'];
|
||||
file_put_contents($this->pathImg(), $body);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +213,11 @@ class Scores_Google_Streetview
|
||||
*/
|
||||
public function pathImg()
|
||||
{
|
||||
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 $this->path . DIRECTORY_SEPARATOR . $filename;
|
||||
}
|
||||
|
||||
@ -172,14 +225,33 @@ class Scores_Google_Streetview
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function display()
|
||||
public function serveUrl()
|
||||
{
|
||||
$file = $this->pathImg();
|
||||
if ( !file_exists($file) ) {
|
||||
$this->getImg();
|
||||
return $this->urlImg();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serveImg()
|
||||
{
|
||||
$this->url = $this->urlImg();
|
||||
Zend_Registry::get('firebug')->info('URL = '.$file);
|
||||
$file = $this->pathImg();
|
||||
Zend_Registry::get('firebug')->info('Filename = '.$file);
|
||||
$imgExist = false;
|
||||
if ( !file_exists($file) && APPLICATION_ENV == 'production' ) {
|
||||
$imgExist = $this->getImg();
|
||||
} elseif (file_exists($file)) {
|
||||
$imgExist = true;
|
||||
}
|
||||
|
||||
if ($imgExist) {
|
||||
return basename($file);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -416,11 +416,6 @@ class Scores_Menu
|
||||
'action' => 'liste',
|
||||
'permission' => 'SURVLISTE'
|
||||
),
|
||||
array(
|
||||
'label' => "Monitoring",
|
||||
'controller' => 'giant',
|
||||
'action' => 'retrive',
|
||||
),
|
||||
array(
|
||||
'label' => "Surveillances fichier",
|
||||
'controller' => 'surveillance',
|
||||
@ -752,9 +747,6 @@ class Scores_Menu
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case 'giant':
|
||||
return true;
|
||||
break;
|
||||
case 'user':
|
||||
switch($action){
|
||||
case 'liste':
|
||||
|
Loading…
Reference in New Issue
Block a user