Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Know You User's Location

Know You User's Location

Presented at JEEConf 2015 http://jeeconf.com/

Anton Moiseev

May 22, 2015
Tweet

More Decks by Anton Moiseev

Other Decks in Technology

Transcript

  1. Agenda • What is geolocation? Why it’s important? • Ways

    to determine user’s location • Disclaimer: everything is on the client-side, examples in Dart 3
  2. Geolocation • The process of determining current user’s location on

    Earth. • Location is anything - address, restaurant name, coordinates, etc. 4
  3. Geocoding Geocoding - readable place name to the coordinate: 5

    { "latitude": 40.7484405, "longitude": -73.98566439999999 } "Empire State Building" Reverse geocoding - coordinate to a readable place name: "350 5th Avenue, New York, NY 10118, USA" { "latitude": 40.7484405, "longitude": -73.985664 }
  4. EasyInsure • Geolocation is business critical: • Searching for closest

    agents • Illegal to offer agents w/o a licence in the user’s state • Matching users to the right agents based on the neighbourhood • Coordinates inside digital signatures 6
  5. 7

  6. 8

  7. How? IP address is matched against a location using DB

    1. Client makes an HTTP request 2. TCP/IP connection established, server gets IP, makes lookup query 3. Database tries to match IP against a record, returns result to the server 4. Server returns result to the client 1. HTTP 2. 108.59.10.15 3. Manassas, VA 4. Manassas, VA 10
  8. Report #1 Distance Accuracy 0-2 km 26% 2-10 km 11%

    10-25 km 6% 25-50 km 5% 50-100 km 5% 100-250 km 6% 250-500 km 12% 500-1000 km 8% 1000+ km 22% Resource - http://goo.gl/pEiCLK User reported accuracy of determined locations 13
  9. Report #2 Resource - https://goo.gl/YxFM2I Distance Correctly Incorrectly 250 km

    93% 4% 100 km 89% 7% 50 km 84% 13% 25 km 76% 21% 10 km 59% 38% Exact City 53% 43% Exact Zip 40% 57% How many determined locations fall within certain distance from the true IP location: 15
  10. ZIP (Postal Code) Even exact ZIP code is not enough,

    example - Washington, DC 20002 16
  11. Problem #2 Ай-пи? Alabama • Doesn’t work around the globe

    • Unresolved IP (postal scale): US - 3%, Canada - 18%, UK - 72% (source) 17
  12. How it works? geolocation.getCurrentPosition(enableHighAccuracy: true) 1 2 3 4 1.

    GPS 2. Wi-Fi access points positioning 3. Cell tower triangulation 4. IP address lookup 21
  13. The Hybrid Approach Goal: 1. Approximate result - as soon

    as possible 2. Accurate result - as soon as available 23
  14. Cache location 25 0 1 2 3 Milliseconds 0 500

    1000 1500 2000 2500 3000 3500 4000 Cache IP HTML5 Geolocation response timeline 100-200 1000-2200 2000-3500
  15. Unify location format 26 {
 "query_status" : {
 "query_status_code" :

    "OK",
 "query_status_description" : "Query successfully performed."
 },
 "ip_address" : "108.59.8.208",
 "geolocation_data" : {
 "continent_code" : "NA",
 "continent_name" : "North America",
 "country_code_iso3166alpha2" : "US",
 "country_code_iso3166alpha3" : "USA",
 "country_code_iso3166numeric" : "840",
 "country_code_fips10-4" : "US",
 "country_name" : "United States",
 "region_code" : "DE",
 "region_name" : "Delaware",
 "city" : "-",
 "latitude" : 39.6734,
 "longitude" : -75.7052,
 "isp" : "Leaseweb USA",
 "organization" : "Leaseweb USA"
 }
 } {
 "timestamp": 1431434095513,
 "coords": {
 "speed": null,
 "heading": null,
 "altitudeAccuracy": null,
 "accuracy": 150,
 "altitude": null,
 "longitude": -82.391989,
 "latitude": 28.123217
 }
 } IP provider format: HTML5 format: