
Chapter 35. Geolocation without GPS

From the website:

  Killer Game Programming in Java
  http://fivedots.coe.psu.ac.th/~ad/jg

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the website.

Thanks,
  Andrew

============================

Topics: use IP and MAC addresses of WiFi Access Points to obtain
        latitude, longitude, and geographical addresses.

Directory contents

There are 10 Java files:
 * AddrViewer.java
     - find the IP and MAC addresses of the device

 * DetectIP.java
 * DetailsUsingIP.java
     - find IP addresses of an outward facing device (a WiFi router)

 * GoogleMAC.java
 * SkyhookMAC.java
     - use MAC addresses to look up latitude and longitude information

 * GoogleLatLong.java
 * OSMLatLong.java
 * YahooLatLong.java
      - use a latitude and longitude to lookup geographical addresses

 * Whois.java
      - use an IP address  to lookup geographical addresses

 * WebUtils.java
     - a utility class for saving JSON code to a file
     - developed in "Chapter 33. Using Web Service APIs"
       http://fivedots.coe.psu.ac.th/~ad/jg/ch33/

One JAR file:
  * json.jar     
     - for processing JSON data
     - explained in "Chapter 33. Using Web Service APIs"
       http://fivedots.coe.psu.ac.th/~ad/jg/ch33/


There are 2 batch files:
  * compile.bat
  * run.bat
     - both batch files assume that json.jar is in the current directory


Two subdirectories:
  * Place Lab Code\:	for finding MAC addresses using the Place Lab API
  * WNV Code\:	for finding MAC addresses using the NirSoft WirelessNetView tool

----------------------------
Compilation:

 > javac AddrViewer.java

 > javac DetectIP.java

 > javac DetailsUsingIP.java

 > compile GoogleMAC.java   
     - uses JSON

 > javac SkyhookMAC.java
     - before compiling, you should assign values to the USER_NAME 
       and REALM constants. You can obtain values when you register 
       for the Skyhook SDK at http://www.skyhookwireless.com/

 > compile GoogleLatLong.java
 > compile OSMLatLong.java
 > compile YahooLatLong.java
     - uses JSON
     - before compiling YahooLatLong.java, you should assign a value 
       to the APP_ID constant. You can obtain a value from  
       http://developer.yahoo.com/geo/placefinder/

 > javac Whois.java

----------------------------
Execution:

 > java AddrViewer

 > java DetectIP

 > java DetailsUsingIP [ <IP_address> ]
    e.g.
      > java DetailsUsingIP
      > java DetailsUsingIP 66.12.74.247


 > run GoogleMAC <MAC_address> [<signal strength>]   
     - uses JSON
    e.g.
      > run GoogleMAC 00:90:D0:f5:29:D2
      > run GoogleMAC 00:25:84:03:19:50 -90


 > java SkyhookMAC <MAC address> [ <signal stength> ]
   e.g.
     > java SkyhookMAC 00:90:d0:f5:29:d2
       - I always get the error message "Unable to determine location"


 > run GoogleLatLong <latitude> <longitude>
 > run OSMLatLong <latitude> <longitude>
 > run YahooLatLong <latitude> <longitude>
     - uses JSON
   e.g.
     > run GoogleLatLong 7.0032811 100.4939958
     > run OSMLatLong 7.0032811 100.4939958
     > run YahooLatLong 7.0032811 100.4939958


 > java Whois <IP_address>
   e.g.
     > java Whois 202.12.74.244

---------
Last updated: 27th November 2010
