Created
June 9, 2015 01:31
-
-
Save jamessdixon/b33ceffe6e4fef3040e3 to your computer and use it in GitHub Desktop.
Texas A&M Geolocation Service in F#
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
#r "../packages/FSharp.Data.2.2.2/lib/net40/FSharp.Data.dll" | |
open System.IO | |
open System.Text | |
open FSharp.Data | |
[<Literal>] | |
let sample = "..\Data\TAMUHttpGet.json" | |
type Context = JsonProvider<sample> | |
let streetAddress = "1600 Pennslyvania Ave" | |
let city = "Washington" | |
let state = "DC" | |
let zip = "20500" | |
let apiKey = "XXXXXXX" | |
let stringBuilder = new StringBuilder() | |
stringBuilder.Append("https://geoservices.tamu.edu/Services/Geocode/WebService/GeocoderWebServiceHttpNonParsed_V04_01.aspx") |> ignore | |
stringBuilder.Append("?streetAddress=") |> ignore | |
stringBuilder.Append(streetAddress) |> ignore | |
stringBuilder.Append("&city=") |> ignore | |
stringBuilder.Append(city) |> ignore | |
stringBuilder.Append("&state=") |> ignore | |
stringBuilder.Append(state) |> ignore | |
stringBuilder.Append("&zip=") |> ignore | |
stringBuilder.Append(zip) |> ignore | |
stringBuilder.Append("&apiKey=") |> ignore | |
stringBuilder.Append(apiKey) |> ignore | |
stringBuilder.Append("&version=4.01") |> ignore | |
stringBuilder.Append("&format=json") |> ignore | |
let searchUri = stringBuilder.ToString() | |
let searchResult = Context.Load(searchUri) | |
let firstResult = searchResult.OutputGeocodes |> Seq.head | |
firstResult.OutputGeocode.Latitude | |
firstResult.OutputGeocode.Longitude | |
firstResult.OutputGeocode.MatchScore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment