If you have a Nokia N95

check out the MLocation library here.

If you have a Windows Mobile

  1. Install GpsPortPPC.exe (free, simple) or GpsGate ($ but powerful) on your device to redirect GPS data stream to a TCP/IP port. Both will use port 20175 by default.

  2. Download the mGPS library (mGPS.zip), unzip it properly into your mobile processing "libraries" directry.

mGPS examples

The following two examples have almost the same output, by either actively pulling data or passively being updated.

mgps_screen01.png

Pull mode

mgpspull.zip

   1 import java.io.*;
   2 import javax.microedition.io.*;
   3 import nl.tue.id.mgps.*;
   4 
   5 GPS gps;
   6 GPSRecord r;
   7 
   8 PFont font;
   9 
  10 void setup(){
  11   font = loadFont(FACE_SYSTEM, STYLE_PLAIN, SIZE_SMALL);
  12   textFont(font);
  13   gps = new GPS(this);
  14   // ip address and port number can be changed:
  15   // gps = new GPS(this, "127.0.0.1", 20175); 
  16   gps.start();
  17 
  18 }
  19 
  20 void draw(){
  21   background(0);
  22   r = gps.getRecord();
  23   if(r!=null){
  24     text("courseMadeGood    : " + r.courseMadeGood, 0, 20);
  25     text("dateTimeOfFix     : " + r.dateTimeOfFix, 0, 40);
  26     text("groundSpeed       : " + r.groundSpeed, 0, 60);
  27     text("lattitude         : " + r.lattitude, 0, 80);
  28     text("lattitudeDirection: " + r.lattitudeDirection, 0, 100);
  29     text("longitude         : " + r.longitude, 0, 120);
  30     text("longitudeDirection: " + r.longitudeDirection, 0, 140);
  31     text("magneticVariation : " + r.magneticVariation, 0, 160);
  32     text("quality           : " + r.quality, 0, 180);
  33     text("satelliteCount    : " + r.satelliteCount, 0, 200);
  34     text("warning           : " + r.warning, 0, 220);
  35   }
  36   
  37   //if there is anything wrong, it will be logged.
  38   text(gps.getLog(), 0, 240, width, height-240);
  39 }

Push mode

mgpspush.zip

   1 import java.io.*;
   2 import javax.microedition.io.*;
   3 import nl.tue.id.mgps.*;
   4 
   5 GPS gps;
   6 GPSRecord r = null;
   7 String logMsg = "";
   8 
   9 PFont font;
  10 
  11 void setup(){
  12   noLoop();
  13   background(0);
  14   font = loadFont(FACE_SYSTEM, STYLE_PLAIN, SIZE_SMALL);
  15   textFont(font);
  16   gps = new GPS(this);
  17   // ip address and port number can be changed:
  18   // gps = new GPS(this, "127.0.0.1", 20175); 
  19   gps.start();
  20 
  21 }
  22 
  23 void draw(){
  24   if(r!=null){
  25     text("courseMadeGood    : " + r.courseMadeGood, 0, 20);
  26     text("dateTimeOfFix     : " + r.dateTimeOfFix, 0, 40);
  27     text("groundSpeed       : " + r.groundSpeed, 0, 60);
  28     text("lattitude         : " + r.lattitude, 0, 80);
  29     text("lattitudeDirection: " + r.lattitudeDirection, 0, 100);
  30     text("longitude         : " + r.longitude, 0, 120);
  31     text("longitudeDirection: " + r.longitudeDirection, 0, 140);
  32     text("magneticVariation : " + r.magneticVariation, 0, 160);
  33     text("quality           : " + r.quality, 0, 180);
  34     text("satelliteCount    : " + r.satelliteCount, 0, 200);
  35     text("warning           : " + r.warning, 0, 220);
  36   }
  37   
  38   //if there is anything wrong, it will be logged.
  39   text(logMsg, 0, 240, width, height-240);
  40 }
  41 
  42 void libraryEvent(Object library, int event, Object data) {
  43   if (library == gps) {
  44     switch (event) {
  45       case GPS.EVENT_GPS_UPDATED: //a GPSRecord is received.
  46         r = (GPSRecord) data;
  47         redraw();
  48         break;
  49       case GPS.EVENT_GPS_LOGMSG: //one message one time.
  50         logMsg = (String) data;
  51         redraw();
  52         break;
  53     }
  54   }
  55 }

GPSRecord

Most of the information in GPSRecord is recorded as a "String". see below for the definition:

   1 public class GPSRecord {    
   2         /**
   3          * Character that indicates a warning.
   4          */
   5     public static final String WARNING = "V";
   6     
   7     public String courseMadeGood = "";
   8     public String dateTimeOfFix = "";
   9     public String groundSpeed = "";
  10     public String lattitude = "";
  11     public String lattitudeDirection = "";
  12     public String longitude = "";
  13     public String longitudeDirection = "";
  14     public String magneticVariation = "";
  15     public String quality = "";    
  16     public String satelliteCount = "";
  17     public boolean warning;
  18 }

CreaPro: GpsInMobileProcessing (last edited 2008-11-23 16:10:52 by 195-241-239-132)