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

Serving Location-based data

Serving Location-based data

by Julian Shen @LINE Developer Meetup https://linegroup.kktix.cc/events/20200918

LINE Developers Taiwan

September 18, 2020
Tweet

More Decks by LINE Developers Taiwan

Other Decks in Technology

Transcript

  1. Julian Shen • Graduated from NCTU • Joined LINE from

    2017 • Backend engineer • Dev Lead of LINE SPOT Team • Live in Hsinchu, work at Neihu @jlnshen julianshen Who am I ?
  2. What is a Location-based service (LBS) Is a software service

    which utilizes geographic data and information to provide services or information to users 適地性服務
  3. Search by location Finding something nearby Finding something somewhere 進入了城隍廟步行區

    新竹的咖啡廳 Sorting/Ranking by distance Search geo shapes Knowing which area I am Check if in service area 新竹市在服務範圍內 附近三公里內的藥局 Geo coding/Reverse Geo Coding
  4. Geospatial data Location: • Latitude • Longitude • Elevation* Name

    Address ..... 24.7861672 新竹市東區大學路1001 國立交通大學 120.9973317
  5. NCTU Costco TSMC NCHU   Big City  

       R (24.7861672, 120.9973317) MOS NOVA 7-11 7-11 7-11 7-11 7-11 7-11 7-11 D Finding all 7-11 in range (D<R) Euclidean distance? X Scan all data in DB?
  6. NCTU Costco TSMC NCHU   Big City  

       (24.7861672, 120.9973317) MOS NOVA 7-11 7-11 7-11 7-11 7-11 7-11 7-11 Indexing location-based data 1 2 3 4 5 6 7 8 9 A B C 1 0 1 1 A B C 1 K-D Tree …
  7. Luckily, you don’t need to invent wheels again Mongo DB

    Elastic Search Postgres SQL MySQL Redis
  8. NCTU Costco TSMC NCHU   Big City  

       R MOS NOVA 7-11 7-11 7-11 7-11 7-11 7-11 7-11 D Finding all 7-11 in range (D<R)  Julian Evan (24.7861672, 120.9973317) (24.7861671, 120.9973318) • Julian & Evan should get similar results • GPS coordinates will never be the same even if you stay in the same place • Caching results is a problem
  9. 1 2 0 4 5 h j n p 3

    6 7 k m q r 8 9 d e s t w x z y v u g f c b t w ws ws wsq wsqj125tf wsqj125t0 wsqj125t wsqj125tfb Geohash Level 1 Level 2 Level 3 Level 8
  10. Geohash length Cell width Cell height 1 ≤ 5,000km 5,000km

    2 ≤ 1,250km 625km 3 ≤ 156km 156km 4 ≤ 39.1km 19.5km 5 ≤ 4.89km 4.89km 6 ≤ 1.22km 0.61km 7 ≤ 153m 153m 8 ≤ 38.2m 19.1m 9 ≤ 4.77m 4.77m 10 ≤ 1.19m 0.596m 11 ≤ 149mm 149mm 12 ≤ 37.2mm 18.6mm Precision