Skip to content

Instantly share code, notes, and snippets.

@brucemcpherson
Created October 2, 2012 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brucemcpherson/3819264 to your computer and use it in GitHub Desktop.
Save brucemcpherson/3819264 to your computer and use it in GitHub Desktop.
urbarama mashup
//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);
}
}
}
}
'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
@brucemcpherson
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment