Web Hosting:
Help Irongeek.com pay for bandwidth and research equipment:
Wigle Data to Google Earth (KML File)
Wigle Data to Google Earth (KML
File)
Google Earth showing Wireless
Access Points found by WiGLE along the Louisville, KY riverfront.
WiGLE is an online database of
Wireless Access Points (802.11A/B/G) that is contributed to by folks
using Netstumbler,
Kismet and other war
driving tools. WiGLE has a
web interface of
its own as well as Java desktop client called
JiGLE. There
is also a Google Maps
interface for the data made by Meblah, but rendering a map with
DHTML can be slow. That's why I wrote a PHP script that can take the
cached data from JiGLE (found in the \JiGLE\WiGLEnet\data directory
after you do a query) and turn it into a KML (Keyhole Markup Language)
file that's easy to import into the
Google Earth desktop application. With the generated KML file and
Google Earth it's easy to view and parse the access point found by WiGLE
users.
To use the
script make sure you have PHP installed on your box and issue a command
like the following:
I generated
my KML files by copying the autocache file from \JiGLE\WiGLEnet\data on
my Windows box to a Linux box then using the PHP script, but you may be
able to do it all from a Windows box if you have PHP installed. I then
took the resulting KML file (mywaps.kml) and opened it in Google Earth
on my Windows box. You will notice when you open the KML file that there
are two different icons for WAPs:
Obviously, the one on the left is for Access Points without WEP/WPA and
the one on the right is for ones with WEP/WPA enabled. If someone wants
to make be some better icons I'll use them.
Once you have it downloaded change the file extension
from ".txt" to ".php". I use to host a Gzipped version of the script,
but this seemed to confuse the MS Windows folks. :) I've tested it with
the latest Google Earth (4.0.1565 Beta) and it still seems to work fine.
If you have a large data set from a big metropolitan area expect Google
Earth to be rather slow. WiFi access point maps of Louisville Kentucky
makes Google Earth grind, I don't want to imagine what places like New
York or LA would make it do. If you want to turn your KML file output
into a compresses KMZ file just Zip it and change the extension from
".zip" to ".kmz" and your done. For examples of how to use this script
and its output see the two links below:
<?php
//wigle-to-kml.php version 1.2
//Wigle to KML (Keyhole Markup Language) Script
// by Adrian "Irongeek" Crenshaw http://www.irongeek.com
//Turns an .autocache file (Found in JiGLE\WiGLEnet\data directory)
into a kml file that can be loaded into Google Earth
//Example usage: php wigle-to-kml.php
_39.0_-87.0_38.0_-86.0.autocache > mywaps.kml
//WAP Icon based on Netstumbler's
// Filter help from http://www.analysisandsolutions.com/code/phpxml.htm
// Ver 1.1 Put WEPed WAPS in separate Folder so you do not have to
view them.
// Ver 1.2 Changed how bad characters are stripped from the SSID so
they would not mess up the XML.
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<kml xmlns=\"http://earth.google.com/kml/2.0\">
<Folder>
<name>WiGLE Data</name>
<open>1</open>
";
PrintKMLFolder($argv[1], 'Wigle WiFi Map (WEP On)', 'Y');
PrintKMLFolder($argv[1], 'Wigle WiFi Map (WEP Off)', 'N');
echo "</Folder>
</kml>";
function PrintKMLFolder($InputFileName, $FolderName, $WEPStatus)
{
$handle = fopen($InputFileName, "r");
echo "<Folder>
<name>$FolderName</name>
<open>1</open>
";
$data = fgetcsv($handle, 1000, "~"); // Skip first line
while (($data = fgetcsv($handle, 1000, "~")) !== FALSE) {
$ssid = $data[2];
// Escape ampersands that aren't part of entities.
$ssid= preg_replace('/&(?!\w{2,6};)/', '&', $ssid );
// Remove all non-visible characters except SP, TAB, LF and CR.
$ssid = preg_replace('/[^\x20-\x7E\x09\x0A\x0D]/', "\n", $ssid );