spring - How to efficiently store the LatLng route path coming from android application -
i'm working on android app keeps track of vehicle's location , sends latlng point every second spring webapp after click of button "start vehicle". need store location rendered in google maps show live location of vehicle on map. working fine but, have store obtained points show complete route traversed when driver clicks "stop vehicle" app.
i've applied following strategies seem inefficient , resource consuming:
- store location in list @ server side when each current location request arrives , preserve in servletcontext. keep on updating list every point received. problem: journey of around 1 hour, many points received , make big list consuming loads of memory. if server shuts down or crashes, servletcontext gone , whole data.
- store location in table row in db (using postgresql). problem: when should entry persisted in db? , making db transactions + consuming of database space? costly, right?
- do not store locations @ server side, keep current 1 live maps. rather preserve locations list @ android app side , send server when driver chooses stop vehicle. problem: sounds fair server's side, android phone able handle same big list , send in call server?
- using hibernate , ehcache. should consider that?
i stuck on how efficiently hogging least amount of resources , ofcourse reducing production server costs.
any appreciated both android, server , whole approach altogether:)
reduce data meaningful amounts:
- rather sending data on fixed time-interval, watch location changes.
- make location change threshold speed-dependent; @ highway speeds, 1 mile might accurate enough, whereas in city driving, might want resolution down 100 yards.
- collect data points in android app, , have interpolate it. if drive straight line between 2 cities, there's no reason report hundreds of intermediate points, rather end points.
Comments
Post a Comment