New streetview integration (create dir for storage DATA_DIR/google/streetview)
This commit is contained in:
parent
d0b5423c7a
commit
7fcc7cb7ae
@ -455,4 +455,34 @@ class FichierController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Façade d'immeuble
|
||||
*/
|
||||
public function streetviewAction()
|
||||
{
|
||||
$file = $this->getRequest()->getParam('fichier');
|
||||
$explode = explode('.', $file);
|
||||
switch ($explode[1]) {
|
||||
case 'png' : $content_type = 'image/png'; break;
|
||||
case 'gif' : $content_type = 'image/gif'; break;
|
||||
case 'jpeg':
|
||||
case 'jpg' : $content_type = 'image/jpeg'; break;
|
||||
}
|
||||
$c = Zend_Registry::get('config');
|
||||
$path = realpath($c->profil->path->data).'/google/streetview/';
|
||||
if ( file_exists($path.$file) ) {
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-type: ' . $content_type.'');
|
||||
header('Content-Length: ' . filesize($path.$file));
|
||||
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
|
||||
header('Content-Disposition: filename="' . basename($path.$file) . '"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
ini_set('zlib.output_compression', '0');
|
||||
echo file_get_contents($path.$file);
|
||||
} else {
|
||||
echo file_get_contents(APPLICATION_PATH.'/../public/themes/default/images/1x1.png');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1169,7 +1169,7 @@ class IdentiteController extends Zend_Controller_Action
|
||||
$lon = $request->getParam('lon', '');
|
||||
$num = $request->getParam('heading', 0);
|
||||
|
||||
$streetview = new Scores_Streetview();
|
||||
$streetview = new Scores_Google_Streetview();
|
||||
if ( $lat != '' && $lon != '' ) {
|
||||
$deg = $streetview->getNumDeg();
|
||||
$nbImg = count($deg);
|
||||
@ -1187,7 +1187,8 @@ class IdentiteController extends Zend_Controller_Action
|
||||
$heading = $deg[$num];
|
||||
$streetview->setHeading($heading);
|
||||
//$streetview->setLocationTxt($adresse);
|
||||
$this->view->assign('url', $streetview->urlImg());
|
||||
$url = $this->view->url(array('controller'=>'fichier', 'action'=>'streetview', 'fichier'=> $streetview->display()), null, true);
|
||||
$this->view->assign('url', $url);
|
||||
}
|
||||
$this->view->assign('lat', $lat);
|
||||
$this->view->assign('lon', $lon);
|
||||
|
@ -67,12 +67,21 @@ class Scores_Google_Streetview
|
||||
*/
|
||||
protected $extension = 'jpg';
|
||||
|
||||
/**
|
||||
* Path where files are stored
|
||||
*/
|
||||
protected $path = '';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->size = '320x320';
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$ths->path = realpath($c->profil->path->data).'/google/streetview';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* https://developers.google.com/maps/documentation/streetview/
|
||||
* Image de 640x640 max
|
||||
* Heading 0 à 360
|
||||
* 0, 45, 90, 135, 180, 225, 270, 315
|
||||
@ -34,23 +35,43 @@ class Scores_Streetview
|
||||
|
||||
protected $extension = 'jpg';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->size = '320x320';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $lattitude
|
||||
* @param unknown $longitude
|
||||
*/
|
||||
public function setLocationGeo($lattitude, $longitude)
|
||||
{
|
||||
$this->location = $lattitude.','.$longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $adresse
|
||||
*/
|
||||
public function setLocationTxt($adresse){}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $num
|
||||
*/
|
||||
public function setHeading($num)
|
||||
{
|
||||
$this->heading = $num;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return multitype:number
|
||||
*/
|
||||
public function getNumDeg()
|
||||
{
|
||||
$mark = array();
|
||||
@ -81,13 +102,17 @@ class Scores_Streetview
|
||||
public function getImg()
|
||||
{
|
||||
require_once 'common/curl.php';
|
||||
$page = getUrl($this->url, '', '', '', false);
|
||||
$page = getUrl($this->urlImg(), '', '', '', false);
|
||||
|
||||
if ( !in_array($page['code'], array(400, 408, 403)) ) {
|
||||
$filename = $this->siret.'-'.$this->heading . '.' . $this->extension;
|
||||
$body = $page['body'];
|
||||
file_put_contents($this->path . DIRECTORY_SEPARATOR . $filename, $body);
|
||||
|
||||
return $this->path . DIRECTORY_SEPARATOR . $filename;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function pathImg()
|
||||
|
BIN
public/themes/default/images/1x1.png
Normal file
BIN
public/themes/default/images/1x1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 95 B |
Loading…
Reference in New Issue
Block a user