Created
October 2, 2012 13:41
-
-
Save brucemcpherson/3819264 to your computer and use it in GitHub Desktop.
urbarama mashup
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
//google apps script version | |
// this is going to be a mashup of geocoding, and architectural info close by | |
function testUrbaramaMashup() { | |
// first get an address of some sort | |
var s = mcpher.InputBox("Provide an address to center on"); | |
if (s) { | |
// geocode it | |
var cr = mcpher.restQuery(undefined, "yahoo geocode", s, undefined, | |
undefined ,undefined , undefined, false, undefined, false) ; | |
if(cr) { | |
var lat = mcpher.CDbl(cr.jObject().find("latitude").value()) ; | |
var lon = mcpher.CDbl(cr.jObject().find("longitude").value()) ; | |
var d = mcpher.CDbl | |
(mcpher.InputBox("Within how many kilometers of " + s + "(" + lat + "," + lon + ")")); | |
// find within a box of this dimensions around center and do urbarama rest query | |
if (d > 0) { | |
cr = mcpher.generalQuery("urbarama", "urbarama", | |
"&miny=" + mcpher.CStr(mcpher.getLatFromDistance(lat, d, -135)) + | |
"&minx=" + mcpher.CStr(mcpher.getLonFromDistance(lat, lon, d, -135)) + | |
"&maxy=" + mcpher.CStr(mcpher.getLatFromDistance(lat, d, 45)) + | |
"&maxx=" + mcpher.CStr(mcpher.getLonFromDistance(lat, lon, d, 45)), false); | |
} | |
} | |
} | |
} |
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
'vba version | |
Public Sub testUrbaramaMashup() | |
' first get an address of some sort | |
Dim s As String, cr As cRest, lat As Double, lon As Double, d As Double | |
Dim minLat As Double, minLon As Double, maxLat As Double, maxLon As Double | |
s = InputBox("Provide an address to center on") | |
If (s <> vbNullString) Then | |
' geocode it | |
Set cr = restQuery(, "yahoo geocode", s, , , , , False, , False) | |
If Not cr Is Nothing Then | |
With cr.jObject | |
lat = CDbl(.find("latitude").value) | |
lon = CDbl(.find("longitude").value) | |
End With | |
d = InputBox("Within how many kilometers of " & s & "(" & lat & "," & lon & ")") | |
'find within a box of this dimensions around center and do urbarama rest query | |
If d > 0 Then | |
Set cr = generalQuery("urbarama", "urbarama", _ | |
"&miny=" & CStr(getLatFromDistance(lat, d, -135)) & _ | |
"&minx=" & CStr(getLonFromDistance(lat, lon, d, -135)) & _ | |
"&maxy=" & CStr(getLatFromDistance(lat, d, 45)) & _ | |
"&maxx=" & CStr(getLonFromDistance(lat, lon, d, 45)), False) | |
End If | |
End If | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://ramblings.mcpher.com/Home/excelquirks/json/rest/urbanarama for more details