java - MongoDB Geolocation using with Spring MVC -
i try implement gps tracking service application. i've service push geolocation data mongodb works well. problem each vehicle must send data in each 20 seconds.
as requirement should show latest 24 hours data in google maps makes problem receive huge data set. (4320 1 vehicle). there best practice in mongo or google maps receive less data , show line history? (response "json")
i assume json looks this:
{ id: 42, car_id: 102, coordinates: [ { lat: ..., lon: ..., timestamp: ... }, { lat: ..., lon: ..., timestamp: ... }, { lat: ..., lon: ..., timestamp: ... }, ... ] }
if use json, there 4 ways reduce size:
remove unused data
you remove duplicate entries list. if car stands still hour, have 180 identical entries in row. keep single one, because drawn line on map won't different.
remove
timestamp
if don't need it. if array ordered, might not need timestamp sorting.
shrink data representation
each character makes difference, if you've got 4320 entries. replace example
lat
,lon
x
,y
. reduces size4*4320 = 17280
characters.change representation. if don't need timestamp, simple reduce data structure
coordinates: [[1,2],[3,4],[5,6],...]
(where1
,3
,5
lat
part ,2
,4
,6
lon
part of coordinate). may reduce json size 20-40%.
compress data
- if possible use gzip (or other compression algorithm). way can shrink json output 10-20% of original size.
use more compact data format
have @ protocol buffers (from google). spring supports , there's javascript library.
there few other protocols can reduce data size. i.e. thrift (from apache / facebook), don't know if spring / javascript supports it.
that's can do.
Comments
Post a Comment