0) $text=" The map expires in $daysleft day(s)"; else $text=" The map EXPIRED already $expireddays days and is candidate for deletion"; } } return ($text); } if ($cmd==""){ print ""; ?> SELECT the NMEA or GPX log file and press upload
NMEA File:
'; exit(); */ // // //header("Content-type: text/plain\n"); //print "// $minx, $miny, $maxx, $maxy"; /* $y="37.427770"; // DEBUG $x="-122.144841"; print "\n"; print "\n"; print ""; exit(); */ $sql = "SELECT * FROM `trackdata` WHERE 1 AND `trackid`='$id' AND `x`>'$minx' AND `x`<'$maxx' AND `y`>'$miny' AND `y`<'$maxy'"; //print $sql; $result=mysql_query($sql); if ((!$result) || (mysql_numrows($result) == 0)) { //printf("ERROR: record unknown\n");exit(1); print "\n"; print ""; exit; } // PARTIALLY REPEATED CODE $numrows=mysql_numrows($result); $step=1; if ($numrows > $MAXPOINTS){ // print "sampling 25 track points for initial track ...
\n"; $step=floor($numrows/$MAXPOINTS); } $i=0; print "\n"; while ($i < $numrows) { $x=mysql_result($result,$i,"x"); $y=mysql_result($result,$i,"y"); //$i++; $i=$i+$step; print "\n"; //print "//marker lat=\"$y\" lng=\"$x\"\n"; } print ""; exit; } if ($cmd=="show"){ include ("../db_connect.php"); $sql = "SELECT min(x), max(x), min(y), max(y) FROM `trackdata` WHERE 1 AND `trackid`='$id'"; $result=mysql_query($sql); if ((!$result) || (mysql_numrows($result) == 0)) { printf("ERROR: record unknown\n");exit(1); } $minx=mysql_result($result,0,"min(x)"); $miny=mysql_result($result,0,"min(y)"); $maxx=mysql_result($result,0,"max(x)"); $maxy=mysql_result($result,0,"max(y)"); // print "($minx, $miny) - ($maxx,$maxy)
\n"; // RECORD KNOWN, RECORD ACCESS // STEP 1, check record in mapdata table $sql = "SELECT * from `mapdata` where id='$id';"; //print $sql; $result=mysql_query($sql); $time=time(); if ((!$result) || (mysql_numrows($result) == 0)) { // NO, this is not possible printf("ERROR: no record $id"); printf("

Record may be deleted due to expiration of the map"); printf('

You may have to upload the GPS trackdata again on http://www.landmarker.nl'); exit(1); } else { // YES, update the record // FOUND $count=mysql_result($result,0,"count"); $count++; $sql="UPDATE `mapdata` SET `count` = '$count', accesstime=$time WHERE `id` = '$id';"; //print $sql; $result=mysql_query($sql); } $sql = "SELECT * FROM `trackdata` WHERE 1 AND `trackid`='$id'"; $result=mysql_query($sql); if ((!$result) || (mysql_numrows($result) == 0)) { markhidden($id); printf("ERROR: record $id seems to contain no valid GPS track data\n

Please email dtromp@dds.nl for assistence and state your log file ID"); printf('

This map is marked "hidden" and will not be shown in the map index on http://www.landmarker.nl'); $expiretext=getexpiretext($id); printf('

The map and associated data will be deleted from the server when the map expires'); printf("

$expiretext"); exit(1); } $numrows=mysql_numrows($result); // print "query done ($numrows rows)
\n"; $step=1; if ($numrows > $MAXPOINTS){ // print "sampling 25 track points for initial track ...
\n"; $step=floor($numrows/$MAXPOINTS); } $i=0; // EXCEL DEBUG /*while ($i < $numrows) { $x=mysql_result($result,$i,"x"); $y=mysql_result($result,$i,"y"); $i++; print "$x,$y
\n"; } exit(); */ // DEBUG //$step=1; while ($i < $numrows) { $x=mysql_result($result,$i,"x"); $y=mysql_result($result,$i,"y"); //$i++; $i=$i+$step; //print "$x,$y
\n"; $xy="$x,$y"; if ($gpoints==""){ $gpoints="$xy"; } else { $gpoints="$gpoints;$xy"; } $ngpoints++; // DEBUG //if ($i==$MAXPOINTS){ // $i=$numrows; //} } //print "$ngpoints
$gpoints
\n"; //$filename=mysql_result($result,0,"filename"); //print "Selecting of x,y done
\n"; if ($ngpoints > 1){ //list($x, $y)=split(",", $valid_xy); $x=$minx+($maxx-$minx)/2; $y=$miny+($maxy-$miny)/2; $minmax="maxx=$maxx&maxy=$maxy&minx=$minx&miny=$miny"; //print "$x, $y, $minmax"; // START HTML //print "$gpoints
\n"; /* Select Google Static Map (former Default) or Google Dynamic Map with trackdata (please wait during initial autozooming):
*/ ?>


// END HTML } else { print "No track data
Email dtromp@dds.nl for help\n"; } } if ($cmd=="insert"){ include ("../db_connect.php"); $sql = "DELETE FROM `trackdata` WHERE 1 AND `trackid`='$id'"; $result=mysql_query($sql); $sql = "SELECT * FROM `mapdata` WHERE 1 AND `id`='$id'"; $result=mysql_query($sql); if ((!$result) || (mysql_numrows($result) == 0)) { printf("ERROR: record unknown\n");exit(1); } $filename=mysql_result($result,0,"filename"); //print "$filename
\n"; //print "Opening cached NMEA log
\n"; $raw=file_get_contents($filename); $array=explode("\n",$raw); //print_r($array); //exit(); //$array=explode("\r",file_get_contents($filename)); $nvalid=0; $nparsed=0; // TODO: recover from aborted insert // EXCEL DEBUG //print "

";
	foreach ($array as $line){
		//print "$line
\n"; $xytime=addslashes(parse_nmea($line)); $nparsed++; //print "$xytime
\n"; if ($xytime != ""){ //print "$xytime\t$line
\n"; //print "$xytime\n";exit(1); $nvalid++; // TODO Modify to allow cross (utc)date tracks ... list($x, $y, $utctime)=split(",", $xytime); // TODO, more efficient SQL //$sql="UPDATE `mapdata` SET `nparsed` = '$nparsed' WHERE `id` = '$id';"; //$result=mysql_query($sql); /* CREATE TABLE `trackdata` ( `id` INT NOT NULL , `trackid` INT NOT NULL , `lineid` INT NOT NULL , `posid` INT NOT NULL , `x` FLOAT NOT NULL , `y` FLOAT NOT NULL , PRIMARY KEY ( `id` ) ); */ // TODO: DELETE FIRST / REPLACE ipv INSERT $sql="INSERT INTO `trackdata` (`trackid`, `lineid`, `posid`, `x`, `y`, `utctime`) VALUES ($id, $nparsed, $nvalid, '$x','$y', '$utctime')"; $result=mysql_query($sql); //print $sql;exit(); //exit(1); // TODO: DELETE CACHED FILE } } $track = parse_gpx($raw); foreach ($track as $xyt) { //print "$xy\n"; //new GPoint(1.181593333,52.94302833) if ($xyt != ""){ list($x, $y, $t)=split(",", $xyt); if (($x!=0) && ($y!=0)){ //print "GPX: $xy
"; $cettime=$t; // == CET ?? $sql="INSERT INTO `trackdata` (`trackid`, `lineid`, `posid`, `x`, `y`, `cettime`) VALUES ($id, $nparsed, $nvalid, '$x','$y', '$cettime')"; $result=mysql_query($sql); } } } // RECORD KNOWN, RECORD ACCESS // STEP 1, check record in mapdata table $sql = "SELECT * from `mapdata` where id='$id';"; //print $sql; $result=mysql_query($sql); $time=time(); if ((!$result) || (mysql_numrows($result) == 0)) { // NO, not possible //printf("DEBUG: no record $id"); printf("ERROR: no record $id");exit(1); //$sql="INSERT INTO `mapdata` (`id`, creationtime) VALUES ('$id', $time)"; //print $sql; //$result=mysql_query($sql); } else { // YES, update the record // $sql="UPDATE `mapdata` SET `field` = '$value' WHERE `id` = '$id';"; // $result=mysql_query($sql); $sql="UPDATE `mapdata` SET `inserttime` = '$time' WHERE `id` = '$id';"; //print $sql; $result=mysql_query($sql); } print "DONE
\n"; //unlink($filename); print "The identification of this Travel Log is $id.
\n"; print "You need this number to access your Travel Log from the homepage
\n"; print "So please remember or write down this number ...
\n"; print "

\n"; $message="ID: $id\nfilename=$filename\n\nhttp://{$_SERVER['SERVER_NAME']}/$PHP_SELF?id=$id&cmd=show"; mail("dtromp@dds.nl", "Nieuwe Landmarker map $id", $message, "From: dtromp@dds.nl\r\n" . "Reply-To: dtromp@dds.nl\r\n" . "X-Mailer: PHP/" . phpversion()); // {$_SERVER['SERVER_NAME']} ?>

\n"); exit(1); } $uploadfile =$_FILES['userfile']['tmp_name']; $movedfile = $uploaddir . "_UPLOADED_" . $_FILES['userfile']['name']; /* if (move_uploaded_file($uploadfile, $movedfile)) { // print "File is valid, and was successfully uploaded. "; // print "Here's some more debugging info:\n"; // print_r($_FILES); // print "1\n"; // 1 indicates successfully stored file, all else is an error } else { // print "Possible file upload attack! Here's some debugging info:\n"; // print_r($_FILES); print "Upload failed"; exit(1); } */ print "NMEA LOGFILE UPLOAD RECEIVED
\n"; print "FILTERING ...
\n"; $filterfile = $uploaddir . "_FILTERED_" . $_FILES['userfile']['name']; //$array=split('\n', file_get_contents($movedfile)); //Windows files do \r\n (0xD, 0xA), this is for a file created //in Windows //\n linefeed (LF or 0x0A (10) in ASCII) //\r carriage return (CR or 0x0D (13) in ASCII) //\x[0-9A-Fa-f]{1,2} the sequence of characters matching the regular expression is a character in hexadecimal notation $text=file_get_contents($uploadfile); $text=str_replace("\r","",$text); $array=explode("\n",$text); //print "
";
	//print "INITIAL
\n"; //print_r($array); //print "STEP0- filter on GPRMC sentences
\n"; // TODO: re-add filtering /* $filtered_array0 = preg_grep("/GPRMC/", $array); //print_r($filtered_array0); // TODO, count //print "STEP1 - remove invalid data
\n"; $filtered_array1 = preg_grep("/,A,/", $filtered_array0); //print_r($filtered_array1); //print "STEP2 - remove missing CRC's
\n"; $filtered_array2 = preg_grep("/\*[A-F0-9][A-F0-9]$/", $filtered_array1); // Poor mans CRC checker (there must be at lease some sore of CRC ...) //print_r($filtered_array2); */ $filtered_array2=$array; $lines=count($filtered_array2); if ($lines==0){ print "No valid GPRMC NMEA sentences present in uploaded file
\n"; exit(); } if (is_file($filterfile)) { unlink($filterfile); } $bytes=my_file_put_contents($filterfile, join("\n", $filtered_array2)); print "STORED, $bytes bytes / $lines lines written to $filterfile
\n"; //print_r($filtered_array); // DEBUG print "CREATING DATABASE ENTRY ...
\n"; /* CREATE TABLE `mapdata` ( `id` INT NOT NULL AUTO_INCREMENT , `filename` VARCHAR( 255 ) NOT NULL , `parsed` VARCHAR( 8 ) NOT NULL , `reserved` VARCHAR( 8 ) NOT NULL , PRIMARY KEY ( `id` ) ); */ include ("../db_connect.php"); $sql = "DELETE FROM `mapdata` WHERE 1 AND `filename`='$filterfile'"; $result=mysql_query($sql); $time=time(); $sql="INSERT INTO `mapdata` (`filename`, `uploadtime`) VALUES ('$filterfile', $time)"; $result=mysql_query($sql); $id=mysql_insert_id(); //print "id=$id\n"; //print "CLICK TO ADD (PART OF) FILE TO DATABASE ...
\n"; ?>
\n"; $id=""; } else { list($id, $utctime, $stat, $lat, $ns, $long, $ew, $speed, $course, $utcdate, $magnvar, $magnew, $crc, $term) = split(',', $nmea); } */ list($id, $dummy) = split(',', $nmea); // TODO: Remember using GMRMC or GPGGA, not both if ($id != "\$GPRMC") { //print "WARNING: $id Sentence ignored
\n"; } else { $nmea_array = split(',', $nmea); //print count($nmea_array); if (count($nmea_array) < 12){ $n=count($nmea_array); //print "WARNING: $id Sentence malformed (n=$n)
\n"; $stat=""; } else { list($id, $utctime, $stat, $lat, $ns, $long, $ew, $speed, $course, $utcdate, $magnvar, $magnew, $crc, $term) = split(',', $nmea); } if ($stat != "A"){ //print "WARNING: $id Sentence with invalid data
\n"; } else { // START HTML /* print "
parsed GPRMC Sentence:
			Field		Example		Comments
			Sentence ID	$id	 
			UTC Time	$utctime	hhmmss.sss
			Status		$stat		A = Valid, V = Invalid
			Latitude	$lat	ddmm.mmmm
			N/S Indicator	$ns		N = North, S = South
			Longitude	$long	dddmm.mmmm
			E/W Indicator	$ew		E = East, W = West
			Speed over ground	$speed	Knots
			Course over ground	$course	Degrees
			UTC Date	$utcdate		DDMMYY
			Magnetic variation	$magnvar 	Degrees
			Magnetic variation	$magnew	E = East, W = West
			Checksum	$crc	 
			Terminator	$term		CR/LF	 
			
"; */ // END HTML //print "Google X and google Y:
\n"; // X-google and Y-google $dd=floor ($lat / 100); $mm=$lat-($dd*100); $y=sprintf("%.8f", $dd+($mm/60)); if ($ns == "S"){$y=-$y;} //print "dd=$dd, mm=$mm, y=$y
\n"; $dd=floor ($long / 100); $mm=$long-($dd*100); $x=sprintf("%.8f", $dd+($mm/60)); if ($ew == "W"){$x=-$x;} //print "dd=$dd, mm=$mm, x=$x
\n"; //print "$utctime\n";exit(1); return ("$x,$y,$utctime"); } } // EX. Carlo // $GPGGA,115226,5218.2965,N,00514.5161,E,1,03,3.6,-1.1,M,46.7,M,,*6A if ($id != "\$GPGGA") { //print "WARNING: $id Sentence ignored
\n"; } else { $nmea_array = split(',', $nmea); //print count($nmea_array); if (count($nmea_array) < 12){ $n=count($nmea_array); print "WARNING: $id Sentence malformed (n=$n)
\n"; $fix=0; } else { list($id, $utctime, $lat, $ns, $long, $ew, $fix, $nsat, $hdop, $alt, $height, $age, $dgpsid, $crc, $term) = split(',', $nmea); } if ($fix == 0){ print "WARNING: $id Sentence with no fix indicator
\n"; } else { // START HTML /* print "
parsed GPGGA Sentence:
				$GPGGA,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,M,<11>,<12>,<13>
1)     UTC time of position fix, hhmmss.sss format	= $utctime
2)     Latitude, ddmm.mmmm format.			= $lat
3)     Latitude hemisphere, N or S.			= $ns
4)     Longitude, dddmm.mmmm format.			= $long
5)     Longitude hemisphere, E or W.			= $ew
6)     Position Fix Indicator, 				= $fix
	0 = fix not available, or invalid.		
	1 = GPS SPS Mode, fix valid.
	2 = Differential GPS, SPS Mode, fix valid.
	3 = GPS PPS Mode, fix valid.
