Main Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Khaytsus

Tools / Merge two sets of maps together
November 27, 2011, 04:07:52

I have a phone and a tablet..  I inevitably download data separately on both, but I'd like to not lose that data..  No point in downloading it twice, or trying to copy from one to another etc..  So I came up with a system I thought I'd share.  Maybe it's useful to a few other folks.

Note you'll clearly have to tweak this to your setup, paths you use, etc etc...  And note I only do Online maps, so these scripts are "hard coded" to the mapsOnline directory.  If you do other types, or multiple types, you'll have to modify accordingly.  And note I've just recently started doing this.  It seems to work, but you'll want to do testing of your own.  If you notice any mistakes or have suggestions, or even find it useful, feel free to say so!

I have a set of scripts on both devices which uploads and downloads the data to my server...  I use the "rsync for Android" in the market to get the rsync and ssh binaries to use in Android, but in reality I use run 'em in gscript (quicker to write a shell script and execute it than in the rsync Android gui).  Note here I'm also using keys so I'm not prompted for passphrases etc, so you'll probably want to do the same thing.  I already had this set up for backing up my SD card, so it was easy to re-use for Locus.

So here's the process I use..

First thing to do is change to the Blank map on both devices.  Otherwise I run into sqlite problems in Locus, I presume because the database is changing out from under Locus, not sure, Menion was looking into it at one point but not sure if he found anything he could fix here..  The symptom will be errors in logcat, but the obvious failure is that you can no longer add any tiles to the map, anything added will not persist next time you start Locus.  

So after I set the map to Blank on both devices, I run the script to sync the Locus data up to my server on both devices.  Then I run a shell script on my Linux box to combine the maps from the phone and tablet into one "merged" directory, ready for download.  Then I run the script to sync the Locus data back down to each device.  Probably take 15-20 minutes total I'm guessing to do the whole process if a lot of stuff has changed, so I typically won't be doing this unless I know I have "enough" data to share.

Now, here are the scripts..   These scripts are for my Dell Streak 7 tablet.  The scripts for my phone are similar, except they use "locus-n1" instead of "locus-ds7' so the files are kept separately between the two devices.

This script uploads /mnt/sdcard/Locus/ to my /media3/android/microsd/locus-ds7/ path on my Linux machine.

/data/data/eu.kowalczuk.rsync4android/files/rsync -rltDv
 -c --chmod=u=rwX,g=rX,o=rX
 -e "/data/data/eu.kowalczuk.rsync4android/files/ssh -l wally -y -i /sdcard/sdcard2/bin/etc/dropbear/dropbear_dss_host_key"
 /mnt/sdcard/Locus/ wally@

And the companion script which downloads the data back..  Note I only download the mapsOnline folder back down for now..  I haven't quite figured out if I can or want to merge points databases..  This copies down from the Linux box's /media3/android/microsd/locus-merged/mapsOnline/ folder back down to my locus maps directory to update it to the newly merged data.


/data/data/eu.kowalczuk.rsync4android/files/rsync -rltDv
 -c --chmod=u=rwX,g=rX,o=rX
 -e "/data/data/eu.kowalczuk.rsync4android/files/ssh -l wally -y -i /sdcard/sdcard2/bin/etc/dropbear/dropbear_dss_host_key"

And I'll attach the shell script here rather than paste it..  Read over it.  What I'm doing is if a file exists in both directories and it does NOT have the same md5sum, I'm merging the two together into the "merge" directory.  After that, I look in both directories.  If a file exists that does not exist in the "merge" directory, I copy it.  This catches the databases which were the same on both paths (checksum) and those which only existed on one device.
The following users thanked this post: ColdAutumn