Created
December 11, 2019 03:32
-
-
Save smzn/fda746432f7e499186c39bf00e32ed18 to your computer and use it in GitHub Desktop.
StreetsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function sview($id = null) { | |
if (!$this->Street->exists($id)) { | |
throw new NotFoundException(__('Invalid street')); | |
} | |
$options = array('conditions' => array('Street.' . $this->Street->primaryKey => $id)); | |
$this->set('street', $this->Street->find('first', $options)); | |
//StreetViewで取得した画像を保存する | |
$street = $this->Street->find('first', $options); | |
$id = "naisyo"; | |
$url0_0 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=0&pitch=0&key=".$id; | |
$img = file_get_contents($url0_0); | |
$imginfo = pathinfo($url0_0); | |
$img_name_0_0 = "street".$street['Street']['id']."_0_0.png"; | |
$path = IMAGES; | |
file_put_contents($path . DS . 'image' . DS . $img_name_0_0, $img); | |
$url0_45 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=0&pitch=45&key=".$id; | |
$img = file_get_contents($url0_45); | |
$imginfo = pathinfo($url0_45); | |
$img_name_0_45 = "street".$street['Street']['id']."_0_45.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_0_45, $img); | |
$url90_0 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=90&pitch=0&key=".$id; | |
$img = file_get_contents($url90_0); | |
$imginfo = pathinfo($url90_0); | |
$img_name_90_0 = "street".$street['Street']['id']."_90_0.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_90_0, $img); | |
//move_uploaded_file($image['tmp_name'], $path . DS . 'image' . DS . $image['name']); | |
$url90_45 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=90&pitch=45&key=".$id; | |
$img = file_get_contents($url90_45); | |
$imginfo = pathinfo($url90_45); | |
$img_name_90_45 = "street".$street['Street']['id']."_90_45.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_90_45, $img); | |
$url180_0 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=180&pitch=0&key=".$id; | |
$img = file_get_contents($url180_0); | |
$imginfo = pathinfo($url180_0); | |
$img_name_180_0 = "street".$street['Street']['id']."_180_0.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_180_0, $img); | |
$url180_45 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=180&pitch=45&key=".$id; | |
$img = file_get_contents($url180_45); | |
$imginfo = pathinfo($url180_45); | |
$img_name_180_45 = "street".$street['Street']['id']."_180_45.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_180_45, $img); | |
$url270_0 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=270&pitch=0&key=".$id; | |
$img = file_get_contents($url270_0); | |
$imginfo = pathinfo($url270_0); | |
$img_name_270_0 = "street".$street['Street']['id']."_270_0.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_270_0, $img); | |
$url270_45 = "https://maps.googleapis.com/maps/api/streetview?location=".$street['Street']['latitude'].",".$street['Street']['longitude']."&size=456x456&heading=270&pitch=45&key=".$id; | |
$img = file_get_contents($url270_45); | |
$imginfo = pathinfo($url270_45); | |
$img_name_270_45 = "street".$street['Street']['id']."_270_45.png"; | |
file_put_contents($path . DS . 'image' . DS . $img_name_270_45, $img); | |
$data = array( | |
'id' => $street['Street']['id'], | |
'photo0_0' => $img_name_0_0, | |
'photo0_45' => $img_name_0_45, | |
'photo90_0' => $img_name_90_0, | |
'photo90_45' => $img_name_90_45, | |
'photo180_0' => $img_name_180_0, | |
'photo180_45' => $img_name_180_45, | |
'photo270_0' => $img_name_270_0, | |
'photo270_45' => $img_name_270_45, | |
); | |
$this->Street->save($data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment