Jump to content

Automate Processing Of Pocket Queries


Recommended Posts

Fellow Cachers:

 

I did some searching for any existing threads on this topic, and couldn't come up with a good example that answered my question or was right on the mark.

 

Here's what I'm interested in -- a solution to automate the processing of delivered pocket queries (GPX files) into several other usable forms: E.G. "Spun" into a form for importing into my Palm, as well as compiled and translated into a file for Streets and Trips (.est file), and finally ready for import to my GPSr.

 

I have seen some brief discussion of automating much of this, leveraging existing excellent tools like GSAK, GPSbabel, GPX Spinner, cmconvert, etc . I'm using all these tools now in a manual fashion - and unfortunately, they aren't an ideal fit for my desired automation platform, which is my Linux server where the pocket queries land.

 

So - I'm already sorting the PQs off into a dedicated folder via Procmail - and realize that I could, alternatively, pass the messages to some sort of command line. I'm struggling with what tool/process might strip the attachment and save it off - and google hasn't been much help in my quest.

 

Once that's done, and I've got a directory full of GPX files - I think there are Linux tools out there that can be scripted to accomplish most, if not all, of what I'm after. In a worst-case scenario, I can full all the PQ files over to a windows machine, or even retrieve the messages to a windows host for processing, if that's my best bet.

 

Anyone out there doing anything like this... and willing to share? If I can bolt together a workable system, I'll definitely document and post the process for others.

 

Thanks for any ideas or suggestions,

Billy

(aka SnoWake)

Link to comment

GPSBabel (which you already have if you installed GSAK) was written for this. It runs from the command line, which means it can be invoked by a batch file. Write a batch file that calls GPSBabel 3 times, once for each transposition you want to do. You may want to read the documentation for GPSBabel, but you can get enough information by running it with the ? switch, or even better, by 'gpsbabel /? > info.txt'. This will pipe the help text from gpsbabel.exe to a file called info.txt, which you can read with any text editor or quickview.exe. If you download gpsbabel by itself, it has a file named babelopts.txt which explains the options. If you don't know how to write a batch file, or run files from a DOS prompt, you need to learn, because that's the way to do automation.

 

Edited to add babelopts.txt

Edited by NightPilot
Link to comment

If you have to run GPSBabel three times to get the same data output in three different formats, we've failed. You can specify multiple -o/-F pairs.

 

To the original poster, GPSBabel is immensely scriptable from procmail on Linux; search the gpsbabel-misc mailing list archives for extensive examples of such recepies.

Link to comment

As far as CMConvert goes, there's source available for a command-line version of that (if you're not already aware of it) that can be compiled and used in *ix environments, and can definitely be scripted. There's options to cover most everything that you can do in the Windows GUI version of the app.

 

I know of people scripting with it in Linux and Windows, and it's also what's used under the hood by MacCMConvert and GSAK's CacheMate export.

Link to comment

As far as pulling out the attachments, if you're familiar with Perl at all you can use the MIME-tools package to parse the email and pull out the attachment. I don't use it to pull out GPX files, but I have been using it for a while with other types of file attachments.

 

Here's a modified copy of part of one of my scripts that might work...

 

use MIME::Parser;

 

my $parser = new MIME::Parser;

$parser->output_under("/some/temp/directory");

 

$gpx_filename = undef;

 

$entity = $parser->parse(\*STDIN);

if ($entity) {

  if ($entity->is_multipart) {

    foreach $part ($entity->parts) {

      if ($part->head->recommended_filename =~ /^.*\.gpx$/) {

        $gpx_filename = $part->bodyhandle->path;

      }

    }

  }

}

 

The mods to the script are untested, but what it should do is parse the email (coming in on standard input) into a subdirectory under the one you specified with output_under (which you can clean up with a cron job later) and, if it contains an attachment with a filename ending in .gpx, it'll set $gpx_filename to the path of the extracted GPX file in that subdirectory. You can then pass that off to whatever you want to convert/parse it with.

Link to comment

I use babel/spinner/isilo from the command line in a batch program to produce the output.

 

GSAK uses babel to drop out files of various types and will load straight to GPS. This is becoming my preferred method. Load a GPX file into GSAK and load in my GPS, drop out for about anything (including streets & trips), and just copy the GPX to my PDA for use in GPX Sonar.

 

It's not "automated" but it's easy.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...