7)     Number of sate1lites in use, 00 to 12.		= $nsat
8)     Horizontal Dilution of Precision, 0.5 to 99.9.	= $hdop
9)     MSL Altitude, -9999.9 to 99999.9 meters.		= $alt
10) Geoidal height, -999.9 to 9999.9 meters.		= $height
11) Differential GPS (RTCM SC-104) data age, number of seconds since last valid RTCM transmission (nu1l if non-DGPS). 
							= $age
12) Differential Reference Station ID, 0000 to 1023. (null if non-DGPS) 
							= $dgpsid
13) Checksum. 						= $crc

"; */ // END HTML //print "Google X and google Y:
\n"; // X-google and Y-google $dd=floor ($lat / 100); $mm=$lat-($dd*100); $y=sprintf("%.8f", $dd+($mm/60)); if ($ns == "S"){$y=-$y;} //print "dd=$dd, mm=$mm, y=$y
\n"; $dd=floor ($long / 100); $mm=$long-($dd*100); $x=sprintf("%.8f", $dd+($mm/60)); if ($ew == "W"){$x=-$x;} //print "dd=$dd, mm=$mm, x=$x
\n"; //print "$utctime\n";exit(1); return ("$x,$y,$utctime"); } } /* NMEA SYNTAX Common NMEA Sentence types The following information describes the most common NMEA-0183 sentences transmitted by GPS receivers. The NMEA standard provides quite a range of sentences, but many relate to non-GPS devices and some others are GPS related but rarely used. We normally recommend the use of NMEA mode for new GPS applications to give maximum compatibility with all GPS receivers. Most GPS receivers also have a binary mode but it is normally best to reserve the use of binary GPS protocols for applications that really require their use, such as those requiring position updates of greater than once per second. We also have a page that covers other NMEA sentences that are also used by GPS receivers, although somewhat less commonly. Sentence Description $GPGGA Global positioning system fixed data $GPGLL Geographic position - latitude / longitude $GPGSA GNSS DOP and active satellites $GPGSV GNSS satellites in view $GPRMC Recommended minimum specific GNSS data $GPVTG Course over ground and ground speed $GPGGA Sentence (Fix data) Example (signal not acquired): $GPGGA,235947.000,0000.0000,N,00000.0000,E,0,00,0.0,0.0,M,,,,0000*00 Example (signal acquired): $GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,19.7,M,,,,0000*1F Field Example Comments Sentence ID $GPGGA UTC Time 092204.999 hhmmss.sss Latitude 4250.5589 ddmm.mmmm N/S Indicator S N = North, S = South Longitude 14718.5084 dddmm.mmmm E/W Indicator E E = East, W = West Position Fix 1 0 = Invalid, 1 = Valid SPS, 2 = Valid DGPS, 3 = Valid PPS Satellites Used 04 Satellites being used (0-12) HDOP 24.4 Horizontal dilution of precision Altitude 19.7 Altitude in meters according to WGS-84 ellipsoid Altitude Units M M = Meters Geoid Seperation Geoid seperation in meters according to WGS-84 ellipsoid Seperation Units M = Meters DGPS Age Age of DGPS data in seconds DGPS Station ID 0000 Checksum *1F Terminator CR/LF $GPGLL Sentence (Position) Example (signal not acquired): $GPGLL,0000.0000,N,00000.0000,E,235947.000,V*2D Example (signal acquired): $GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D Field Example Comments Sentence ID $GPGLL Latitude 4250.5589 ddmm.mmmm N/S Indicator S N = North, S = South Longitude 14718.5084 dddmm.mmmm E/W Indicator E E = East, W = West UTC Time 092204.999 hhmmss.sss Status A A = Valid, V = Invalid Checksum *2D Terminator CR/LF $GPGSA Sentence (Active satellites) Example (signal not acquired): $GPGSA,A,1,,,,,,,,,,,,,0.0,0.0,0.0*30 Example (signal acquired): $GPGSA,A,3,01,20,19,13,,,,,,,,,40.4,24.4,32.2*0A Field Example Comments Sentence ID $GPGSA Mode 1 A A = Auto 2D/3D, M = Forced 2D/3D Mode 1 3 1 = No fix, 2 = 2D, 3 = 3D Satellite used 1 01 Satellite used on channel 1 Satellite used 2 20 Satellite used on channel 2 Satellite used 3 19 Satellite used on channel 3 Satellite used 4 13 Satellite used on channel 4 Satellite used 5 Satellite used on channel 5 Satellite used 6 Satellite used on channel 6 Satellite used 7 Satellite used on channel 7 Satellite used 8 Satellite used on channel 8 Satellite used 9 Satellite used on channel 9 Satellite used 10 Satellite used on channel 10 Satellite used 11 Satellite used on channel 11 Satellite used 12 Satellite used on channel 12 PDOP 40.4 Position dilution of precision HDOP 24.4 Horizontal dilution of precision VDOP 32.2 Vertical dilution of precision Checksum *0A Terminator CR/LF $GPGSV Sentence (Satellites in view) Example (signal not acquired): $GPGSV,1,1,01,21,00,000,*4B Example (signal acquired): $GPGSV,3,1,10,20,78,331,45,01,59,235,47,22,41,069,,13,32,252,45*70 Field Example Comments Sentence ID $GPGSV Number of messages 3 Number of messages in complete message (1-3) Sequence number 1 Sequence number of this entry (1-3) Satellites in view 10 Satellite ID 1 20 Range is 1-32 Elevation 1 78 Elevation in degrees (0-90) Azimuth 1 331 Azimuth in degrees (0-359) SNR 1 45 Signal to noise ration in dBHZ (0-99) Satellite ID 2 01 Range is 1-32 Elevation 2 59 Elevation in degrees (0-90) Azimuth 2 235 Azimuth in degrees (0-359) SNR 2 47 Signal to noise ration in dBHZ (0-99) Satellite ID 3 22 Range is 1-32 Elevation 3 41 Elevation in degrees (0-90) Azimuth 3 069 Azimuth in degrees (0-359) SNR 3 Signal to noise ration in dBHZ (0-99) Satellite ID 4 13 Range is 1-32 Elevation 4 32 Elevation in degrees (0-90) Azimuth 4 252 Azimuth in degrees (0-359) SNR 4 45 Signal to noise ration in dBHZ (0-99) Checksum *70 Terminator CR/LF $GPRMC Sentence (Position and time) Example (signal not acquired): $GPRMC,235947.000,V,0000.0000,N,00000.0000,E,,,041299,,*1D Example (signal acquired): $GPRMC,092204.999,A,4250.5589,S,14718.5084,E,0.00,89.68,211200,,*25 Field Example Comments Sentence ID $GPRMC UTC Time 092204.999 hhmmss.sss Status A A = Valid, V = Invalid Latitude 4250.5589 ddmm.mmmm N/S Indicator S N = North, S = South Longitude 14718.5084 dddmm.mmmm E/W Indicator E E = East, W = West Speed over ground 0.00 Knots Course over ground 0.00 Degrees UTC Date 211200 DDMMYY Magnetic variation Degrees Magnetic variation E = East, W = West Checksum *25 Terminator CR/LF $GPVTG Sentence (Course over ground) Example (signal not acquired): $GPVTG,,T,,M,,N,,K*4E Example (signal acquired): $GPVTG,89.68,T,,M,0.00,N,0.0,K*5F Field Example Comments Sentence ID $GPVTG Course 89.68 Course in degrees Reference 89.68 T = True heading Course Course in degrees Reference 89.68 M = Magnetic heading Speed 0.00 Horizontal speed Units N N = Knots Speed 0.00 Horizontal speed Units K K = KM/h Checksum *5F Terminator CR/LF */ } // END parse_mmea function /* function parse_gpx($gpx){ // TODO: use seg/track division $track=array(); preg_match_all("/]*)>/i", $gpx, $matches); foreach ($matches[1] as $latlong){ if (preg_match_all("/lat=\"([0-9]+\.[0-9]+)\"/", $latlong, $tmpmatches)){ $lat=$tmpmatches[1][0]; //print $lat; if (preg_match_all("/lon=\"([0-9]+\.[0-9]+)\"/", $latlong, $tmpmatches)){ $lng=$tmpmatches[1][0]; //print $lng; $xy="$lng,$lat"; array_push($track, $xy); } } } //$track=array(); // preg_match_all("/]*)>/i", $gpx, $matches); foreach ($matches[1] as $latlong){ if (preg_match_all("/lat=\"([0-9]+\.[0-9]+)\"/", $latlong, $tmpmatches)){ $lat=$tmpmatches[1][0]; //print $lat; if (preg_match_all("/lon=\"([0-9]+\.[0-9]+)\"/", $latlong, $tmpmatches)){ $lng=$tmpmatches[1][0]; //print $lng; $xy="$lng,$lat"; array_push($track, $xy); } } } // //print_r($track); //exit; return($track); //print_r($track); //exit; // //19.832764 // // START HTML //print "Google X and google Y:
\n"; // X-google and Y-google $dd=floor ($lat / 100); $mm=$lat-($dd*100); $y=sprintf("%.6f", $dd+($mm/60)); if ($ns == "S"){$y=-$y;} //print "dd=$dd, mm=$mm, y=$y
\n"; $dd=floor ($long / 100); $mm=$long-($dd*100); $x=sprintf("%.6f", $dd+($mm/60)); if ($ew == "W"){$x=-$x;} //print "dd=$dd, mm=$mm, x=$x
\n"; return ("$x,$y"); } // END parse_gpx function */ function parse_gpx($gpx){ // TODO: use seg/track division $track=array(); /* 1.567871 */ //print $gpx; preg_match_all("/]*)>.*?