Ben voor mijn werk aan het kijken of we iets kunnen automatiseren en nu stuit ik op een stukje code om de afstand tussen 2 plaatsen te bepalen aan de hand van 2 postcode's.
De programmeertaal komt mij niet bekend voor, en op de site staat ook niet welke taal het is.. kan iemand mij vertellen welke taal dit is:
PHP-code:
The code used to calculate this is using webservices is very simple and can be found below
Dim Service As New geoaccess.GeoAccess()
Dim LocationFrom, LocationTo As geoaccess.Location
LocationFrom = Service.GazetteerSimple("NL", "", "", "", "", FromPostalCode, SubscriptionKey)
LocationTo = Service.GazetteerSimple("NL", "", "", "", "", ToPostalCode, SubscriptionKey)
If LocationFrom.X = "" Or LocationFrom.Y = "" Or LocationTo.X = "" Or LocationTo.Y = "" Then
Response.Write("PostalCode not found")
Else
Dim Route As geoaccess.RouteResult
Route = Service.RoutePlannerSimple(LocationFrom.X, LocationFrom.Y, LocationTo.X, LocationTo.Y, geoaccess.EncodingType.AND1, geoaccess.RouteLanguage.English, True, False, False, False, False, False, False, "", SubscriptionKey)
Response.Write("Distance of the Route = " & Route.Distance / 1000 & "km")
End If
The code used to calculate this using html requests and XML parsing
Dim httpresult As System.Net.WebResponse
Dim httprequest As System.Net.WebRequest
Dim XMLDoc As New System.Xml.XmlDocument()
Dim Node As System.Xml.XmlNode()
Dim X1, Y1, X2, Y2 As String
Dim GazetteerUrl, RoutePlannerUrl As String
GazetteerUrl = "http://geoaccess.and.com/geoaccess/geoaccess.asmx/GazetteerSimple?"
GazetteerUrl &= "Country=nl&State=&City=&Street=&Premise=&SubscriptionKey=" & SubscriptionKey & "&PostCode="
RoutePlannerUrl = "http://geoaccess.and.com/geoaccess/geoaccess.asmx/RoutePlannerSimple?"
RoutePlannerUrl &= "Encoding=AND1&Language=English&WantMetric=true&WantRouteDetails=false&WantDataSet=false&"
RoutePlannerUrl &= "WantDescription=false&WantSpeedInfo=false&WantLocations=false&WantRouteData=false&"
RoutePlannerUrl &= "FormatString=&SubscriptionKey=" & SubscriptionKey
Try
httprequest = System.Net.WebRequest.Create(GazetteerUrl & FromPostalCode)
XMLDoc.Load(httprequest.GetResponse().GetResponseStream)
X1 = XMLDoc.Item("Location").Item("X").InnerText
Y1 = XMLDoc.Item("Location").Item("Y").InnerText
httprequest = System.Net.WebRequest.Create(GazetteerUrl & ToPostalCode)
XMLDoc.Load(httprequest.GetResponse().GetResponseStream)
X2 = XMLDoc.Item("Location").Item("X").InnerText
Y2 = XMLDoc.Item("Location").Item("Y").InnerText
RoutePlannerUrl &= "&DepartureX=" & X1 & "&DepartureY=" & Y1 & "&ArrivalX=" & X2 & "&ArrivalY=" & Y2
httprequest = System.Net.WebRequest.Create(RoutePlannerUrl)
XMLDoc.Load(httprequest.GetResponse().GetResponseStream)
Response.Write("Distance of the Route = " & XMLDoc.Item("RouteResult").Item("Distance").InnerText / 1000 & "km")
Catch
Response.Write("Getting the distance failed")
End Try