1 / 8

Google Maps API

Google Maps API. Calculating driving distance between two places. Google Distance Matrix API. https://developers.google.com/maps/documentation/distancematrix/. Google Maps Directions. Google Distance Matrix API. http://maps.googleapis.com/maps/api/distancematrix/xml

nikita
Télécharger la présentation

Google Maps API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Google Maps API Calculating driving distance between two places

  2. Google Distance Matrix API https://developers.google.com/maps/documentation/distancematrix/

  3. Google Maps Directions

  4. Google Distance Matrix API http://maps.googleapis.com/maps/api/distancematrix/xml ?origins=Halifax+NS&destinations=Sydney+NS&mode=driving&sensor=false

  5. API returns XML …How to get values into SAS? <DistanceMatrixResponse> <status>OK</status> <origin_address>Halifax, NS, Canada</origin_address> <destination_address>Truro, NS Canada</destination_address> <row> <element> <status>OK</status> <duration> <value>4167</value> <text>1 hour 9 mins</text> </duration> <distance> <value>94230</value> /* metres */ <text>94.2 km</text> </distance> </element> </row> </DistanceMatrixResponse>

  6. Ingredients • filename url “http:// …” • infilerecfm=s /* read as stream */ • Regular expressions to process XML • prxparse • prxmatch • prxposn

  7. %macrogmapsdist (ORIG, DEST); %let URL = str(http://maps.googleapis.com/maps/api/distancematrix/xml ?origins=)&ORIG. %nrstr(&destinations=)&DEST. %nrstr(&mode=driving&sensor=false); filename gmapsurl"&URL"; data _null_; /* Regular expression pattern to match XML tags and pull out distance value */ regex = prxparse("/\<distance>\s*\<value>(\d+)\<\/value>/"); infilegmapsrecfm=s lrecl=32767; input; if prxmatch(regex, _infile_) then distance = prxposn(regex, 1, _infile_); put distance; run; %mendgmapsdist;

  8. Resources • Driving Distances and Times, Using SAS® and Google Maps, Mike Zdeb • University at Albany, School of Public Health • Paper 043-29 An Introduction to Regular Expressions with Examples from Clinical Data, Richard Pless, Ovation Research Group, Highland Park, IL • Paper 119-29 Reading and Writing XML files from SAS®, Miriam Cisternas, Ovation Research Group, Carlsbad, CA Ricardo Cisternas, MGC Data Services, Carlsbad, CA • Paper 121-2012,Accessing and Extracting Data from the Internet Using SASR, George Zhu, SunitaGhosh, Alberta Health Services - Cancer Care

More Related