Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of...
Transcript of Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of...
![Page 1: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/1.jpg)
Location-aware Computing APIs for Location-based Services
Prof. Marco Di Felice Department of Computer Science and Engineering
University of Bologna
Context-Aware Systems
http://www.cs.unibo.it/difelice/
![Page 2: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/2.jpg)
APIs for Location-based services
2APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
COMPONENTSofLOCATION-BASEDSERVICESARCHITECTURE
Source:http://geoawesomeness.com/
Ø Wewillstillfocusonthepositioningtechnologies,butconsideringavailablelocalizationAPIs.
![Page 3: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/3.jpg)
Location-aware services
3
GeoDataACQUISITION
GeoDataMODELING
GeoDataSTORAGE
GeoDataVISUALIZATION
GeoDataAnalytics
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
![Page 4: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/4.jpg)
Location-aware services
4LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
APIsforOUTDOORLOCALIZATION(ANDGEO-INFORMATIONRETRIEVAL)
WEBSERVICES
![Page 5: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/5.jpg)
APIs for Location-based services
5
q SeveralgeoservicesandgeolocationAPIsareavailable(atleastforoutdoorscenarios).
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
![Page 6: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/6.jpg)
APIs for Location-based services
6
q GeolocationAPIsforlocation-basedservices
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
http://www.programmableweb.com/news/61-geolocation-apis-panoramio-google-gears-and-yahoo/2012/03/14
![Page 7: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/7.jpg)
7
APIs for Location-based services
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
q RepresentationalStateTransfer(REST)!setofarchitecturalprinciplesfordistributedsystems.1. ClientServeràInteractionsbasedonarequest-response
communicationpattern.2. UniformInterfacesàUnambigousstandardinterfacefor
accessingtheresources(e.g.theURI).3. Statelessàclientcontextandstatearenotstoredontheserver.4. Cacheableàdataarecachedbyclientsandintermediaries.5. LayeredSystemàintermediatecomponentscanhidewhatis
behindthem(e.g.contentdeliverynetworks).
![Page 8: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/8.jpg)
APIs for Location-based services
8
q SeveralgeoservicesandgeolocationAPIsareavailable(atleastforoutdoorscenarios).
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
![Page 9: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/9.jpg)
APIs for Location-based services
9
q W3CGeolocationAPIisaneffortbytheWorldWideWebConsortium(W3C)tostandardizeaninterfaceforretrievingthegeographicallocationinformationforaclient-side(Web)device.² HTML5GeolocationAPIissupportedbymostofthebrowser² Geolocationdata:latitude,longitude,accuracy,altitude,
altitude,altitudeAccuracy,speed,heading,timestamp² Mainmethods:getCurrentPosition()andwatchPosition()
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
![Page 10: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/10.jpg)
APIs for Location-based services
10
q HTML5GeolocationAPIcodeexample
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
interfaceGeolocation{voidgetCurrentPosition(PositionCallbacksuccessCallback,optionalPositionErrorCallbackerrorCallback,optionalPositionOptionsoptions);longwatchPosition(PositionCallbacksuccessCallback,optionalPositionErrorCallbackerrorCallback,optionalPositionOptionsoptions);voidclearWatch(longwatchId);};
Documentationandsourcecodeavailableat:http://www.w3schools.com/html/html5_geolocation.asp
![Page 11: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/11.jpg)
APIs for Location-based services
11
q HTML5GeolocationAPIcodeexample
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
<script>varx=document.getElementById("demo");functiongetLocation(){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(showPosition);}else{x.innerHTML="Geolocationisnotsupportedbythisbrowser.";}}functionshowPosition(position){x.innerHTML="Latitude:"+position.coords.latitude+"<br>Longitude:"+position.coords.longitude;}</script>
Documentationandsourcecodeavailableat:http://www.w3schools.com/html/html5_geolocation.asp
![Page 12: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/12.jpg)
APIs for Location-based services
12
q HTML5GeolocationAPIcodeexample
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:http://www.w3schools.com/html/html5_geolocation.asp
![Page 13: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/13.jpg)
APIs for Location-based services
13
q SeveralgeoservicesandgeolocationAPIsareavailable(atleastforoutdoorscenarios).
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
![Page 14: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/14.jpg)
APIs for Location-based services
14
q GoogleMapsAPI
² HTTP-basedWebserviceAPI
² WebclientAPI(Javascript)
² ProgramminglanguageAPI(Java,Python)
² MobileOSAPI(Android,iOS)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 15: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/15.jpg)
APIs for Location-based services
15
q GoogleMapswebservicesareacollectionofHTTPinterfacestoGoogleservicesprovidinggeographicdataformap-relatedapplications.² RESTfulservices;resourcesareidentifiedbyaidentifier,and
manipulatedbyusingacommonsetofHTTPmethods.² OutputsarereturnedinJSON/XMLformats.² Aregistrationkeyisneededtoaccesstheservices.
https://console.developers.google.com
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 16: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/16.jpg)
APIs for Location-based services
16
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 17: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/17.jpg)
APIs for Location-based services
17
q TheGoogleMapsGeolocationAPIprovidesthecurrentlocation(plustheaccuracyradius)
² Geolocationisperformedbyconsideringfingerprinting/triangulationtechniques,basedoncellulartowersandWiFinetworkstheuserscandetectattheirlocations(providedasinputs).
² Requests/responsesareformattedinJSON,andtransmittedusingPOSTmethodsoverHTTPS.
² TheAPIkeyisneededtoidentifytheapplication(andthequota)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 18: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/18.jpg)
APIs for Location-based services
18
q TherequestbodymustbeformattedinJSON.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
{"homeMobileCountryCode":310,"homeMobileNetworkCode":410,"radioType":"gsm","carrier":"Vodafone","considerIp":"true","cellTowers":[//CellTowerObjects.],"wifiAccessPoints":[//WiFiAccessPointObjects.]}
HOMENETWORKCOUNTRYCODE
HOMENETWORKNETWORKCODE
MOBILERADIOTYPE:gsm,lte,cdma,wcdma
UseIPaddresswhenwirelessnetworkinfoarenotavailable
Networkprovidername
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 19: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/19.jpg)
APIs for Location-based services
19
q TherequestbodymustbeformattedinJSON.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
{"cellTowers":[{"cellId":42,"locationAreaCode":415,"mobileCountryCode":310,"mobileNetworkCode":410,"age":0,"signalStrength":-60,"timingAdvance":15}]}
CELLTOWERSOBJECTEXAMPLE
TIMEOFARRIVALfrommobilenodetothebasestation
RECEIVEDSIGNALSTRENGTH(indbm)
UniqueCELLIDENTIFIER(mandatory)
AreaandNetworkIdentifiers(mandatory)
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 20: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/20.jpg)
APIs for Location-based services
20
q TherequestbodymustbeformattedinJSON.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
"wifiAccessPoints":[{"macAddress":"01:23:45:67:89:AB","signalStrength":-65,"age":0,"channel":11,"signalToNoiseRatio":40}]
WIFIOBJECTEXAMPLE
NOISEoverRECEIVEDSIGNAL(indb)
WIFIchannelusedbytheAP
MACADDRESSoftheAP(mandatory)
ReceivedSignalStrength(RSS)indbm
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 21: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/21.jpg)
APIs for Location-based services
21
q TheresponsebodymustbeformattedinJSON.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
{"location":{"lat":51.0,"lng":-0.1},"accuracy":1200.4}
Estimatedlatitudeandlongitudeoftheuser(indegrees)
Localizationerror,definedasaradius(inmeters)ofacirclecenteredattheestimatedlocationreturnedabove.
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 22: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/22.jpg)
APIs for Location-based services
22
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 23: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/23.jpg)
APIs for Location-based services
23
q TheGoogleMapsElevationAPIallowsdeterminingelevationdataforalllocationsonthesurfaceoftheearth,includingdepthlocationsontheoceanfloor.² Elevationdataareavailablethroughmeasurementsorinterpolation.
² Requests/responsesareformattedinJSONorXML,andtransmittedusingPOSTmethodsoverHTTPS.
² Requestscanbeissuedforfordiscretelocationsorforanorderedpath
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/elevation/outputFormat?parameters
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 24: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/24.jpg)
APIs for Location-based services
24
q Positionalrequestsareindicatedthroughuseofthelocationsparameter,indicatingelevationrequestsforthespecificlocations(latitude/longitudevalues).
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=YOUR_API_KEY
{"results":[{"elevation":1608.637939453125,"location":{"lat":39.73915360,"lng":-104.98470340},"resolution":4.771975994110107}],"status":"OK”} Minimumdistanceofinterpolation(inmeters)
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 25: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/25.jpg)
APIs for Location-based services
25
q Positionalrequestscanrefertotheelevationdataalongapathatspecifiedintervals.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/elevation/json?path=36.578581,-118.291994|36.23998,-116.83171&samples=3&key=YOUR_API_KEY
² Pathisacoupleoflatitude/longitudeofthestartandendpoint² Sampleisthenumberofsamplepointsalongapathforwhichtoreturnelevationdata
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 26: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/26.jpg)
APIs for Location-based services
26
q Positionalrequestscanrefertotheelevationdataalongapathatspecifiedintervals.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
{"results":[{"elevation":4411.941894531250,"location":{"lat":36.5785810,"lng":-118.2919940},"resolution":19.08790397644043},
{"elevation":1381.861694335938,"location":{"lat":36.41150289067028,"lng":-117.5602607523847},"resolution":19.08790397644043},{"elevation":-84.61699676513672,"location":{
"lat":36.239980,"lng":-116.831710},"resolution":19.087903}],"status":"OK"}
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 27: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/27.jpg)
APIs for Location-based services
27
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 28: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/28.jpg)
APIs for Location-based services
28
q Geocodingistheprocessofconvertingaddressesintogeographiccoordinates(latitude/longitude).
² Reversegeocodingistheprocessofconvertinggeocoordinates(latitude/longitude)intosymbolicaddresses(e.g.nation,city,address).
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/geocode/output?parameters
² OutputcanbeJSONorXML² Parametersaredifferentforgeocodingandreversegeocoding
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 29: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/29.jpg)
APIs for Location-based services
29
q Geocodingistheprocessofconvertingaddressesintogeographiccoordinates(latitude/longitude)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
PARAMETERSOFTHEGEOCODINGSERVICE
² Address!Thestreetaddressintheformatusedbythenationalpostalservice² ComponentsàAcomponentfilterofthegeocodingrequest
ü routematcheslongorshortnameofaroute.ü localitymatchesagainstbothlocalityandsublocalitytypes.ü administrative_areamatchesalltheadministrative_arealevels.ü postal_codematchespostal_codeandpostal_code_prefix.ü countrymatchesacountrynameoratwoletterISO3166-1countrycode.
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 30: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/30.jpg)
APIs for Location-based services
30APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY
{"results":[{…"formatted_address":"1600AmphitheatreParkway,
MountainView,CA94043,USA","geometry":{"location":{"lat":37.4224764,"lng":-122.0842499},"location_type":"ROOFTOP”,
"viewport":{"northeast":{"lat":37.4238253802915,"lng":-122.0829009197085},"southwest":{"lat":37.4211274197085,"lng":-122.0855988802915}}…
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 31: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/31.jpg)
APIs for Location-based services
31
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 32: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/32.jpg)
APIs for Location-based services
32
q GoogleMapsDirectionsAPIallowscalculatingdirectionsbetweenlocations(non-trackingservice).
² Directionsmayspecifyorigins,destinationsandwaypoints² Result(JSON/XML)containalistofwaypoints² Directionscanbeprovidedforseveralmodesoftransportation,
includingtransit,driving,walkingorcycling.² Timeintrafficcanbeestimated.² Preferencesfortransitroutes(less_walkingorfewer_transfers)
canbeprovidedasinput.APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 33: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/33.jpg)
APIs for Location-based services
33
q GoogleMapsDirectionsAPIallowscalculatingdirectionsbetweenlocations(non-trackingservice).
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&avoid=highways&mode=cycling&key=YOUR_API_KEY
origin/destinationàaddressorgeocoordinatesmodeàdriving,walking,cycling,transitwaypointsàarrayofwaypoints,expressedascoordinatesoraddressesavoidàtolls,highways,ferriesorindoorarrival_time/departure_timeàusedfortransitdirectionstransit_modeàpreferredmodesoftransit(bus,subway,train,tram,rail)unitsàdistanceunittodisplayresults…
SOMEPARAMETERS
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 34: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/34.jpg)
APIs for Location-based services
34
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 35: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/35.jpg)
APIs for Location-based services
35
q GoogleMapsRoadsAPIallowsmappingGPScoordinatestothegeometryoftheroad,andtodeterminethespeedlimitalongtheroadsegments.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://roads.googleapis.com/v1/speedLimits?parameters&key=YOUR_API_KEY
² path!Listofcoordinates(latitude/longitude),separatedbycommas² placeIdàplaceIDoftheroadsegment,returnedbythesnapToRoadsmethod
² unitsàspeedlimitsinkilometersormilesperhour.
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 36: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/36.jpg)
APIs for Location-based services
36APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
https://roads.googleapis.com/v1/speedLimits?placeId=ChIJ1Wi6I2pNFmsRQL9GbW7qABM&placeId=ChIJ58xCoGlNFmsRUEZUbW7qABM&key=YOUR_API_KEY
"speedLimits":[{"placeId":"ChIJ1Wi6I2pNFmsRQL9GbW7qABM","speedLimit":60,"units":"KPH"},{"placeId":"ChIJ58xCoGlNFmsRUEZUbW7qABM","speedLimit":60,"units":"KPH"},}]
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 37: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/37.jpg)
APIs for Location-based services
37
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 38: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/38.jpg)
APIs for Location-based services
38
q TheGoogleMapsTimeZoneAPIallowsrequestingthetimezoneforalocationontheearth,aswellasthatlocationtimeoffsetfromtheUTC
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/timezone/outputFormat?parameters
² location!comma-separatedlat,lngtuple(eg.location=-33.86,151.20)² timestamp!desiredtimeassecondssincemidnight,January1,1970UTC.
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 39: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/39.jpg)
APIs for Location-based services
39
q TheGoogleMapsTimeZoneAPIallowsrequestingthetimezoneforalocationontheearth,aswellasthatlocationtimeoffsetfromtheUTC
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510×tamp=1331161200&key=YOUR_API_KEY
{"dstOffset":0,"rawOffset":-28800,"status":"OK","timeZoneId":"America/Los_Angeles","timeZoneName":"PacificStandardTime"}
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 40: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/40.jpg)
APIs for Location-based services
40
q MainGoogleMapswebservices² GoogleMapsGeolocationAPI² GoogleMapsElevationAPI² GoogleMapsGeocodingAPI² GoogleMapsDirectionsAPI² GoogleMapsRoadsAPI² GoogleMapsTimeZoneAPI² GooglePlacesAPI
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 41: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/41.jpg)
APIs for Location-based services
41
q TheGooglePlacesAPIreturnsinformationaboutplaces,definedasestablishments,geographiclocations,orprominentpointsofinterest.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
² PlaceSearchesreturnalistofplacesbasedonauser'slocationorsearchstring.² PlaceDetailsrequestsreturninformationaboutaspecificPlace(e.g.reviews)
² PlaceAddallowaddingdatatotheGooglePlacesdatabase² PlacePhotosgivesaccesstothePlacerelatedphotosstoredinGoogle'sPlacedatabase.² PlaceAutocompletecanbeusedtoautomaticallyfillinthenameand/oraddressofaplace² QueryAutocompletecanbeusedtoprovideaquerypredictionservicefortext-based
geographicsearches,byreturningsuggestedqueriesasyoutype.
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 42: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/42.jpg)
APIs for Location-based services
42
q TheGooglePlacesAPIreturnsinformationaboutplaces,definedasestablishments,geographiclocations,orprominentpointsofinterest.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
https://maps.googleapis.com/maps/api/place/nearbysearch/jsonlocation=-33.8670522,151.1957362&radius=500&type=restaurant&name=Italia&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.503186,-0.126446&radius=5000&type=museum&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants+in+Sydney&key=
Documentationandsourcecodeavailableat:https://developers.google.com/maps/web-services/
![Page 43: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/43.jpg)
APIs for Location-based services
43
q GoogleMapsAPI
² HTTP-basedWebserviceAPI
² WebclientAPI(Javascript)
² High-levelProgramminglanguageAPI(Java,Python)
² MobileOSAPI(Android,iOS)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
![Page 44: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/44.jpg)
Location-aware services
44LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
APIsforOUTDOORLOCALIZATION
MOBILEAPPLICATIONS(ANDROIDOS)
![Page 45: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/45.jpg)
Location-aware services
45LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
² GPSmodulesmightpresentaseriousbatterydrainproblemduetotheirhighcomputationload
KleomenisKatevas,HamedHaddadi,LaurissaTokarchuk,SensingKit:EvaluatingtheSensorPowerConsumptioniniOSdevices,https://arxiv.org/abs/1606.05576
![Page 46: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/46.jpg)
Location-aware services
46LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
² GPSmodulesmightpresentaseriousbatterydrainproblemduetotheirhighcomputationload
Per-phaseconsumption Consumptionfordifferentaccuracies
KongyangChen,GuangTan,andMingmingLu,ImprovingtheEnergyPerformanceofGPSReceiversforLocationTrackingApplications,2017IEEEConferenceonComputerCommunicationsWorkshops(INFOCOMWKSHPS):2017IEEEInfocomMiseNetWorkshop
![Page 47: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/47.jpg)
Location-aware services
47LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
² GPSmodulesmightpresentaseriousbatterydrainproblemduetotheirhighcomputationload
MeeyeonLee,Deok-KiKimandJung-WonLee,AnalysisofCharacteristicsofPowerConsumptionforContext-AwareMobileApplications,Information2014,5,612-621;doi:10.3390/info5040612
OUTDOOR(GPS)
INDOOR(WI-FI)
OUTDOOR(GPS)
![Page 48: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/48.jpg)
Location-aware services
48LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
APIvsmeterbasedconsumptionvalues
ImmanuelKönig,AbdulQudoosMemon,KlausDavid,EnergyconsumptionofthesensorsofSmartphones,TenthInternationalSymposiumonWirelessCommunicationSystems2013
![Page 49: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/49.jpg)
APIs for Location-based services
49APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
HOWtogetthecurrentpositioninAndroid?
LOCATIONMANAGER
GPSprovider Wi-Fiprovider Cellularprovider
LOCATIONLISTENER
Locationchanged!
[interface]
NETWORKPROVIDER
![Page 50: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/50.jpg)
APIs for Location-based services
50APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
q InAndroid,thebatteryconsumptionofLocation-awareapplicationscanbemanagedbyproperlysettingthreeconfigurationparametersofthemobileapp:
https://developer.android.com/guide/topics/location/battery
² Accuracy:Theprecisionofthelocationdata.Ingeneral,thehighertheaccuracy,thehigherthebatterydrain.
² Frequency:Howoftenlocationiscomputed.Themorefrequentlocationiscomputed,themorebatteryisused.
² Latency:Howquicklylocationdataisdelivered.Lesslatencyusuallyrequiresmorebattery.
![Page 51: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/51.jpg)
APIs for Location-based services
51APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
q InAndroid,thebatteryconsumptionofLocation-awareapplicationscanbemanagedbyproperlysettingthreeconfigurationparametersofthemobileapp:
https://developer.android.com/guide/topics/location/battery
² Accuracy:Theprecisionofthelocationdata.Ingeneral,thehighertheaccuracy,thehigherthebatterydrain.
LocationRequestmLocationRequest=newLocationRequest();mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
PRIORITY_HIGH_ACCURACY,PRIORITY_BALANCED_POWER_ACCURACY,PRIORITY_LOW_POWER,PRIORITY_NO_POWER
Usesalllocationproviders
Passivelocalization,itexploitslocalizatioupdatesfromotherapps
![Page 52: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/52.jpg)
APIs for Location-based services
52APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
q InAndroid,thebatteryconsumptionofLocation-awareapplicationscanbemanagedbyproperlysettingthreeconfigurationparametersofthemobileapp:
https://developer.android.com/guide/topics/location/battery
² Frequency:Howoftenlocationiscomputed.Themorefrequentlocationiscomputed,themorebatteryisused.
LocationRequestmLocationRequest=newLocationRequest();mLocationRequest.setInterval(10000);mLocationRequest.setFastestInterval(5000);
Intervalatwhichlocationcomputedforotherappsisdeliveredtothecurrentapp
![Page 53: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/53.jpg)
APIs for Location-based services
53APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
q InAndroid,thebatteryconsumptionofLocation-awareapplicationscanbemanagedbyproperlysettingthreeconfigurationparametersofthemobileapp:
https://developer.android.com/guide/topics/location/battery
² Latency:Howquicklylocationdataisdelivered.Lesslatencyusuallyrequiresmorebattery.
LocationRequestmLocationRequest=newLocationRequest();mLocationRequest.setInterval(10000);mLocationRequest.setMaxWaitTime(50000);
Thisvalueshouldbeconsiderablelargerthantheinterval
![Page 54: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/54.jpg)
APIs for Location-based services
54APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
q InAndroid,thebatteryconsumptionofLocation-awareapplicationscanbemanagedbyproperlysettingthreeconfigurationparametersofthemobileapp:
https://developer.android.com/guide/topics/location/battery
1. RemoveLocationUpdatesifnotneeded2. Setatimeoutofwhenthelocationupdateshouldstop3. Usepassivelocationupdatesandproperlysettheupdateparameters
LocationRequestrequest=newLocationRequest();request.setInterval(15*60*1000);request.setFastestInterval(2*60*1000);
![Page 55: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/55.jpg)
APIs for Location-based services
55APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
q FusedlocationproviderAndroidAPIs.² Itmergesthelocalizationoutputsofdifferentlocalization
providersforbetteraccuracy.² Itmanages/hidestheunderlyinglocationtechnology(i.e.
GPS,cellularbasedorWiFibased).² Itallowstheusertospecifyrequirementsatahighlevel,
likehighaccuracyorlowpower.² Itsupportsgeofencingandactivityrecognition.
![Page 56: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/56.jpg)
APIs for Location-based services
56
q STEP1-Requestlocationpermissions
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.google.android.gms.location.sample.basiclocationsample"><uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION"/><uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION"/></manifest>
ANDROIDMANIFEST.XML
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 57: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/57.jpg)
APIs for Location-based services
57
q STEP2–ConnecttoGooglePlayservices
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
if(mGoogleApiClient==null){mGoogleApiClient=newGoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();}…mGoogleApiClient.connect();
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 58: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/58.jpg)
APIs for Location-based services
58
q STEP3–Getthelastknownlocation
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
publicvoidonConnected(BundleconnectionHint){mLastLocation=
LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);if(mLastLocation!=null){
mLatitudeText.setText(String.valueOf(mLastLocation.getLatitude()));mLongitudeText.setText(String.valueOf(mLastLocation.getLongitude()));}}
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 59: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/59.jpg)
APIs for Location-based services
59
q STEP4–Createalocationrequest
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
LocationRequestmLocationRequest=newLocationRequest();mLocationRequest.setInterval(10000);mLocationRequest.setFastestInterval(5000);mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationSettingsRequest.Builderbuilder=newLocationSettingsRequest.Builder().addLocationRequest(mLocationRequest);
Interval–inmilliseconds-ofupdates
PRIORITY_BALANCED_POWER_ACCURACY,PRIORITY_HIGH_ACCURACY,PRIORITY_LOW_POWER,PRIORITY_NO_POWER
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 60: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/60.jpg)
APIs for Location-based services
60
q STEP5–ReceiveLocationupdates
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,mLocationRequest,this);
publicclassMainActivityextendsActionBarActivityimplementsConnectionCallbacks,OnConnectionFailedListener,LocationListener{...@OverridepublicvoidonLocationChanged(Locationlocation){mCurrentLocation=location;
…}
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 61: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/61.jpg)
APIs for Location-based services
61
q Geofencingisatechniquetodefinevirtualboundariesofageographicarea,andtolocalizeauseroverit.
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Geofenceàpoint(latitude/longitude)plusaradiusAneventistriggeredeachtimetheuserentersorexitsthegeofence,ordwellslongerthanagivenintervaloftime.Eachgeofenceisassociatedtoanexpirationtime
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 62: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/62.jpg)
APIs for Location-based services
62
q STEP1–Createageofenceobject
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
mGeofenceList.add(newGeofence.Builder()//SettherequestIDofthegeofence..setRequestId(entry.getKey()).setCircularRegion(entry.getValue().latitude,entry.getValue().longitude,Constants.GEOFENCE_RADIUS_IN_METERS).setExpirationDuration(Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS).setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER|Geofence.GEOFENCE_TRANSITION_EXIT).build());
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 63: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/63.jpg)
APIs for Location-based services
63
q STEP2–Definetheinitialtriggerevents
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
mGeofenceList.add(newGeofence.Builder()//SettherequestIDofthegeofence..setRequestId(entry.getKey()).setCircularRegion(entry.getValue().latitude,entry.getValue().longitude,Constants.GEOFENCE_RADIUS_IN_METERS).setExpirationDuration(Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS).setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER|Geofence.GEOFENCE_TRANSITION_EXIT).build());
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 64: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/64.jpg)
APIs for Location-based services
64
q STEP3–AddgeofencesandIntents
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
LocationServices.GeofencingApi.addGeofences(mGoogleApiClient,mGeofenceList,getGeofencePendingIntent())
privatePendingIntentgetGeofencePendingIntent(){Intentintent=newIntent(this,GeofenceTransitionsIntentService.class);returnPendingIntent.getService(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);}
Documentationandsourcecodeavailableat:http://developer.android.com/training/location/index.html
![Page 65: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/65.jpg)
Location-aware services
65LOCATIONINTELLIGENCE&SPATIALDATAANALYSIS
MARCODIFELICE
APIsforINDOORLOCALIZATION(BASEDONWIRELESSTECHNOLOGIES)
![Page 66: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/66.jpg)
APIs for Indoor Localization
66
q IndoorAtlas(https://www.indooratlas.com)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
SDKavailableat:https://www.indooratlas.com
q Localizationbygeomagnetictechnology(i.e.analysisoftheEarth’smagneticfield)
q Supportsindoornavigation,geo-fencingandway-finding.
![Page 67: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/67.jpg)
APIs for Indoor Localization
67
q IndoorAtlas(https://www.indooratlas.com)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
SDKavailableat:https://www.indooratlas.com
q Client-serverarchitecture,basedonfoursteps
1. CreateLocationandAddmapfloor(throughaWebapplication)
2. Setwaypoints(throughamobileapp)3. Walkthroughthewaypoints,andautomatically
gathersensordata(e.g.magnetometer)4. Importthemap,andaddlocation-based
featuresthroughthemobileapplication
![Page 68: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/68.jpg)
APIs for Indoor Localization
68
q IndoorAtlas(https://www.indooratlas.com)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
SDKavailableat:https://www.indooratlas.com
q SDKforAndroidandIOSoperatingsystemsLocationupdatesareprovidedbytheIALocationListenerinterfaceandtheonLocationChanged()callbackmethod,andareexpressedasabsolutecoordinates(LAT;LONG).
privateIALocationListenermIALocationListener=newIALocationListener(){@OverridepublicvoidonLocationChanged(IALocationlocation){
Log.d(TAG,"Latitude:"+location.getLatitude());Log.d(TAG,"Longitude:"+location.getLongitude());
}};
![Page 69: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/69.jpg)
APIs for Indoor Localization
69
q ESTIMOTE(http://developer.estimote.com/android/)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Furtherinformationavailableat:http://developer.estimote.com/android/
Android/IOSSDKforindoorlocalizationandLocalizationbasedservicesthroughBeaconsq Defineindoorgeofenceregions
q MonitortheBLEsignal
q TriggercorrespondingactionbasedondetectedBeacon
![Page 70: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/70.jpg)
APIs for Indoor Localization
70
q ESTIMOTE(http://www.i-locate.eu/the-virtual-hub/)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Furtherinformationavailableat:http://developer.estimote.com/android/
EachBeaconisidentifiedbythreevalues:
² UUID,commonlyrepresentedasastring,e.g.“B9407F30-F5F8-466E-AFF9-25556B57FE6D”
² majornumber,anunsignedshortinteger,i.e.,anintegerrangingfrom1to65535,(0isareservedvalue)
² minornumber,alsoanunsignedshortinteger,likethemajornumber.
![Page 71: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/71.jpg)
APIs for Indoor Localization
71
q ESTIMOTE(http://www.i-locate.eu/the-virtual-hub/)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Furtherinformationavailableat:http://developer.estimote.com/android/
beaconManager=newBeaconManager(getApplicationContext());//addthisbelow:beaconManager.connect(newBeaconManager.ServiceReadyCallback(){@OverridepublicvoidonServiceReady(){beaconManager.startMonitoring(newRegion("monitoredregion",UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"),22504,48827));}});
DEFINETHEREGION
![Page 72: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/72.jpg)
APIs for Indoor Localization
72
q ESTIMOTE(http://www.i-locate.eu/the-virtual-hub/)
APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICESMARCODIFELICE
Furtherinformationavailableat:http://developer.estimote.com/android/
beaconManager.setMonitoringListener(newBeaconManager.MonitoringListener(){@OverridepublicvoidonEnteredRegion(Regionregion,List<Beacon>list){ DOSOMETHING}@OverridepublicvoidonExitedRegion(Regionregion){ DOSOMETHING}});
DEFINETHEACTION
![Page 73: Location-aware Computing · APIs for Location-based services 28 q Geocoding is the process of converting addresses into geographic coordinates (latitude/longitude). ² Reverse geocoding](https://reader034.fdocuments.us/reader034/viewer/2022043007/5f91f3238124752ca241d7cd/html5/thumbnails/73.jpg)
APIs for Indoor Localization
73APPLICATIONLAYERINTERFACES(API)FORLOCATION-BASEDSERVICES
MARCODIFELICE
INDOORLOCALIZATIONDEMOTHROUGHBLEBEACONS