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:

  1. remove unused data

    1. 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.

    2. remove timestamp if don't need it. if array ordered, might not need timestamp sorting.

  2. shrink data representation

    1. each character makes difference, if you've got 4320 entries. replace example lat , lon x , y. reduces size 4*4320 = 17280 characters.

    2. change representation. if don't need timestamp, simple reduce data structure coordinates: [[1,2],[3,4],[5,6],...] (where 1, 3 , 5 lat part , 2, 4, 6 lon part of coordinate). may reduce json size 20-40%.

  3. compress data

    1. if possible use gzip (or other compression algorithm). way can shrink json output 10-20% of original size.
  4. use more compact data format

    1. have @ protocol buffers (from google). spring supports , there's javascript library.

    2. 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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -