Wednesday, April 20, 2011

Mapping the cell locations from an iphone db on google maps

IOs stores the GPS locations of towers it connects to in this file:

/var/root/Library/Cache/locationd/consolidated.db

It's an sqlite3 file... So here is a script to pull the longtitude and lattitudes and turn them into a simple KML file.
#/bin/bash

#this is the KML heading
echo '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>

  <name>youri</name>'
 
#pull the longitude and latitude from sqlite3
for i in $(sqlite3 consolidated.db 'select longitude,latitude from celllocation';)
do coordinate=$(echo $i | sed 's/|/,/g')



echo '<Placemark><name>'$coordinate'</name><Point><coordinates>'$coordinate',0</coordinates></Point></Placemark>'
done;

echo '</Document></kml>'


I added this to my lighttpd.conf and restarted it.

  ".kml"       =>      "application/vnd.google-earth.kml+xml",

Then it's just a matter of passing the kml file to google maps..

http://maps.google.com/maps?q=http://$yourserver/output.kml

I noticed a bunch of towers I never connected to  (far away places) so there are some problems with this.

No comments:

Post a Comment