Dynamically Generate GPX from ASP page?


Hi, I maintain a web page of motorcycle shops in the NYC area (http://nymstf.org/shoplist.asp) and thought it would be cool to have a link on the page that could generate a GPX file based on current information in the database behind that web page.

I understand that GPX is just plaintext XML. I'm just trying to wrap my head around the formatting of the XML.

Can someone show me an example of what the correct code would look like for two waypoints in one file? Fields I have are shop name, address, phone, web site, one or two lines of what they sell/service, and of course lat/long (in decimal format supplied by the Google Maps API).

Once I have a good example I can take that and run with it, set the MIME type correctly, etc.

Thanks in advance!!!

Install Extra_POI_Loader

Install Extra_POI_Loader from http://turboccc.wikispaces.com/Extra_POI_Editor#Extra_POI_Ed...

With that, you can populate each field and Save As a gpx file.

Garmin's POI Loader Help information under Advanced Features>Adding Address and Contact Information will give you some insight regarding the fields also.

My H-D Dealers.gpx file uses most fields:

Zumo 550 & Zumo 665 My alarm clock is sunshine on chrome.


Thank you Dave, that oughta' get me started.

Description tags?

Any suggestions as to what XML tag would be best to use for descriptive text about the shops??

Description I believe is the

Description I believe is the tag you want, but I don't exactly remember. I'd have to open my Historic Vessels of the US and Canada POI in notepad to tell you for certain, since its entries use all the fields in a GPX file.

"Anyone who is capable of getting themselves made President should on no account be allowed to do the job." --Douglas Adams

Fielding Questions...

Sorry, needed a pun. Basically there's a comment field and a description field and I'm looking for guidance on which would be more appropriate or more useful as a display item in the GPS receivers, or if I could or should use both.

The Extra POI Editor shows me comments displaying before descriptions. Not sure if that is consistent among receivers or if all receivers show both. If I can use both it might save me worrying about how consistent the support is for things like CR/LF inside the XML datum.

GPX formatting

Part of what you are asking will depend on how you are planning to use the fields. Both the comment and description fields will truncate. For most 4.3 inch screens that's around 22 characters on a single line.

The fields are also limited to the maximum number of characters but I don't remember the limit off the top of my head. Then there is the manner in which Garmin handles the fields as well. Both are on the second or More screen so if there is no reason to ask to see more, the info is never displayed.

There is one field that is not limited as to the number of characters and does display on the initial screen which can be used to lead a person to ask to see more data and that is the email address. It always appears on the bottom of the initial or GO screen. look at my Exxon GPX file to see it in use.

Illiterate? Write for free help.

Web Links?

Dave, the LINK tag in your file (generated by POI Editor?) seems inconsistent with the documentation at Topografix. What's up with that? The docs say to use a URL tag.

FYI I put a link on the shops list page. Anyone wanna have a look at it??


Thanks for the help and suggestions welcome!

Obsolete Waypoints?

Another thought just came to me - how can I manage places that become obsolete? Is there an automated way to delete them via the GPX file?

Doesn't look like it to me but maybe I'm missing something?

Not easily

I don't think it would be easy to do as the number of fields could be variable and therefore the number of lines making up a single entry. Yes, the lines would begin with the WPT lat tag and end with /wpt, it would just be easier to regenerate the file when you are notified of a change.

Illiterate? Write for free help.

Clarification re Deletes...

I think I need to clarify...

The GPX file I'm creating is made dynamically, from a database that contains the data about the motorcycle shops. The web page is created dynamically from the same database.

What I'm thinking is that if a GPX file could specify entries to be deleted, when shops close I can mark them as deleted instead of just erasing their records from the database, then on the next GPX upload those waypoints could be deleted.

The other option I guess is to update a waypoint to say CLOSED in the address, comments, etc.

what i'm having trouble with

What I'm having trouble with is your definition of "dynamically." Do you mean the file is created on demand from the entries in your database or is it created and made available on your web site? If the file automatically updates with a change to an entry, does that include the addition or removal of offered services? If a location closes, why continue to carry it in both your database and the GPX?

Thinking this through a little from my standpoint, if a location closes, the database entry should go to either an archive status or deleted from the active DB and transferred to an archive file. Do you really anticipate these failed businesses to reopen as another iteration of the same failed business? There was a reason the shop closed, and it may not have been due to the owner but the lack of business for that location.

By not creating the GPX file until demanded, the requester would get the freshest data provided your generator understood an inactive location was not to be included. It shouldn't take more than a minute to generate a file on demand and most people are willing to wait for their data if theey know you are "generating a file with the latest updates."

Illiterate? Write for free help.

GPX File Generation

Yes, by dynamically I do mean the GPX file is created at the time you click the link, from the entries in the database. It takes less than a second. From the standpoint of someone using a web browser they wouldn't know the difference if it was a static file or generated from database info. The requestor always gets current data with each click.

At the risk of confusing the matter further, I'll point out that I'm never actually creating a GPX file on the web server itself. Clicking the link for the GPX file runs an ASP web page (script) that queries the database for shops, wraps the data with the necessary GPX/XML headers and tags and streams the results to the client's web browser software and tells the web browser to save it as a GPX file.

I have only been doing this database for a couple of years and in that time four motorcycle businesses that I know of in the five boroughs have closed their doors permanently. A couple have moved and one changed its name. I think one did both.

No matter, what is important is that I thought it would be great if when someone uploads a new GPX file to their GPS receiver, that process could cause the deletion of shops that had closed since the last upload. I just don't know how to make that happen, or if it can be made to happen. THAT is my question.

Now it's more clear

What is missing from your scenario is how the file is loaded to the GPS. If it is to be loaded using POILoader, then every time you run the program it will overwrite the old file of the same name. If you load it into your favorites, then it again follows the rulw an existing file of the same name is overwritten. Now, overwriting an existing file always requires confirmation. But if you allow duplicate file names, then you start running into another problem, numbers in the name.

Numbers in a file name will most often generate a speed alert which causes the unit to continuously play whatever alert sound is present as you approach a location. The sound can be either the custom sound or the "Bongs." My suggestion is to not have the file download directly to a unit but to the computer and leave it to the requester to handle the file naming issue.

To sum this up, you need to not only understand the HTML in writing a GPX but how a unit handles the files once they are present. Look into POILoader and get familiar with it and it's keywords and quirks. Gary Hayman, who isn't as active as he used to be has a set of web pages giving all sorts of tips and tricks. There is A LOT of information buried in many different blog entries by Gary that will help you.


Illiterate? Write for free help.

Box, he's telling the page

Box, he's telling the page to save the output as a .GPX file, so it's up to the end user to still put the file on the GPS properly. He's likely going to have links pointing at the POI loading process for the major manufacturers.

"Anyone who is capable of getting themselves made President should on no account be allowed to do the job." --Douglas Adams

Right on the money...

Strephon_Alkhalikoi wrote:

Box, he's telling the page to save the output as a .GPX file, so it's up to the end user to still put the file on the GPS properly. He's likely going to have links pointing at the POI loading process for the major manufacturers.

Yep. Actually I don't even think I'll bother polluting the page with instructions. EDIT: But if there's a preferred way of utilizing the GPX files I would probably make a web page describing it.

Ready, I Think...

As of last night I've gotten the GPX to pass XML validation. Everything else should be working OK so please have a look. Clicking the link below should prompt your web browser to save or open a file called NYCMOTOS.GPX.


Thanks everyone for your guidance. FWIW I never consider these things "finished" so suggestions, hints, tips, whatever, welcome anytime!

POI Loader...

Thanks for the pointer to Hayman's tips 'n tricks. That web site is a little "noisy" for me though, so I'm having trouble gleaning useful info from it.

I'm reading about POI Loader on the Garmin site and I can see how some of its features could turn out to be a headache if you don't use manual mode. For example, one shop is named "Speed Motorcycles". Surely I won't be the only person with this kind of problem. A POI file containing camera shops could be a nightmare... Cameta Camera, Ritz Camera, K&M Camera, you get the idea!

@Bad Andy

Looks like you are learning quickly.

It would be my impression that having the word "camera" in the name of an individual POI entry would not generate an alert (as it would if it was in the "file name".

In furthering your learning process, why don't you test some things (like "camera" in a POI entry) out for yourself and then give us the results of your testing.

Simulation is a quick way to test things out. You can do so with POI files that you create yourself pointing to locations close by your own home.

Look at http://www.poi-factory.com/node/31482 to get started.