User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

GUIDE: Send GPS data using HTTP to your web site

Sun Jul 08, 2007 9:06 pm

How to send GPS data using HTTP to a web site

This article is for developers who wants to post GPS data to his own web site using HTTP.

GpsGate 2.5.0 build 207 (and later) can send GPS data over http. Any web server can receive and process the position data sent to it.

Please follow those steps to configure GpsGate.
1. Start GpsGate
2. Open the Settings dialog
3. Go to the Output tab
4. Add a "GpsGate.com (Send)" plugin.
5. Click on "..." (or "More Options..." in the 2.6 Windows version)
6. Change the "Protocol" to "HTTP".
7. Set "Server" to your web server address E.g. www.myaddress.com
8. Set the "File path" to the script address. E.g. /gpsgate.php if /gpsgate.php is the page on your web server to process the requests. Do not forget the first "/".
8. Click OK
9. Now configure in which intervals you want GpsGate to send data to your web site.
10. Click OK.

URL format
The URL posted will have the following parameters:
longitude=34.2333&latitude=23.2222&altitude=34.0&speed=30.3&heading=234.5&date=20070529&time=123445.234&username=myuser&pw=encryptedpassword

longitude: Decimal degrees (WGS84)
latitude: Decimal degrees (WGS84)
altitude: Above sea level in meters.
speed: Speed over ground in knots
heading: Heading in degrees. 0 is north, 90 is east, 180 is south, 270 is west.
date: UTC data in the format: YYYYMMDD
time: UTC time in the format: HHMMSS.sss
username: The username specified.
password: The password specified with a simple encryption. The encryption/decryption algorithm can be found here:
http://forum.gpsgate.com/topic.asp?TOPIC_ID=5638

End user deployment
All configuration in GpsGate are stored in XML files ending with the extension .ggXML, you can use those files for simpler configuration. If you prepare one ggXML file and copy it to the "Chains" folder in the GpsGate root directory, you can have a menu option with your settings ready in GpsGate!

GpsGate for Windows will also allow you to install a ggxml file over the web by clicking on it in a browser (this feature will soon be available in the PPC version as well). In this way you can provide a link to the ggxml file which contains the configuration to send data to your website.

Additional info
Note that you can also send data over TCP/IP and UDP using the "GpsGate.com (Send)" PlugIn.

When you select to send data to another server, no data will be sent to GpsGate.com

Regards,
Johan

Franson Support

tonyh
Posts: 4
Joined: Thu Mar 22, 2007 10:21 pm

RE: GUIDE: Send GPS data using HTTP to your web site

Mon Jul 09, 2007 12:54 am

Tack så mycket Johan! Your service is incredible. I wish to express my gratitude by including some of my PHP Server-Side Code for the benefit of all of your GPS Gate customers who want to create dynamic Web services.

(This code is made available per GNU-GPL and, as such, no warranties or support is included or implied.) [:D]

Cheers,
Tony


Code: Select all

<font color="blue">
<?
//   SYNOPSIS: Demonstration Consumption of REST HTTP Parameters from
//   Franson GPSGate in to create simple XML database of position
//
//   IMPLEMENTATION NOTES: Server-side: Tested with PHP 5.x on
//   IIS server with IE client.  Client-side: Tested with Franson
//   GPSGate v2.5.0.207 on PC running Windows XP SP2.
//   You need to create an empty placeholder file named
//   position.xml in the same Web-accessible directory
//   as this file (consumeGPSGate.php).  Must grant "modify"
//   permissions to position.xml on sever.  Use your Web browser to
//   view position.xml to get the latest position after
//   GPSGate posts the HTTP REST parameters to this
//   file (consumeGPSGate.php).  Limitations: Currently stores
//   only one position based on intervals set at GPSGate client.
//
//   REDISTRIBUTION: Buy a Franson GPSGate License and feel free to
//   use this code per GNU GENERAL PUBLIC LICENSE (GNU - GPL) Version 3.0
//   http://www.gnu.org/licenses/gpl-3.0.txt
//
//   Thank you Johan and the rest of the franson.com team for helping
//   me out!...8 July 2007 - Tony in San Diego (tonyh on franson.com forum)


//----------------------------------------------
//   Use dummy date to prevent caching of Web page and force refresh
//----------------------------------------------
//    Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
//    always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
//    HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
//    HTTP/1.0
header("Pragma: no-cache");
 

//----------------------------------------------
//   Set content type for XML
//----------------------------------------------
header("Content-type:text/xml");


//----------------------------------------------
//   REST HTTP Parameters
//----------------------------------------------
//   Decimal Degrees - WGS1984 Datum
$lat = $_GET["latitude"];
$lon = $_GET["longitude"];

//   meters above sea level
$alt_m = $_GET["altitude"];

//   knots
$vel_kt = $_GET["speed"];

//   Degrees
$head = $_GET["heading"];

//   UTC - YYYYMMDD
$date = $_GET["date"];

//   UTC - HHMMSS.sss
$time = $_GET["time"];

$user = $_GET["username"];
$pwd_encry = $_GET["pw"];


//----------------------------------------------
//   SI - English Conversions
//----------------------------------------------
//   Feet above sea level
$alt_ft = 3.2808399 * floatval($alt_m);

//   Miles per hour
$vel_mph = 1.15077945 * floatval($vel_kt);


//----------------------------------------------
//   Date - time parsing and RFC 822 date creation
//----------------------------------------------
//   Set timezone to UTC
date_default_timezone_set("UTC");

$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
$hour = substr($time, 0, 2);
$minute = substr($time, 2, 2);
//   Decimal seconds truncated
$second = substr($time, 4, 2);

//   RFC 822 Format: "Day, DD MMM YYYY HH:MM:SS UTC"
$date_RFC822 = date(DATE_RFC822, mktime($hour, $minute, $second, $month, $day, $year));


//----------------------------------------------
//   Simple dynamic generation of XML document
//----------------------------------------------
//   Declare new XML document
$dom = DOMDocument::loadXML('<positiondatabase/>');
$dom->preserveWhiteSpace = false;
$dom->encoding = "UTF-8";

//   documentElement refers to the root element!
$positiondatabase = $dom->documentElement;

//   Web 2.0 Metadata for reusability using W3 geo:lat and geo:long namespace standards
$positiondatabase->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:geo','http://www.w3.org/2003/01/geo/wgs84_pos#');

//   Declare individual XML elements
$position = $dom->createElement("position");
$geolat = $dom->createElementNS("http://www.w3.org/2003/01/geo/wgs84_pos#","geo:lat",$lat);
$geolong = $dom->createElementNS("http://www.w3.org/2003/01/geo/wgs84_pos#","geo:long",$lon);
$alt_meters = $dom->createElement("altitude_m",$alt_m);
$alt_feet = $dom->createElement("altitude_ft",$alt_ft);
$vel_knots = $dom->createElement("velocity_kt",$vel_kt);
$vel_milesperhour = $dom->createElement("velocity_mph",$vel_mph);
$heading = $dom->createElement("heading_deg",$head);
$date_time = $dom->createElement("date_rfc822",$date_RFC822);
$username = $dom->createElement("user_name",$user);
$pwd_encryted = $dom->createElement("user_pwd_encrypt",$pwd_encry);

//   Inserting individual XML elements

//   append child nodes to root element
$dom->documentElement->appendChild($position);

//   append grandchild nodes to child elements
$position->appendChild($geolat);
$position->appendChild($geolong);
$position->appendChild($alt_meters);
$position->appendChild($alt_feet);
$position->appendChild($vel_knots);
$position->appendChild($vel_milesperhour);
$position->appendChild($heading);
$position->appendChild($date_time);
$position->appendChild($username);
$position->appendChild($pwd_encrypted);


//----------------------------------------------
//   XML Output Processing
//----------------------------------------------
//   Save new XML file output
$output = $dom->save('position.xml');

//   Make output readable
$dom->preserveWhitespace = false;
$dom->formatOutput = true;

//   Print XML file output to client display
print $dom->saveXML();
?>
</font id="blue">

jpalten
Posts: 2
Joined: Thu Nov 29, 2007 12:53 pm

RE: GUIDE: Send GPS data using HTTP to your web site

Thu Nov 29, 2007 12:56 pm

Will this also work with the normal,main,global gpsgate.com server? Can my application use this interface to send my position to my buddies?

User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Thu Nov 29, 2007 1:24 pm

Yes, that will work.

Please download "GpsGate.com Client SDK" it has a PDF document which in detail with samples describes how you can send data from a client to GpsGate.com or GpsGate Server:
http://franson.com/gpsgateserver/download.asp

You can send data using TCP/IP, UDP and HTTP. The TCP/IP protocol is very interesting since it support device configuration and track buffering on the client side.

Regards,
Johan

Franson Support

deputydave
Posts: 6
Joined: Wed Dec 12, 2007 9:58 pm
Location: USA
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Thu Dec 13, 2007 12:04 am

