Accessing client GPS data

This article relates to Anoto Live™ forms versions 3.5.2 and below.  GPS data is delivered in the standard XML output in Anoto Live Forms 4.5 and higher.

GPS basics

The Global Positioning System (GPS) is a U.S. space-based global navigation satellite system. It provides reliable positioning, navigation, and timing services to worldwide users on a continuous basis in all weather, day and night, anywhere on or near the Earth.  GPS has become a widely used aid to navigation worldwide, and a useful tool for map-making, land surveying, commerce, scientific uses, tracking and surveillance. 

Anoto Live™ forms and GPS

In ALF it is possible to use GPS for tracking purposes in two ways:

  • Document position - locate the position when the user sent the document. This is performed in the appserver, as a custom application
  • Continuous tracing - locate the position of the user continuously. This is performed in the registry, as explained below.

What GPS data is available from the mobile client

From the GPS in the mobile device client we capture the following information:

  • Latitude
  • Longitude
  • Time
  • Precision in meters 
  • Interval: every second minute and when a pen document is sent

How does it work?

If the ALF mobile client has GPS support enabled, it will transmit its coordinates to the server every second minute or when a form is submitted. The server records this information in the system Registry. For the information to be accessed you write a specific 'event handler' within /var/opt/dpp-registry/gpsInfoHandler.php. In this file you should create a class called GpsInfoHandler, which has a method called handleInfo() to handle the GPS data as you wish.

For example, to just dump some information about a user to a file on the server, the following code can be used:

<? class GpsInfoHandler {   function handleInfo ($data)   {   if(!isset($data["X-XMS-GPSDataAtSend"]))     return;     $gpsData = $data["X-XMS-GPSDataAtSend"];     $splitData = explode(" ", $gpsData);     $precision = false;      if(count($splitData) == 0) //empty data - no gps info received     {       return;     } elseif(count($splitData) >= 3) //we have latitude, longitude and timestamp in raw format, for example 54.9595546333333 -1.47640988333333 1261411188     {       $latitude = $splitData[0];       $longitude = $splitData[1];       $timestamp = $splitData[2];     }     if(count($splitData) == 4) //we also have precision     $precision = $splitData[3];          $time = date("r", $timestamp); //human readable time, for example Thu, 21 Dec 2000 16:01:07 +0200     $user = $data["X-XMS-email"];      $message = "User $user was at longitude $longitude, latitude $latitude on $time.";     if($precision)     $message .= " Precision was $precision meters";      file_put_contents("/tmp/gps", $message);   } } ?> 

The output of this event handler will be to place the users GPS information within a file in the servers /tmp/gps folder. By manipulating this code you can include the GPS data within any workflow e.g. output it with the forms XML.

Anoto Live Forms 4.5

Since Anoto Live Forms 4.5, any GPS data collected is supplied in the standard XML output document under the <location> node e.g.

<location longitude="-1.002165" latitude="52.946446" description="" created="2016-12-06T12:32:40+00:00" accuracy="10"/> <location longitude="-1.002165" latitude="52.946446" description="" created="2016-12-06T12:32:50+00:00" accuracy="10"/>
Was this article useful? Thanks for the feedback There was a problem submitting your feedback. Please try again later.