 Okay, this video is part of a series on maps and locations and the first part of this series we're looking at shell scripts and again, I'm using Google API. You may or may not like that. There is OpenStreets or OpenMaps, OpenStreetMaps.com, which I don't have very much experience with. Google does the best jobs with maps and so that's what I default to. Some of which is using a service, some of which in the future we might actually be using some of their code. So keep in mind that what I'm showing you is using open source tools and my scripts are open source but you're accessing a server which is a service that has one copyrighted information and two you're depending on someone else to provide this information for you and whether you're using OpenStreetMaps or not, you know, if you're using a service that's out there, that service can be taken away. And remember these images that we're going to be pulling today are copyrighted, just keep that in mind depending on what you're doing and what your plans are for this. So we're going to be grabbing street views today. We're going to be giving both addresses and GPS coordinates to get street views and displaying them on our computer all within a shell script and let's go ahead and get started. Again, we're using a very basic API here for Google which is just using URLs to grab information. I use WGet to download stuff but you can use Curl if you prefer Curl on SA-Q for quiet and now I got to paste in a URL here so let me go ahead and grab copy and paste this here. So we're going to say maps, googleapis.com, maps, API and then we're going to request a street view. We're going to give it a size, I'm going to give it kind of a wide view, and then a location. So let's go ahead and type in an address. I'll say 123 5th Avenue South in Naples, Florida near where I live and then I'm going to use display which is part of the image magic package to display it. You can use whatever reviewer you want. I use, if you don't have image magic installed already which you might already, it's commonly installed but it should be in repositories and we'll display, oh I didn't give any output so it outputted it to a funny name file right here. Let's go ahead and just remove that file. If you don't give it an output name it's going to output name of the file from the URL which isn't a file name here it's our argument so let's go ahead, run our wget command and say dash capital O and we'll say street.png, I already have one there from a test run but I'm going to overwrite it right now and now I can display the street png. So there we go, nice little look of downtown Naples. This is not my house. I don't live in town, Naples is a very nice, very rich town. I do not live there. I live on the outskirts of Collier County. I basically live in the Everglades, in fact let's give you, I'm not going to give you my exact address but I'm going to give you an area near me. I'll just say let's look at 16th Avenue Southwest in Naples and we'll display that this is, yeah this is more like where I live. Nice area, very sunny here and about a 35 to 45 minute drive, probably close to 45 minute drive from that first shot so don't think that I'm a millionaire or anything. I don't live downtown. That house probably costs literally probably about 10 times what my house costs. So anyway, that's how you get a street view but there's more information we can put in there because that's a street view but what way are we facing? So what we can add to our command here and what I'm going to add here is I'm going to say the NN symbol, that ampersand, ampersand and it's saying that now if that command is successful, if we successfully pull down an image then we're going to run this next command. It will just not do anything after that. We're going to say display our street.png, that way we don't have to type in two commands. There we go. Okay, so that's facing one way. What we can add in is our heading which is I believe 360 degree heading. So here we can say end and so we're passing it a new variable we're going to say end and we'll say the variable is heading and we're going to give it a value of what we're looking at I believe is zero. Let's go ahead and test out that theory. No, it wasn't zero. So there's the same location facing a different direction. Let's go ahead and say 10 which should be probably can't tell much of a difference there but we're off a little bit off there so let's do 100. Okay so 100 is what it looks like it was defaulting to earlier. Let's try 50. There we go. Okay, so over to the left is zero and we're turning around 360 degrees is the max we can do. If you do 360 you'll get the same view as zero to the right. So if I want to move more to the right and I want to look more over here I can type in 100 that would point more that way. Let's do 180 so that'd be pointing back. There's a dirt road there. So if we want what we could do here is we can pass it information for four different views and get the four different angles. So that's what we're going to do and we're going to do it in a script. To save time I'm going to copy and paste the script because I already have it written up. I'm going to say well as I've mentioned in the previous tutorials in the series all my codes up on GitHub and here is a view of that and I'll give you more information on the GitHub stuff at the end of the video but here's the code. I can copy and paste this. I can look at the raw copy and paste it. I can also grab this URL here and I can then just say W get and whoops I can say W get and paste in that. It downloads it but it's not executable. If I try to run it it's not going to let me yeah it's not even going to let me autocomplete because it's not executable. What I'm going to have to do is change mod plus x. Now if you get clone you don't need to do this because it doesn't just download it. It pulls everything down as a project but we'll say get street address. So plus x so if you create a script change mod plus x to make it executable and at this point I can run it by dot slash and I didn't give it any variables so I can do here is I can copy and paste the example here and get a street view of Fifth Avenue in New York one two three Fifth Avenue and my script pulls down the four different directions. There's probably I believe there is an option to get a panorama view all the way around but all depending on what you want to do I think four views might be useful rather than having one long one but if you want to make a panorama that you can pan around you can do that. So let's go ahead and look at this code. If you watch the previous videos a lot of this is going to look familiar here we're checking the number of arguments given by the user. They need to give at least one argument and really this program only takes one argument which is the address. So this is saying look at the number of arguments if it's less than one well then give our error output which shows the usage and example and then exit and don't run the rest of the script. Okay then we're going to say take the first argument and set that to the variable of address don't really need to put it in the address but it's nice label things like that and if you're going to be using the code the script the variable more than one place it's nice to have it like that just for reference I could leave this line out all together and down here where we use address use dollar sign one whatever. This time I put my pull commands and display commands and the remove command basically the bulk of my script into a function called get view. Why did I do that? Because I think that's the easiest way to loop through it properly and also loop through it all at once. What I mean by that is here down here the bottom of our script this is our whole script we're already at the end it's not very long. We're saying for I in and then we're giving it command of sequence. Okay so we're saying we're going to do a for loop and we're going to create a variable called I and we're going to loop through a set of numbers. So let's go ahead take this and real quick I'll open up another shell here I'll paste that in there and as you can see what this is doing it's starting at zero it's moving by intervals of 90 and it's going to 270 and then stopping. If we did 360 again the first view would be the same as the last view so we don't need to go 360 we're just going 90, 90, 90 and stopping at 27 or sorry 270. So that's giving us our four views instead of typing out each number which it's only four numbers I could have typed out each one and it actually probably would have been about the same length. But if you wanted to get more angles you can easily modify this to get every interval I don't know why you would need to do that but if you needed to you could so I decided to throw that in the loop. Now inside that loop we're doing is we're calling that function now I could have theoretically put all this in there a few issues with that is if I did that it would download one display one wait for you to close that remove it download the next one display the next one wait for you to close that view remove it so forth and so on doing this not only allows me to run all this in one command but also let me use this ampersand which says do it all at once so we have four views instead of downloading one downloading the next download X it's gonna start downloading all four views at the same time and displaying them as they appear and then removing them as you close them so I thought that was the best way to do that so that's the ampersand there is saying run this command and continue with the loop which is just running that same command again doing it four times so again we can run that example there get the four-street views we can also do it in Naples Florida there that's a nice house right there think that's the house we were looking at earlier in the first example there so there's our street use and and you can somewhat line up because of the curvature of the lens they're not gonna line up perfectly but if we can figure out yeah okay so this one goes here you can see that's the driveway right there and then I guess it's not right this one's the next one yeah there we go that lines up and if we were to move these off like this this one would line up over here again not perfectly and then again the first one will line up about there so you have a complete 360 and four different frames so that's great in a street view with an address let's go ahead and go back to my github account here and back out and that was get street by address here's get street by GPS basically the same exact code except for instead grabbing an address or grabbing the latitude and longitude and we're saying that as the location there not gonna bother really going over that because everything else is pretty much the same we're getting the same for views looping it through looping through the function blah blah blah so again this is a series hopefully you've watched the previous videos in this series if not there should be an annotation on the screen as well as possibly one in the description of the video if you want to get all the code in this video go to github.com forward slash middle x1000 look at my repositories for one called maps and locations this first part is all basher those shell scripts and you can see all the code there I recommend taping out yourself playing around with it so you learn if you're having issues then you can download mine if you just want to download mine to modify it or just download to use it they're all there free and open source my side of the code again remember you're using a service that's online that can be taken away and does have restrictions on the number of requests and of course the images are copyrighted so be careful to use them for please visit my site filmsbychrist.com that's Chris the K should be linked to that in the description as well and please like subscribe and share it helps me out a lot and as always I hope that you have a great day okay this is an introduction to filmsbychrist.com I'm Chris that's Chris the K that's me right there my daughter ember and my wife Jennifer we pretty much live in the swamps of Florida I'm a firefighter by day as well as by night we work long hours but that's not why you're here you're here about the videos I put up on YouTube these videos are mainly about computers and programming which means most my videos look something like this and if that's what you're interested in great if not that's alright I do videos on other topics too such as video editing special effects photo editing 3d design and music creation if you were one of my viewers and you enjoy my videos my patreon page is a place where you can go to help support my videos so I asked that you take the time to go to my patreon page and look at different levels of rewards you can receive for different levels of backing there should be a link in the description of this video if you were watching it on YouTube otherwise you can visit patreon.com forward slash metal x1000 and I thank you for your time and your support have a great day