I am trying to access this page on my 8125 PDA http://deputydave.com/minimap.html what am I missing?

sweber
Posts: 1
Joined: Sun Apr 20, 2008 11:31 am
Location: Denmark

RE: GUIDE: Send GPS data using HTTP to your web site

Sun Apr 20, 2008 11:52 am

Hi All

Following the instructions for setting up gpsgate accessing my own php script on myown server. I end up with the error message 404. This usually means that there is something wrong in the url and the url can not be found.
I am using the http protocol, after step 8 I will have the following in the server line "http://myserver.domain.xx/php/gate.php".
myserver.domain.xx is not the correct server name
Executing the test in gpsgate will give the above mentioned error.

Pasting the url above into a browser will give the result I expect, a response from the script gate.php.

If I use default settings and send to gpsgate.com with a usercode/password, I get the correct answer that the usercode/password are invalid.
hope someone can point me in the right direction.
Steen

User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Sun Apr 20, 2008 3:21 pm

Please follow those steps:

1. Open the GpsGate Settings dialog. Go to the "Output" tab
2. Check "Connect to custom GpsGate Server"
3. Click on "More options..."
4. Select HTTP as Protocol.
5. Enter "http://myserver.domain.xx/php/gate.php" as Server address and click OK
6. Click Next in the Wizard. Enter username / password and then "Finish"

You can also verify the connection by clicking "Test".

Regards,
Johan

Franson Support

unicptz
Posts: 5
Joined: Thu May 15, 2008 3:24 pm

RE: GUIDE: Send GPS data using HTTP to your web site

Thu May 15, 2008 3:30 pm

All works with custom server, but when I reboot my ppc or exit gpsgate and start again all my properties (server name, protocol, mobile) don't save and become initial.

User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Thu May 15, 2008 3:44 pm

This can be because of the language used on your device. Which language is it? Which country are you from?

We have made some improvements on this in the latest release. But there are still some problem when file paths cannot be saved as Latin-1 characters.

Regards,
Johan

Franson Support

unicptz
Posts: 5
Joined: Thu May 15, 2008 3:24 pm

RE: GUIDE: Send GPS data using HTTP to your web site

Fri May 16, 2008 1:32 am

Russian. Windows mobile 5.0
The URL is "http://www.domain.ru/gps/getdata.php"

User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Fri May 16, 2008 12:58 pm

Yes, there is some problems to save Unicode paths in the settings files. We are aware of this limitation, and will try to fix it as soon as possible.

Try the latest version (build 321) it should improve things, and be less likely to fail saving the settings, even though it doesn't solve all known problems related to this.

Regards,
Johan

Franson Support

bveldkamp
Posts: 2
Joined: Tue May 27, 2008 5:26 pm

RE: GUIDE: Send GPS data using HTTP to your web site

Tue May 27, 2008 5:27 pm

Does GpsGate support basic or digest authentication when sending data to an http server?

User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Tue May 27, 2008 5:31 pm

No, you need to authenticate the request using the username + password you get in the URL.

Regards,
Johan

Franson Support

rudykstra
Posts: 2
Joined: Mon Jun 09, 2008 10:52 pm

RE: GUIDE: Send GPS data using HTTP to your web site

Mon Jun 09, 2008 11:00 pm

First of all, many thanks for this fantastic and stable program. I tried earlier versions which wouldn't work quite right, but this one is wordth every penny (or Euro)

My question;

I'm usig gps-gate client to send my position by HTTP to my own database. I've tried it for a day with an interval of 5 minutes. When I came home i found the interval to be quite big when I'm driving fast. However, for my occupation I have to wander (survey) distances of about 5 kilometrs per day and I want this logged as well. Therefore it is not a suitable option for me to switch to the 'log every fixed distance' option.

Can you tell me how big (how much data) the HTTP-calls to my database (website) are? If I know the amount of data a request aqcuires, I can calculate the most efficient settings for the interval.

Thanks in advance and kind regards,

Ruurd Dijkstra

User avatar
johan
GpsGate
Posts: 14079
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Send GPS data using HTTP to your web site

Tue Jun 10, 2008 1:31 pm

The HTTP request is about 0.5 kB.

The reason you miss position updates when driving fast can be that GPRS will not always work completely stable when roaming between base stations, something that happens often when driving fast. The result will be that data is lost and some HTTP requests fails.

If no data may be lost you need to use the TCP/IP options which can handle bad connections without loosing data. It will also consumke less band width, but it will not work with a web server.

Regards,
Johan

Franson Support

Return to “GpsGate for Developers”