Changement streetview
This commit is contained in:
parent
de8e417522
commit
33dd9e5123
@ -1315,9 +1315,9 @@ class IdentiteController extends Zend_Controller_Action
|
||||
|
||||
//Corriger la voie pour Mappy
|
||||
$adresse.= ' '.strtr($infos->AdresseVoie, array(
|
||||
'R' => 'RUE',
|
||||
'AV' => 'AVENUE',
|
||||
'RLE' => 'RUELLE',
|
||||
'R' => 'RUE',
|
||||
'AV' => 'AVENUE',
|
||||
'RLE' => 'RUELLE',
|
||||
));
|
||||
|
||||
$adresse.= ' '.$infos->AdresseRue;
|
||||
@ -1345,8 +1345,10 @@ class IdentiteController extends Zend_Controller_Action
|
||||
public function streetviewAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$num = $request->getParam('heading', 0);
|
||||
|
||||
if ( $request->isXmlHttpRequest() ) {
|
||||
// --- Prepare information
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$siret = $request->getParam('siret');
|
||||
$lat = $request->getParam('lat', '');
|
||||
@ -1365,9 +1367,9 @@ class IdentiteController extends Zend_Controller_Action
|
||||
|
||||
//Corriger la voie
|
||||
$adresse.= strtr($infos->AdresseVoie, array(
|
||||
'R' => 'RUE',
|
||||
'AV' => 'AVENUE',
|
||||
'RLE' => 'RUELLE',
|
||||
'R' => 'RUE',
|
||||
'AV' => 'AVENUE',
|
||||
'RLE' => 'RUELLE',
|
||||
));
|
||||
|
||||
$adresse.= ' '.$infos->AdresseRue;
|
||||
@ -1381,48 +1383,57 @@ class IdentiteController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
|
||||
$num = $request->getParam('heading', 0);
|
||||
$user = new Scores_Utilisateur();
|
||||
$this->view->AuthorizeUpdate = $user->checkModeEdition();
|
||||
|
||||
$this->view->assign('siret', $siret);
|
||||
$this->view->assign('lat', $lat);
|
||||
$this->view->assign('lon', $lon);
|
||||
|
||||
$mode = 'address';
|
||||
$this->view->assign('streetviewMode', $mode);
|
||||
$file = false;
|
||||
|
||||
if ( $mode == 'address' && $adresse !== null ) {
|
||||
$streetview = new Scores_Google_Streetview($siret);
|
||||
$streetview->setLocationTxt($adresse);
|
||||
$url = $streetview->serveUrl();
|
||||
$this->view->assign('url', $url);
|
||||
}
|
||||
if (intval($siret) < 1000) {
|
||||
$this->view->assign('url', false);
|
||||
} else {
|
||||
$streetview = new Scores_Google_Streetview($siret);
|
||||
|
||||
if ( $mode == 'GPS' && intval($siret)>100 && $lat != '' && $lon != '' ) {
|
||||
$streetview = new Scores_Google_Streetview($siret);
|
||||
$deg = $streetview->getNumDeg();
|
||||
$nbImg = count($deg);
|
||||
$pagePrec = $num-1;
|
||||
if ($pagePrec<=0) {
|
||||
$pagePrec = $nbImg-1;
|
||||
}
|
||||
$pageSuiv = $num+1;
|
||||
if($pageSuiv>=$nbImg) {
|
||||
$pageSuiv = 0;
|
||||
}
|
||||
$this->view->assign('pagePrec', $pagePrec);
|
||||
$this->view->assign('pageSuiv', $pageSuiv);
|
||||
// --- Affichage GPS
|
||||
if ($lat != '' && $lon != '') {
|
||||
$this->view->assign('streetviewMode', 'GPS');
|
||||
$deg = $streetview->getNumDeg();
|
||||
$nbImg = count($deg);
|
||||
$pagePrec = $num-1;
|
||||
if ($pagePrec<=0) {
|
||||
$pagePrec = $nbImg-1;
|
||||
}
|
||||
$pageSuiv = $num+1;
|
||||
if($pageSuiv>=$nbImg) {
|
||||
$pageSuiv = 0;
|
||||
}
|
||||
$this->view->assign('pagePrec', $pagePrec);
|
||||
$this->view->assign('pageSuiv', $pageSuiv);
|
||||
|
||||
$streetview->setLocationGeo( $lat, $lon );
|
||||
$heading = $deg[$num];
|
||||
$streetview->setHeading($heading);
|
||||
|
||||
$img = $streetview->serveImg();
|
||||
if ( $img!==false ) {
|
||||
$url = '/fichier/streetview/'.$img;
|
||||
$this->view->assign('url', $url);
|
||||
}
|
||||
}
|
||||
$streetview->setLocationGeo($lat, $lon);
|
||||
$heading = $deg[$num];
|
||||
$streetview->setHeading($heading);
|
||||
}
|
||||
// --- Fallback adresse
|
||||
elseif (!empty($adresse)) {
|
||||
$this->view->assign('streetviewMode', 'ADDRESS');
|
||||
$streetview->setLocationTxt($adresse);
|
||||
}
|
||||
|
||||
$file = $streetview->pathImg();
|
||||
if ($file !== false) {
|
||||
$this->view->assign('url', '/file/streetview/img/q/'.$streetview->fileImg());
|
||||
$this->view->assign('cache', 1);
|
||||
$this->view->assign('saveas', '');
|
||||
} else {
|
||||
$this->view->assign('url', $streetview->urlImg());
|
||||
$this->view->assign('cache', 0);
|
||||
$this->view->assign('saveas', $streetview->fileImg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,14 +33,12 @@
|
||||
<?php if ($this->source == 'google') {?>
|
||||
|
||||
<div id="infogeo_photo">
|
||||
<?=$this->action('streetview', 'identite', null, array(
|
||||
'infos' => $this->infos,
|
||||
));?>
|
||||
<?=$this->action('streetview', 'identite', null, array('infos' => $this->infos,));?>
|
||||
</div>
|
||||
|
||||
<?php } elseif ($this->source == 'mappy') {?>
|
||||
|
||||
<div><img id="pp-cb-thumb" width="300px" /></div>
|
||||
<div><img id="streetview" width="300px" /></div>
|
||||
<script src="<?=$this->lienJs?>"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
@ -50,7 +48,7 @@
|
||||
var img = $('<img src="' + current.getURL(320, null) +
|
||||
'" alt="' + current.getDescription() +
|
||||
'" width="300px" />');
|
||||
$('#pp-cb-thumb').replaceWith(img);
|
||||
$('#streetview').replaceWith(img);
|
||||
}
|
||||
};
|
||||
var address = "<?=$this->adresse?>";
|
||||
|
@ -1,17 +1,31 @@
|
||||
<?php if ($this->url) {?>
|
||||
|
||||
<div id="legende-photo">Cliché à l'approche de l'adresse postale.</div>
|
||||
<img id="pp-cb-thumb" src="<?=$this->url?>" width="320" height="320" />
|
||||
<img id="streetview" data-cache="<?=$this->cache?>" data-saveas="<?=$this->saveas?>" src="<?=$this->url?>"
|
||||
width="320" height="320" />
|
||||
<script>
|
||||
$('streetview').on('onload', function(e) {
|
||||
var cache = $(this).data('cache');
|
||||
var saveas = $(this).data('saveas');
|
||||
if (cache == 0) {
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.width = $(this).width; canvas.height = $(this).height;
|
||||
canvasContext = canvas.getContext("2d");
|
||||
canvasContext.drawImage($(this), 0, 0, $(this).width, $(this).height);
|
||||
var dataURL = canvas.toDataURL();
|
||||
$.post(<?=$this->url(array('module'=>'file', 'controller'=>'streetview', 'action'=>'saveimg'),
|
||||
'default', true)?>, { name: saveas, base64: dataURL });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php if ($this->streetviewMode == 'gps') {?>
|
||||
<?php if ($this->AuthorizeUpdate) {?>
|
||||
<div>
|
||||
<a class="street-heading" href="<?=$this->url(array(
|
||||
'controller'=>'identite','action'=>'streetview', 'siret'=> $this->siret,
|
||||
'lat'=>$this->lat, 'lon'=>$this->lon, 'heading'=>$this->pagePrec), 'default', true)?>"><</a>
|
||||
-
|
||||
<a class="street-heading" href="<?=$this->url(array(
|
||||
'controller'=>'identite', 'action'=>'streetview', 'siret'=> $this->siret,
|
||||
'lat'=>$this->lat, 'lon'=>$this->lon, 'heading'=>$this->pageSuiv), 'default', true)?>">></a>
|
||||
<a class="street-heading" href="<?=$this->url(array('controller'=>'identite','action'=>'streetview',
|
||||
'siret'=> $this->siret, 'lat'=>$this->lat, 'lon'=>$this->lon, 'heading'=>$this->pagePrec),
|
||||
'default', true)?>"><</a> - <a class="street-heading" href="<?=$this->url(array('controller'=>'identite',
|
||||
'action'=>'streetview', 'siret'=> $this->siret, 'lat'=>$this->lat, 'lon'=>$this->lon,
|
||||
'heading'=>$this->pageSuiv), 'default', true)?>">></a>
|
||||
</div>
|
||||
<script>
|
||||
$('a.street-heading').click(function(e){
|
||||
@ -21,4 +35,11 @@ $('a.street-heading').click(function(e){
|
||||
</script>
|
||||
<?php }?>
|
||||
|
||||
<?php if ($this->AuthorizeUpdate) {?>
|
||||
<div>
|
||||
<a class="street-original" href="#">Original</a> -
|
||||
<a class="street-upload" href="#">Upload</a>
|
||||
</div>
|
||||
<?php }?>
|
||||
|
||||
<?php }?>
|
@ -9,7 +9,7 @@
|
||||
</div>
|
||||
|
||||
<?php elseif ($this->source == 'mappy'):?>
|
||||
<div><img id="pp-cb-thumb" width="300px" /></div>
|
||||
<div><img id="streetview" width="300px" /></div>
|
||||
<script src="<?=$this->lienJs?>"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
@ -27,7 +27,7 @@ $(document).ready(function() {
|
||||
var img = $('<img src="' + current.getURL(320, null) +
|
||||
'" alt="' + current.getDescription() +
|
||||
'" width="300px" />');
|
||||
$('#pp-cb-thumb').replaceWith(img);
|
||||
$('#streetview').replaceWith(img);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -1 +1 @@
|
||||
<img src="/fichier/imgcache/<?php echo $this->name;?>" />
|
||||
<img src="/file/image/cache/q/<?php echo $this->name;?>" />
|
@ -1,10 +1,10 @@
|
||||
<?php if ($this->url) {?>
|
||||
<div id="legende-photo">Cliché à l'approche de l'adresse postale.</div>
|
||||
<img id="pp-cb-thumb" src="<?=$this->url?>" width="320" height="320" />
|
||||
<div>
|
||||
<img id="streetview" src="<?=$this->url?>" width="320" height="320" />
|
||||
<div>
|
||||
<a class="street-heading" href="<?=$this->url(array(
|
||||
'controller'=>'identite','action'=>'streetview', 'lat'=>$this->lat, 'lon'=>$this->lon, 'heading'=>$this->pagePrec))?>"><</a>
|
||||
-
|
||||
'controller'=>'identite','action'=>'streetview', 'lat'=>$this->lat, 'lon'=>$this->lon, 'heading'=>$this->pagePrec))?>"><</a>
|
||||
-
|
||||
<a class="street-heading" href="<?=$this->url(array(
|
||||
'controller'=>'identite','action'=>'streetview', 'lat'=>$this->lat, 'lon'=>$this->lon, 'heading'=>$this->pageSuiv))?>">></a>
|
||||
</div>
|
||||
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class File_StreetviewController extends Zend_Controller_Action
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
}
|
||||
|
||||
public function imgAction()
|
||||
{
|
||||
$filename = $this->getRequest()->getParam('q');
|
||||
$c = Zend_Registry::get('config');
|
||||
$file = realpath($c->profil->path->data).'/google/streetview/'.$filename;
|
||||
$content_type = 'application/csv-tab-delimited-table';
|
||||
|
||||
//Envoi du fichier sur la sortie standard
|
||||
if ( file_exists($file) ) {
|
||||
$modules = apache_get_modules();
|
||||
if (in_array('mod_xsendfile', $modules)) {
|
||||
header ('X-Sendfile: ' . $file);
|
||||
header ('Content-Type: ' . $content_type);
|
||||
header ('Content-Disposition: attachment; filename="' . $content_type . '"');
|
||||
exit;
|
||||
} else {
|
||||
ini_set('zlib.output_compression', '0');
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-Type: ' . $content_type.'');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
header('Content-MD5: ' . base64_encode(md5_file($file)));
|
||||
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
readfile($file);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$name = $request->getParam('name');
|
||||
$base64 = $request->getParam('base64');
|
||||
$removePart = 'data:image/png;base64,';
|
||||
$pos = strpos($base64, $removePart);
|
||||
$data = substr($base64, $start + strlen($removePart));
|
||||
file_put_contents(substr_replace($name.'.png','.jpg'), base64_decode($data));
|
||||
}
|
||||
}
|
@ -186,6 +186,20 @@ class Scores_Google_Streetview
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -213,42 +227,9 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serveUrl()
|
||||
{
|
||||
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);
|
||||
$filename = $this->path . '/' . $this->fileImg();
|
||||
if (file_exists($filename)) {
|
||||
return $this->path . '/' . $filename;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -614,10 +614,10 @@ table.liasse td.type {min-width:250px;}
|
||||
#infogeo_txt {float:left;width:320px;padding:10px 0;}
|
||||
#infogeo_photo {float:left;margin:0;padding:0;width:320px;}
|
||||
#legende-photo {margin:5px 0; padding:10px;border:1px solid #0000ff;color:#0000ff;}
|
||||
#pp-cb-thumb div.left {float:left;position:relative;width:256px;height:128px;overflow:hidden;}
|
||||
#pp-cb-thumb div.right {float:left;position:relative;width:44px;height:128px;overflow:hidden;}
|
||||
#pp-cb-thumb div.left img{position:relative;left:-256px;top:-140px;}
|
||||
#pp-cb-thumb div.right img{position:relative;top:-140px;}
|
||||
#streetview div.left {float:left;position:relative;width:256px;height:128px;overflow:hidden;}
|
||||
#streetview div.right {float:left;position:relative;width:44px;height:128px;overflow:hidden;}
|
||||
#streetview div.left img{position:relative;left:-256px;top:-140px;}
|
||||
#streetview div.right img{position:relative;top:-140px;}
|
||||
|
||||
/* Juridique
|
||||
----------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user