Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Advanced Geolocationfor the Mobile Web
Andy Gup, @agup
How to get a good location
Challenges
Solutions
Smartphone/Tablet GPS
Built for consumer use-cases
Accuracy only needs to be “good enough”
Tiny antenna on bottom of device
Geolocation Object
Say what, 4887 meters accuracy???
Indoors using WiFi-only
Demo
http://github.com/esri/html5-geolocation-tool-js
Best possible accuracy…under perfect conditions
3 – 10 meters
10 – 33 feet
Problem 1: location fluctuations
Problem 2: all locations lumped together
Network location
GPS location
??
Use case: Stationary…
5 minutes!
Problem 3: Accuracy will vary
Bad
So-so
GoodTime vs Accuracy
Problem 3: Accuracy will vary
Bad
So-so
GoodTime vs Accuracy
Accuracy vs Precision
Low AccuracyHigh Precision
High AccuracyLow Precision
High AccuracyHigh Precision
Problem 4: GPS needs to warm up!
Initial readings less accurate or non-existent
Technical Use Case: Cold Start
GPS takes time to calibrate
Phone rebooted
Updated phone OS
Potential for no cached values
Potential for large inaccuracy
Technical Use Case: Warm start
GPS has been in use continuouslyGPS is (mostly) calibrated
Highest potential for accuracy and precision
Using the Geolocation API options
errorHandler()
Timeout
maximumAge – used only during startup
enableHighAccuracy
Snapshot location – Not Reliable!
navigator.geolocation.getCurrentPosition();
watchId = navigator.geolocation.watchPosition(
processGeolocation,
/* OPTIONAL */
geolocationError,
{
timeout: 0,
maximumAge: Infinity,
enableHighAccuracy: true
}
);
Continuous location
maximumAge (ms)
Max age of cached position in milliseconds
“0” – do not use cache
“Infinity” – (default) return any cached value
timeout (ms)
Max milliseconds to return a positionThrow error if no location at timeoutWith watchPosition() can throw error repeatedly
“Infinity” – (default) don’t return until position available
enableHighAccuracy(boolean)
Try to obtain best possible result
If GPS available and perms enabled -- use it
If Geolocation Service available -- use it
– Requires an internet connection!
– WiFi and/or Cellular
watchPosition scenario 1:
{
timeout: 30000,
maximumAge: 300000
}
Request result < 30 secondsAccept cache value < 5 mins old
watchPosition scenario 2:
{
timeout: 60000,
maximumAge: Infinity
}
Request result < 1 minuteReturn any cache value
watchPosition scenario 3:
{
timeout: 60000,
maximumAge: 0,
enableHighAccuracy: true
}
Request result < 1 minuteDo NOT use cache, try GPS
Browser Geolocation AccuracyDepends on …
Type of browserType of deviceWi-Fi On/OffGPS On/OffLocation user permissionsVPN
Force phone to use GPS
Solution 1: Post-process bufferingSolution 2: Cordova pluginSolution 3: 1 and/or 2 + external GPS
Solution 1:Buffering to determine center point
Capture many points
Average all values
Calculate centroid
[{lat:-120,lon:35}, {lat:-120.01,lon:35.1}, {lat:-120.011,lon:35.02}, {lat:-120,lon:35.1}, {lat:-120,lon:35}]
JavaScriptData Collection
Field location template
github.com/esri/html5-geolocation-tool-js
Solution 2:Cordova/PhoneGap & Geolocation
Taps native SDKs via plugins
Direct access to geolocation functionality
Can track geolocation while in background
Battery usage optimization
cordova-plugin-advanced-gelocation
https://github.com/Esri/cordova-plugin-advanced-geolocation
Separates GPS from Network location
Multi-threaded for high performance
Calculates centroid
Android only!
Native functionality
Separates network locations
from GPS locations
External GPS
Can provide greater accuracy and precision
Can provide faster location acquisition
Connect via USB or Bluetooth
Example: Trimble R1Sub-meter accuracy*
Works with Geolocation API
Overrides onboard GPS
Works on iOS and Android
On extra step on Android
A GPS Experiment
START POINT
Commercial GPS Smartphone GPS
Solution 3: buffer, plugin + external GPS
Take a close look at use casesStudy your requirements
Recap
Consumer vs Commercial case casesConsumer vs Commercial equipment
Accuracy vs Precision
Getting the best static location
Questions?
Andy Gup, Esri Developer Advocatehttp://[email protected]@agup
Works with..
Works with…