User:-jha-/GPXprocessing

From OpenStreetMap Wiki
Jump to navigation Jump to search

Just to document for myself, how i process my gpx-tracks before upload:

Step 1: Everything to GPX

  • NMEA to GPX (4nt-batch):
for %na in (*.nmea) if not exist "%@path[%@lfn[%na]]%@name[%na].gpx"  c:\programme\gpsbabel\gpsbabel.exe -p "" -t -i nmea -f "%@lfn[%na]" -x sort,time -x track,pack,split=20s,sdistance=0.2k -x track,fix=3d,course,speed -x discard,hdop=2.9,vdop=5 -o gpx -F "%@path[%@lfn["%na"]]%@name["%na"].gpx"
  • TRK (Medion GoPal) to GPX (4nt-batch):
for %na in (*.trk) if not exist "%@path[%@lfn[%na]]%@name[%na].gpx" c:\programme\gpsbabel\gpsbabel.exe -p "" -t -i gopal,clean=1,maxspeed=250 -f "%@lfn[%na]" -x nuketypes,waypoints -x transform,trk=rte -x nuketypes,routes -o gpx -F "%@path[%@lfn["%na"]]%@name["%na"].gpx"
  • GDB (Garmin/Mapsource) to GPX (4nt-batch):
for %na in (*.gdb) if not exist "%@path[%@lfn[%na]]%@name[%na].gpx" c:\programme\gpsbabel\gpsbabel.exe -p "" -t -i gdb -f "%@lfn[%na]" -x track,course,speed -o gpx -F  "%@path[%@lfn["%na"]]%@name["%na"].gpx"

Step 2: Clean the GPX-Files 4NT-batch gpx-smart.btm:

for %na in (t\*.gpx) if not exist "%@path[%@lfn[%na]]smart\%@name[%na].gpx" c:\programme\gpsbabel\gpsbabel.exe -p "" -t -i gpx -f "%@lfn[%na]" -x nuketypes,waypoints,routes -x transform,wpt=trk -x nuketypes,tracks -x polygon,file=C:\DOKUME~1\jha\EIGENE~1\Geo\europa.txt -x polygon,file=C:\DOKUME~1\jha\EIGENE~1\Geo\gruener.txt,exclude -x polygon,file=C:\DOKUME~1\jha\EIGENE~1\Geo\mergenthaler.txt,exclude -x polygon,file=C:\DOKUME~1\jha\EIGENE~1\Geo\mindener.txt,exclude -x sort,time -x transform,trk=wpt -x nuketypes,waypoints -x track,pack,sdistance=0.2k,split=20s -x position,distance=1m -o gpx -F  "%@path[%@lfn["%na"]]%\smart\%@name["%na"].gpx"
  • europa.txt (to gd rid of totally wrong data like points on the equator....):
#Western Europe
46.000 -1.0000
46.000 22.0000
58.000 22.0000
58.000 -1.0000
46.000 -1.0000
  • gruener.txt (my home is tracked already):
#Grüner
50.13946424623351 8.566997051239014
50.14156835911032 8.566997051239014
50.14156835911032 8.570108413696289
50.13946424623351 8.570108413696289
50.13946424623351 8.566997051239014
  • mergenthaler.txt (skip-area):
#Mergenthaler 
50.136809906482114 8.5703444480896
50.136809906482114 8.566503524780273
50.13445801091226  8.566503524780273
50.13445801091226  8.5703444480896
50.136809906482114 8.5703444480896
  • mindener.txt (skip-area):
#Mindener
51.21101034909585 6.81454896926880
51.21101034909585 6.80903434753418
51.21400787223587 6.80903434753418
51.21400787223587 6.81454896926880
51.21101034909585 6.81454896926880

Step 3: Rename the GPX-Files to unique filenames (Random will do) 4NT-batch cp-uniq.btm:

if not exist .\uniq mkdir .\uniq
for %na in (*.gpx) copy "%na" .\uniq\GPX-Track_%@random[100000,900000]%@random[100000,900000]%@random[100000,900000].gpx

Step 4: upload them via php (php-cli) gpxupload.php

<?php
  $dir = opendir(".");
  while(false != ($file = readdir($dir)))
  {
   if(($file != ".") and ($file != ".."))
   {
     $fileChunks = explode(".", $file);
     if(strtolower($fileChunks[1]) == "gpx")
     {      
        echo "File ".$file."\n\r";
        exec('curl -u -jha-:password -H Expect: -F file="@'.$file.'" -F description=Unterwegs_in_Deutschland -F tags=germany -F public=1 http://www.openstreetmap.org/api/0.5/gpx/create');
     }
   }
 }
 closedir($dir);
?>