SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
An architecture to handle reverse
geocoding
laurent@zen.ly
Zenly is a location app that lets you
know what friends and family are
up to in real-time.
The app is focused on location, and
therefore relies a lot on adresses.
Our users do millions of reverse
geocoding's everyday and it has to
work :)
The operation to transform a latitude/longitude into an address.
Handled by CoreLocation : ReverseGeocoder one simple API.
public typealias CLGeocodeCompletionHandler = ([CLPlacemark]?, NSError?) -> Void
// reverse geocode requests
public func reverseGeocodeLocation(location: CLLocation,
completionHandler: CLGeocodeCompletionHandler)
May return multiple placemarks.
Reverse geocoding
In practice
Take one, use it, forget it….
Usually data comes from two providers NAVTEQ and TELEATLAS.
Other APIs available : Google (do not mix and match), open data…
Simply search for “Free reverse geocoding”.
CoreLocation hides everything.
When problems start
Some applications may want to display multiple adresses for
multiple people, possibly moving … … and we bump into a limit.
Apple writes: “avoid more than one per minute and do it when UI
needs it”. Problem of count and rate.
Empirically it can handle one every few seconds.
If too many: longer answer time and then errors.
“Boss, we need to pay Google”
Architecture leading to a problem
Being purely model driven leads to problems.
User Address
Reverse Geocode
Location Change
UI
User Address
Reverse Geocode
Location Change
User Address
Reverse Geocode
Location Change
Thinking bias
Get UI components ready ASAP to avoid spinning wheel.
Optimize in a time based manner.
Optimize in the context of one user only.
Improvements
Global.
Cache.
Scheduling.
Priority and UI driven.
Track identifier.
Do only what is necessary!
Global operation
Avoid to use “reverse geocoding on the go”.
One available through a unique object (Singleton).
Handle both time based and position based consideration and
optimization.
Make sure an operation can be redistributed through multiple places.
Only one object is responsible.
Data structure
func reverseGeocode<T:ReverseGeocodable>(geocodableObject:T?, identifier:String?,
priority:ReverseGeocodingPriority,
completionHandler: CLGeocodeCompletionHandler?) -> ReverseGeocodeResult
struct GeopositioningRunningInfo:CustomStringConvertible {
var priority:ReverseGeocodingPriority = ReverseGeocodingPriority.Normal
var context:Any? = nil
var handlers:[Any] = []
var identifier:String?
}
Cache
Based on coordinates….but how to encode this ?
Geohash: a division of the planet and many nice things
(neighbors…). See Wikipedia !.
Must have a resolution: level. May depend on where you are!
Implementation through an NSCache where key is geohash and
value the originally received CLPlacemarks.
Scheduled operations should be considered: multiple handlers.
Multiple people in the same place.
Geohash samples
//Paris: Zenly office
var aPos:Pos = Pos(latitude:48.868117, longitude:2.355915)
var geoHash:String = (ServiceReverseGeocoder.sharedGeocoder.geoHashString(aPos, level: 8))!
XCTAssert(geoHash == "u09wj85t")
geoHash = (ServiceReverseGeocoder.sharedGeocoder.geoHashString(aPos, level: 3))!
XCTAssert(geoHash == "u09")
geoHash = (ServiceReverseGeocoder.sharedGeocoder.geoHashString(aPos, level: 1))!
XCTAssert(geoHash == "u")
Downscaled information in no network.
Scheduling
Avoid flooding the Apple Reverse Geocoder.
Schedule operation on a heartbeat (timer).
Do nothing in the background.
Stop when all is done.
If error: next operation can be progressively delayed.
Don’t trap yourself!
Scheduling Principle
func reverseGeocode<T:ReverseGeocodable>(geocodableObject:T?, identifier:String?,
priority:ReverseGeocodingPriority,
completionHandler: CLGeocodeCompletionHandler?) -> ReverseGeocodeResult
{
var result = ReverseGeocodeResult.DefaultLaunch
//Do pre check
//Keep where we are in order to start heartbeat if necessary
let countBefore:Int = self.reverseGeocodingCount()
//More stuff
//Start heartbeat if needed
let countAfter:Int = self.reverseGeocodingCount()
if 0 == countBefore && countAfter > 0 {
self.heartbeat = Foundation.NSTimer.scheduledTimerWithTimeInterval(self.GeocodingServiceHeartbeatValue,
target: self, selector:#selector(_doExecuteHeartBeat(_:)) , userInfo: nil, repeats: true)
self.heartbeat?.tolerance = self.GeocodingServiceHeartbeatTolerance
}
return result
}
Priority
Arbitrary number: 3 sounds good for normal usage.
Very simple FIFO model : 3 FIFOs as queues.
Heartbeat is unstacking the queues.
Operations can be moved between queues.
Should be settable on a more permanent basis: use cautiously!
Priorities are to be used!!!!
Priority queues
HighMedium
u09wj85t
u09wj86d
ke7fynh8
6gyqdy5u
6gyqdy5v
drt2xp2mu09wj84f
Normal
Heart
beat
UI driven
Medium High Medium
Track identifier
Follow someone moving
T1
T2
T3
T4
T5
T6
Implementation details
Follow someone moving.
Identifier can be a user UUID but we can think of other cases (e.g UI).
We do not want to encode position of the past.
An operation with an identifier replaces the previous one.
Should handle both identifier and priority.
One more improvement: still keep a delivery ratio.
Thank You!
https://zen.ly/join

Contenu connexe

Tendances

Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...
Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...
Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...Mozza
 
235629204 snapchat-business-deck
235629204 snapchat-business-deck235629204 snapchat-business-deck
235629204 snapchat-business-deckYan Rozovsky
 
WEB 3 Marketing to boost customer engagement and loyalty.pdf
WEB 3 Marketing  to boost customer engagement and loyalty.pdfWEB 3 Marketing  to boost customer engagement and loyalty.pdf
WEB 3 Marketing to boost customer engagement and loyalty.pdfJimmy Pons
 
Warc - Marketers Toolkit 2023.pdf
Warc - Marketers Toolkit 2023.pdfWarc - Marketers Toolkit 2023.pdf
Warc - Marketers Toolkit 2023.pdfdigitalinasia
 
Digital 2022 India (February 2022) v01
Digital 2022 India (February 2022) v01Digital 2022 India (February 2022) v01
Digital 2022 India (February 2022) v01DataReportal
 
The State of Creativity 2023
The State of Creativity 2023The State of Creativity 2023
The State of Creativity 2023Social Samosa
 
60 Min Brand Strategist NEW
60 Min Brand Strategist NEW60 Min Brand Strategist NEW
60 Min Brand Strategist NEWIdris Mootee
 
AppVirality.com - Investor Pitch Deck
AppVirality.com - Investor Pitch DeckAppVirality.com - Investor Pitch Deck
AppVirality.com - Investor Pitch DeckLaxman Papineni
 
Ogilvy_SL_SOCIAL MEDIA TRENDS 2023.pdf
Ogilvy_SL_SOCIAL MEDIA TRENDS 2023.pdfOgilvy_SL_SOCIAL MEDIA TRENDS 2023.pdf
Ogilvy_SL_SOCIAL MEDIA TRENDS 2023.pdfMishellie
 
Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01
Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01
Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01DataReportal
 
Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...
Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...
Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...Mozza
 
MoEngage: Next Generation Marketing Cloud
MoEngage: Next Generation Marketing CloudMoEngage: Next Generation Marketing Cloud
MoEngage: Next Generation Marketing CloudMoEngage Inc.
 
What's Next: Authenticity - The Struggle is Real
What's Next: Authenticity - The Struggle is RealWhat's Next: Authenticity - The Struggle is Real
What's Next: Authenticity - The Struggle is RealOgilvy Consulting
 
Digital 2021 Czechia (January 2021) v01
Digital 2021 Czechia (January 2021) v01Digital 2021 Czechia (January 2021) v01
Digital 2021 Czechia (January 2021) v01DataReportal
 
12 Mobile Growth Tactics for App Launch, Acquisition and Retention
12 Mobile Growth Tactics for App Launch, Acquisition and Retention12 Mobile Growth Tactics for App Launch, Acquisition and Retention
12 Mobile Growth Tactics for App Launch, Acquisition and RetentionAdrien Montcoudiol
 
dentsu 2022 media trends
dentsu 2022 media trendsdentsu 2022 media trends
dentsu 2022 media trendsdentsu
 
Zenpayroll Pitch Deck Template
Zenpayroll Pitch Deck TemplateZenpayroll Pitch Deck Template
Zenpayroll Pitch Deck TemplateJoseph Hsieh
 
Digital 2022 Egypt (February 2022) v01
Digital 2022 Egypt (February 2022) v01Digital 2022 Egypt (February 2022) v01
Digital 2022 Egypt (February 2022) v01DataReportal
 
Lyft presentation
Lyft presentationLyft presentation
Lyft presentationBilly Irwin
 

Tendances (20)

Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...
Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...
Organic Acquisition: How To Acquire A Million Users With Zero Marketing (mobi...
 
235629204 snapchat-business-deck
235629204 snapchat-business-deck235629204 snapchat-business-deck
235629204 snapchat-business-deck
 
WEB 3 Marketing to boost customer engagement and loyalty.pdf
WEB 3 Marketing  to boost customer engagement and loyalty.pdfWEB 3 Marketing  to boost customer engagement and loyalty.pdf
WEB 3 Marketing to boost customer engagement and loyalty.pdf
 
Warc - Marketers Toolkit 2023.pdf
Warc - Marketers Toolkit 2023.pdfWarc - Marketers Toolkit 2023.pdf
Warc - Marketers Toolkit 2023.pdf
 
Investor deck q2 2017 (1)
Investor deck q2 2017 (1)Investor deck q2 2017 (1)
Investor deck q2 2017 (1)
 
Digital 2022 India (February 2022) v01
Digital 2022 India (February 2022) v01Digital 2022 India (February 2022) v01
Digital 2022 India (February 2022) v01
 
The State of Creativity 2023
The State of Creativity 2023The State of Creativity 2023
The State of Creativity 2023
 
60 Min Brand Strategist NEW
60 Min Brand Strategist NEW60 Min Brand Strategist NEW
60 Min Brand Strategist NEW
 
AppVirality.com - Investor Pitch Deck
AppVirality.com - Investor Pitch DeckAppVirality.com - Investor Pitch Deck
AppVirality.com - Investor Pitch Deck
 
Ogilvy_SL_SOCIAL MEDIA TRENDS 2023.pdf
Ogilvy_SL_SOCIAL MEDIA TRENDS 2023.pdfOgilvy_SL_SOCIAL MEDIA TRENDS 2023.pdf
Ogilvy_SL_SOCIAL MEDIA TRENDS 2023.pdf
 
Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01
Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01
Digital 2022: Essential Facebook Messenger Stats for Q1 2022 v01
 
Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...
Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...
Mobile Gamification - How The Best Apps Nailed It (Waze, Duolingo, Tinder, Sn...
 
MoEngage: Next Generation Marketing Cloud
MoEngage: Next Generation Marketing CloudMoEngage: Next Generation Marketing Cloud
MoEngage: Next Generation Marketing Cloud
 
What's Next: Authenticity - The Struggle is Real
What's Next: Authenticity - The Struggle is RealWhat's Next: Authenticity - The Struggle is Real
What's Next: Authenticity - The Struggle is Real
 
Digital 2021 Czechia (January 2021) v01
Digital 2021 Czechia (January 2021) v01Digital 2021 Czechia (January 2021) v01
Digital 2021 Czechia (January 2021) v01
 
12 Mobile Growth Tactics for App Launch, Acquisition and Retention
12 Mobile Growth Tactics for App Launch, Acquisition and Retention12 Mobile Growth Tactics for App Launch, Acquisition and Retention
12 Mobile Growth Tactics for App Launch, Acquisition and Retention
 
dentsu 2022 media trends
dentsu 2022 media trendsdentsu 2022 media trends
dentsu 2022 media trends
 
Zenpayroll Pitch Deck Template
Zenpayroll Pitch Deck TemplateZenpayroll Pitch Deck Template
Zenpayroll Pitch Deck Template
 
Digital 2022 Egypt (February 2022) v01
Digital 2022 Egypt (February 2022) v01Digital 2022 Egypt (February 2022) v01
Digital 2022 Egypt (February 2022) v01
 
Lyft presentation
Lyft presentationLyft presentation
Lyft presentation
 

En vedette

CocoaPods for private libraries
CocoaPods for private librariesCocoaPods for private libraries
CocoaPods for private librariesCocoaHeads France
 
OSX Complex Application Challenge Architecture
OSX Complex Application Challenge ArchitectureOSX Complex Application Challenge Architecture
OSX Complex Application Challenge ArchitectureCocoaHeads France
 
A little respect for MVC part 1 par Gegoire Lhotellier
A little respect for MVC part 1 par Gegoire LhotellierA little respect for MVC part 1 par Gegoire Lhotellier
A little respect for MVC part 1 par Gegoire LhotellierCocoaHeads France
 
MultiPeer Connectivity Framework
MultiPeer Connectivity Framework MultiPeer Connectivity Framework
MultiPeer Connectivity Framework CocoaHeads France
 
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeatureBlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeatureCocoaHeads France
 
Swift Sequences & Collections
Swift Sequences & CollectionsSwift Sequences & Collections
Swift Sequences & CollectionsCocoaHeads France
 
Gatekeeper par Guillaume Faure
Gatekeeper par Guillaume FaureGatekeeper par Guillaume Faure
Gatekeeper par Guillaume FaureCocoaHeads France
 
Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...
Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...
Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...CocoaHeads France
 

En vedette (20)

CocoaPods for private libraries
CocoaPods for private librariesCocoaPods for private libraries
CocoaPods for private libraries
 
Silent push
Silent pushSilent push
Silent push
 
OSX Complex Application Challenge Architecture
OSX Complex Application Challenge ArchitectureOSX Complex Application Challenge Architecture
OSX Complex Application Challenge Architecture
 
OHHttpStubs
OHHttpStubsOHHttpStubs
OHHttpStubs
 
A little respect for MVC part 1 par Gegoire Lhotellier
A little respect for MVC part 1 par Gegoire LhotellierA little respect for MVC part 1 par Gegoire Lhotellier
A little respect for MVC part 1 par Gegoire Lhotellier
 
Apple Search Optimization
Apple Search OptimizationApple Search Optimization
Apple Search Optimization
 
App-resizer Library
App-resizer LibraryApp-resizer Library
App-resizer Library
 
POI clusturing
POI clusturingPOI clusturing
POI clusturing
 
Mastering Interface Builder
Mastering Interface BuilderMastering Interface Builder
Mastering Interface Builder
 
Découverte de HomeKit
Découverte de HomeKitDécouverte de HomeKit
Découverte de HomeKit
 
MultiPeer Connectivity Framework
MultiPeer Connectivity Framework MultiPeer Connectivity Framework
MultiPeer Connectivity Framework
 
Conférence DotSwift 2016
Conférence DotSwift 2016Conférence DotSwift 2016
Conférence DotSwift 2016
 
Swift open source
Swift open sourceSwift open source
Swift open source
 
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeatureBlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
 
Swift Sequences & Collections
Swift Sequences & CollectionsSwift Sequences & Collections
Swift Sequences & Collections
 
Gatekeeper par Guillaume Faure
Gatekeeper par Guillaume FaureGatekeeper par Guillaume Faure
Gatekeeper par Guillaume Faure
 
Plugins Xcode
Plugins XcodePlugins Xcode
Plugins Xcode
 
Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...
Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...
Genius scan - Du boostrap à 20 millions d’utilisateurs, techniques et outils ...
 
3D Touch
3D Touch3D Touch
3D Touch
 
BitTorrent on iOS
BitTorrent on iOSBitTorrent on iOS
BitTorrent on iOS
 

Similaire à Zenly - Reverse geocoding

Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native appsInnovationM
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operationsMateusz Grzechociński
 
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONELUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONEMicrosoft Mobile Developer
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingGabor Paller
 
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...Bruno Salvatore Belluccia
 
Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010Christian Heilmann
 
Android Loaders : Reloaded
Android Loaders : ReloadedAndroid Loaders : Reloaded
Android Loaders : Reloadedcbeyls
 
Where20 2008 Ruby Tutorial
Where20 2008 Ruby TutorialWhere20 2008 Ruby Tutorial
Where20 2008 Ruby TutorialShoaib Burq
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)Jose Manuel Pereira Garcia
 
Average- An android project
Average- An android projectAverage- An android project
Average- An android projectIpsit Dash
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automationMario Fusco
 
Common mistakes in android development
Common mistakes in android developmentCommon mistakes in android development
Common mistakes in android developmentHoang Nguyen Huu
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
GeoDjango & HTML5 Geolocation
GeoDjango & HTML5 GeolocationGeoDjango & HTML5 Geolocation
GeoDjango & HTML5 GeolocationJohn Paulett
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaExoLeaders.com
 

Similaire à Zenly - Reverse geocoding (20)

Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native apps
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
 
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONELUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processing
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
 
Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010
 
Android Loaders : Reloaded
Android Loaders : ReloadedAndroid Loaders : Reloaded
Android Loaders : Reloaded
 
DIY Uber
DIY UberDIY Uber
DIY Uber
 
Mobile optimization
Mobile optimizationMobile optimization
Mobile optimization
 
Where20 2008 Ruby Tutorial
Where20 2008 Ruby TutorialWhere20 2008 Ruby Tutorial
Where20 2008 Ruby Tutorial
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Average- An android project
Average- An android projectAverage- An android project
Average- An android project
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automation
 
Common mistakes in android development
Common mistakes in android developmentCommon mistakes in android development
Common mistakes in android development
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
Phone Gap
Phone GapPhone Gap
Phone Gap
 
GeoDjango & HTML5 Geolocation
GeoDjango & HTML5 GeolocationGeoDjango & HTML5 Geolocation
GeoDjango & HTML5 Geolocation
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 

Plus de CocoaHeads France

Plus de CocoaHeads France (20)

Mutation testing for a safer Future
Mutation testing for a safer FutureMutation testing for a safer Future
Mutation testing for a safer Future
 
iOS App Group for Debugging
iOS App Group for DebuggingiOS App Group for Debugging
iOS App Group for Debugging
 
Asynchronous swift
Asynchronous swiftAsynchronous swift
Asynchronous swift
 
Visual accessibility in iOS11
Visual accessibility in iOS11Visual accessibility in iOS11
Visual accessibility in iOS11
 
My script - One year of CocoaHeads
My script - One year of CocoaHeadsMy script - One year of CocoaHeads
My script - One year of CocoaHeads
 
Ui testing dealing with push notifications
Ui testing dealing with push notificationsUi testing dealing with push notifications
Ui testing dealing with push notifications
 
CONTINUOUS DELIVERY WITH FASTLANE
CONTINUOUS DELIVERY WITH FASTLANECONTINUOUS DELIVERY WITH FASTLANE
CONTINUOUS DELIVERY WITH FASTLANE
 
L'intégration continue avec Bitrise
L'intégration continue avec BitriseL'intégration continue avec Bitrise
L'intégration continue avec Bitrise
 
Super combinators
Super combinatorsSuper combinators
Super combinators
 
Design like a developer
Design like a developerDesign like a developer
Design like a developer
 
Handle the error
Handle the errorHandle the error
Handle the error
 
Quoi de neuf dans iOS 10.3
Quoi de neuf dans iOS 10.3Quoi de neuf dans iOS 10.3
Quoi de neuf dans iOS 10.3
 
IoT Best practices
 IoT Best practices IoT Best practices
IoT Best practices
 
SwiftyGPIO
SwiftyGPIOSwiftyGPIO
SwiftyGPIO
 
Présentation de HomeKit
Présentation de HomeKitPrésentation de HomeKit
Présentation de HomeKit
 
Programme MFI retour d'expérience
Programme MFI retour d'expérienceProgramme MFI retour d'expérience
Programme MFI retour d'expérience
 
How to communicate with Smart things?
How to communicate with Smart things?How to communicate with Smart things?
How to communicate with Smart things?
 
Build a lego app with CocoaPods
Build a lego app with CocoaPodsBuild a lego app with CocoaPods
Build a lego app with CocoaPods
 
Let's migrate to Swift 3.0
Let's migrate to Swift 3.0Let's migrate to Swift 3.0
Let's migrate to Swift 3.0
 
Project Entourage
Project EntourageProject Entourage
Project Entourage
 

Dernier

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 

Dernier (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 

Zenly - Reverse geocoding

  • 1. An architecture to handle reverse geocoding laurent@zen.ly
  • 2. Zenly is a location app that lets you know what friends and family are up to in real-time. The app is focused on location, and therefore relies a lot on adresses. Our users do millions of reverse geocoding's everyday and it has to work :)
  • 3. The operation to transform a latitude/longitude into an address. Handled by CoreLocation : ReverseGeocoder one simple API. public typealias CLGeocodeCompletionHandler = ([CLPlacemark]?, NSError?) -> Void // reverse geocode requests public func reverseGeocodeLocation(location: CLLocation, completionHandler: CLGeocodeCompletionHandler) May return multiple placemarks. Reverse geocoding
  • 4. In practice Take one, use it, forget it…. Usually data comes from two providers NAVTEQ and TELEATLAS. Other APIs available : Google (do not mix and match), open data… Simply search for “Free reverse geocoding”. CoreLocation hides everything.
  • 5. When problems start Some applications may want to display multiple adresses for multiple people, possibly moving … … and we bump into a limit. Apple writes: “avoid more than one per minute and do it when UI needs it”. Problem of count and rate. Empirically it can handle one every few seconds. If too many: longer answer time and then errors. “Boss, we need to pay Google”
  • 6. Architecture leading to a problem Being purely model driven leads to problems. User Address Reverse Geocode Location Change UI User Address Reverse Geocode Location Change User Address Reverse Geocode Location Change
  • 7. Thinking bias Get UI components ready ASAP to avoid spinning wheel. Optimize in a time based manner. Optimize in the context of one user only.
  • 8. Improvements Global. Cache. Scheduling. Priority and UI driven. Track identifier. Do only what is necessary!
  • 9. Global operation Avoid to use “reverse geocoding on the go”. One available through a unique object (Singleton). Handle both time based and position based consideration and optimization. Make sure an operation can be redistributed through multiple places. Only one object is responsible.
  • 10. Data structure func reverseGeocode<T:ReverseGeocodable>(geocodableObject:T?, identifier:String?, priority:ReverseGeocodingPriority, completionHandler: CLGeocodeCompletionHandler?) -> ReverseGeocodeResult struct GeopositioningRunningInfo:CustomStringConvertible { var priority:ReverseGeocodingPriority = ReverseGeocodingPriority.Normal var context:Any? = nil var handlers:[Any] = [] var identifier:String? }
  • 11. Cache Based on coordinates….but how to encode this ? Geohash: a division of the planet and many nice things (neighbors…). See Wikipedia !. Must have a resolution: level. May depend on where you are! Implementation through an NSCache where key is geohash and value the originally received CLPlacemarks. Scheduled operations should be considered: multiple handlers. Multiple people in the same place.
  • 12. Geohash samples //Paris: Zenly office var aPos:Pos = Pos(latitude:48.868117, longitude:2.355915) var geoHash:String = (ServiceReverseGeocoder.sharedGeocoder.geoHashString(aPos, level: 8))! XCTAssert(geoHash == "u09wj85t") geoHash = (ServiceReverseGeocoder.sharedGeocoder.geoHashString(aPos, level: 3))! XCTAssert(geoHash == "u09") geoHash = (ServiceReverseGeocoder.sharedGeocoder.geoHashString(aPos, level: 1))! XCTAssert(geoHash == "u") Downscaled information in no network.
  • 13. Scheduling Avoid flooding the Apple Reverse Geocoder. Schedule operation on a heartbeat (timer). Do nothing in the background. Stop when all is done. If error: next operation can be progressively delayed. Don’t trap yourself!
  • 14. Scheduling Principle func reverseGeocode<T:ReverseGeocodable>(geocodableObject:T?, identifier:String?, priority:ReverseGeocodingPriority, completionHandler: CLGeocodeCompletionHandler?) -> ReverseGeocodeResult { var result = ReverseGeocodeResult.DefaultLaunch //Do pre check //Keep where we are in order to start heartbeat if necessary let countBefore:Int = self.reverseGeocodingCount() //More stuff //Start heartbeat if needed let countAfter:Int = self.reverseGeocodingCount() if 0 == countBefore && countAfter > 0 { self.heartbeat = Foundation.NSTimer.scheduledTimerWithTimeInterval(self.GeocodingServiceHeartbeatValue, target: self, selector:#selector(_doExecuteHeartBeat(_:)) , userInfo: nil, repeats: true) self.heartbeat?.tolerance = self.GeocodingServiceHeartbeatTolerance } return result }
  • 15. Priority Arbitrary number: 3 sounds good for normal usage. Very simple FIFO model : 3 FIFOs as queues. Heartbeat is unstacking the queues. Operations can be moved between queues. Should be settable on a more permanent basis: use cautiously! Priorities are to be used!!!!
  • 18. Track identifier Follow someone moving T1 T2 T3 T4 T5 T6
  • 19. Implementation details Follow someone moving. Identifier can be a user UUID but we can think of other cases (e.g UI). We do not want to encode position of the past. An operation with an identifier replaces the previous one. Should handle both identifier and priority. One more improvement: still keep a delivery ratio.