Created
April 10, 2016 17:34
-
-
Save anonymous/42f0014496848a8600765596e2c1468a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function Get-LongLat | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string[]]$ZipCode | |
) | |
process | |
{ | |
foreach($z in $ZipCode) | |
{ | |
Write-Verbose "Getting geometry for $z" | |
$data = Invoke-RestMethod -Method Get -Uri "http://maps.googleapis.com/maps/api/geocode/json?address=$z" | |
$obj = [pscustomobject]@{ | |
ZipCode = $z | |
Address = $data.results.formatted_address | |
Latitude = $data.results.geometry.location.lat | |
Longitude = $data.results.geometry.location.lng | |
} | |
Write-Output $obj | |
} | |
} | |
} | |
function Get-Forecast | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string]$Latitude, | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string]$Longitude, | |
[Parameter( | |
Mandatory = $false, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string]$Apikey = 'myapikeyhere' | |
) | |
process | |
{ | |
Write-Verbose "Getting forecast for $Latitude,$Longitude" | |
$data = Invoke-RestMethod -Method Get -Uri "https://api.forecast.io/forecast/$ApiKey/$Latitude,$Longitude" | |
Write-Output $data | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment