GPX KML GML PLT XSLT converter

2,434 views
Skip to first unread message

cybarber

unread,
Sep 27, 2005, 6:51:34 PM9/27/05
to KML Discussions
Hi,

Online XSLT Translator / Covertor: KmlGpxGmlTransform.hta Application (IE only!)


Above Windows/Internet Explorer (sorry, Firefox and Mac adepts) HTA Application GUI transforms using XSLT the following formats:
GPX v1.0 to GPX v1.1 (with GPX Schema validation)
GPX v1.1 to GPX v1.0 (with GPX Schema validation)
GPX to KML (Stylesheets handles both GPX 1.0 and 1.1)
KML to GPX v1.1 ((with GPX Schema validation)
GML v2.1 types Polygon-Geometry to KML
KML and GPX to OziExplorer PLT
PLT to KML(will add OziExplore wpt to KML shortly)

Some of the transformation sheets stil need some cleaning up of commentary and unused code sections but they are al working.

The GUI allows the user to browse to the local input file or a Web URL can be input. From a select box one of the above mentioned XSLT transformation sheets can be selected. For each type of XSLT transformation a parameter menu appears.

The application tests for the presence of MSXML 3.0, 4.0, 5.0(office2003 users) and 6.0(new standalone successor of version 4.0).

An HTA application has a low security level and allows writing to disc. A zip file which I try to keep up to date with the latest versions( Jan 7th updated), is available for local use.

Direct links to the XSLT transformation files:

Update January 1st: added OziExplorer PLT plaintext to KML transformation(using FSO and ADO):
PLT to KML

KML to PLT
GPX to PLT


robogeoXML to KML

KML2GPX

GPX2KML

GPX10to11

GPX11to10

GML2KML

A 1.1mB zipped (unzipped 3.7mb) GML polygon format world map for transforming test to KML: World Borders.zip

The resulting KML world map after transformation: World Borders.kmz

The Application:
KmlGpxGmlTransform.hta Application (IE only!)

(Browser security setting may influence the usage from the website, so better download below kmlgpxgml.zip file.

ZIP file with above XSLT sheets GUI hta with some supporting images and sound files:
kmlgpxgml.zip (350kb)


A GPX to KML conversion example setting differently coloured track icons according to slope/gradient class.





Cybarber, Sept 28th, updated Jan 18th 2006.

Tisham

unread,
Sep 28, 2005, 4:32:27 AM9/28/05
to KML Discussions
I will put it through XSLT transformer in Java and make it portable, how does that sound?? Have u put the XSL's up?

cybarber

unread,
Sep 28, 2005, 5:59:58 AM9/28/05
to KML Discussions
Post deleted by cybarber

Tisham

unread,
Sep 28, 2005, 7:04:34 PM9/28/05
to KML Discussions
Thanks cyb,
Will do,not sure how u can be MS specific in XML, then again I only work with SOAP
To see my PHP stuff and if you feel like porting it to asp or something see the demo here

Travel_By_GPS

unread,
Oct 4, 2005, 6:59:15 PM10/4/05
to KML Discussions
Quote:


Finally, I have more or less a Windows/Internet Explorer... GUI ready as an HTA Application to XSLT-transform the following formats:
... GPX to KML (Stylesheets handles both GPX 1.0 and 1.1)




Cy,
I'm looking for a utility that will convert GPX 1.1 to KML, such that the waypoint comment field in GPX is converted to the Placemark name in KML and such that the waypoint description field in GPX is converted to Placemark description in KML. Does your program do this?

cybarber

unread,
Oct 5, 2005, 7:10:34 AM10/5/05
to KML Discussions
Post deleted by cybarber

Travel_By_GPS

unread,
Oct 5, 2005, 10:09:58 AM10/5/05
to KML Discussions
Quote:

For testing can you post a sample GPX file online which you would like to convert?




I'm am happy to assist with your development.

I always like to test with my foothills.gpx file because it is a big file which I've have put a lot of time into filling out.

http://www.travelbygps.com/premium/foothills/foothills.gpx

Here are some obvious details about the file:
Waypoint Names are six characters or less.
Comments are 16 Characters or less.
Descriptions are sometimes very long.
There are about 280 waypoints and 15 routes/tracks.

Note the file was created using ExpertGPS and was subsequently brought up to GPX 1.1 standard using GPS Babel

You migh also have a look at
http://www.travelbygps.com/gmaps/gpx/geographic_search_data.gpx
which includes some imbeded links.

I hope this helps!

cybarber

unread,
Oct 5, 2005, 6:53:13 PM10/5/05
to KML Discussions
The version of GPSBabel in Google Earth doesnot transform the <desc> Description content</desc. to KML: <description> Description content</description>.

For some reason (should be easy fro the GPSBabel guysor dolls to correct!) the <desc/> element is taken over in KML as such.

If KML would have a GML application schema( and donot be so arrogant google as to make your own KML schema as if you didn't copy cat most of it from GML!!) against which the KML instance document would be validated this would have been hamered out long ago.


MY XSLT application(GPX2KML.xslt) transforms <desc/> to <description/>

Cybarber

cybarber

unread,
Oct 5, 2005, 7:42:48 PM10/5/05
to KML Discussions
The GPX2KML.xslt transformation application now uses the <cmt/> element as name if it exists, otherwise <name/> is used.
Both the <name/> and <symb/> elements i put in the <description/> element together with the <desc/> lement.

Attached the UPDATED to KML converted foothills.gpx file.

For each track/route Camera views (N,NE,E,SE,S,SW,W,NW,N) and Bounding boxes are created. For track points the icon color and size changes according to slope/steepness of that point.


Try to convert them online with the interface. It is now possible to download input files from the web besides using local host files. Just copy the url paste it in the input filed and hit the browse button. Large files may take a while before they are downloaded and parsed!.

Cybarber
146347-foothills.zip

cybarber

unread,
Oct 5, 2005, 7:57:28 PM10/5/05
to KML Discussions
And now Updated also the Geographic_searcxh_data.gpx converted to KML with the waypoint links inside the Description element. Deleted the empty route and the Bounding Box

(actually I have to go through the GPX2KML.xslt sheet this weeken as it is still very dirty. Have to weed out a lot of unused comments and code. have to check which GPX elements I can put into which KML element. Most of the lements can only be swopped together in the description lement or in the SNippet element. There should be a way to get the <symb/> element connected to the Placemark Icon image but then one should do some mapping between a symb list and some default pallet images or custom images. Problem is that the GPX symb values are not standard i guess. Garmin may use different ones then Magellan? Garmin version differences? Don't know in detail. Does anyone know a list of standart symbols in XML format which could be used as alookup fuyle to map?

Cybarber

Cybarber
146356-geographic_search_data.zip

Travel_By_GPS

unread,
Oct 6, 2005, 5:59:41 AM10/6/05
to KML Discussions
Cy,
Excellent.
Just a few comments:
When opening the foothills.kml file in Google Earth. I see the spinning globe and the foothills trail data showing up in the Carolinas, but the globe continues to rotate and stops over Africa, which is strange but could be my settings.
When I fly back over to the Carolinas, I see the track boundries box which is something new for me and easy enough to turn off.
It took me a minute to figure what was going on with the tracks and routes. I decided to turn off the track "points" and a nice line remained.
The "routes" are an artifact of the origional ExpertGPS file and I will will probably eliminate them from the published data.
Conclusion: you have taken a very detailed GPX file and made it into a nice KML file. The reuslt is an excellent hiking trail presentation in Google Earth.
My complements,

Travel_By_GPS

unread,
Oct 6, 2005, 6:23:41 AM10/6/05
to KML Discussions
Wow.
I spend a good part of my coffee and email time this morning flying around the globe with this data. My only comments are:
The boundy box appears to be sunk in the Arctic Ocean.
There is something going on with "route" which happens to coincide with the Death Valley waypoint.
Once again excellent Cy.

Regarding symbols... the subject of symbols always comes up and is never resolved. GPS manufactures have sets of symbols, not necessarly standard sets, which may differ from receiver to receiver. Mapping software developers have an even wider range of symbols extending to personal symbology ( a recent subject in the GPSXML yahoo group). When I am map authoring, using ExpertGPS, I use the Garmin eTrex set of symbols as there are a great many eTrex units in use by TravelByGPS.com patrons.

cybarber

unread,
Oct 6, 2005, 8:13:04 AM10/6/05
to KML Discussions


Hi,

The transparent box is




something which I have added to show the boundaries. I didn't check the original GPX file but as the waypoints are spread out too far apart, the bounding box's roof is partly falling below the earths surface, I guess. It is only visually interesting on smaller surfaces where the earths curve is closer too a straight line. I should but some code in to compare minlat-maxlat and minlon-maxlon to set some limit on transforming these attributes to the box.



Yes, it is just another placemark so you can de-select it.
I could also de-select it by default.

I will probably create some input form in my GUI application sothat one can customise the XSLT -transformation process( with some PARAM values)
Open, visibility and whether the track needs to have points besides a path.

Well, you can easily delete the boundary placemark aswell as the empty routes and then save the KML/KMZ file to and open from local host.

Don't understand why GE start boven the ocean I'll check the file tonight in GE.

Cy
146887-StarrPass-Network.kmz

cybarber

unread,
Oct 6, 2005, 9:28:15 AM10/6/05
to KML Discussions
Route:

No nothing is going on there, it is only that in your orignal GPX file it has:

<rtept lat="36.366570" lon="-116.704730">
<name>110</name>
<cmt>DEATH VALLEY</cmt>
<desc>DEATH VALLEY</desc>
<link href="http://www.travelbygps.com/guides/deathvalley/deathvalley.php">
<type>text/html</type>
</link>
<sym>Waypoint</sym>
<type>Waypoint</type>

For my <rtept/> transforms I had the desc, cmt and symb transdformed to the <description/> element. So it went according to the rules. The only thing I chould have done is to add spaces and captions like Symbol: Waypoint, Comment: Death Valley,.

As I wrote before the Sheet is in draft and for the time being i mopped most content elements into the desdcription element.

Cy

mmclaren

unread,
Oct 7, 2005, 9:03:53 AM10/7/05
to KML Discussions
Great work Cybarber,

After a cursory glance through your KML conversion XSL, AFAICT the only time you need to do dirty things in your XSL is when you are calculating "distCosineLaw". Java’s Xalan (and other XSL engines) support the EXSLT Extensions for maths and stuff. Which is also slightly dirty but it will enable your XSL to be used beyond MS IE.

WARNING: non XSL coders avert eyes now.



Adding xmlns:math="http://exslt.org/math" to the stylesheet element will let you do add a template with something like:

Code:

<xsl:template name="distCosineLaw">
<xsl:param name="lo1" />
<xsl:param name="la1" />
<xsl:param name="lo2" />
<xsl:param name="la2" />
<xsl:variable name="R">6371000</xsl:variable>
<xsl:variable name="ratio">
<xsl:value-of select="(math:constant('PI',10)) div 180" />
</xsl:variable>
<xsl:variable name="lon1">
<xsl:value-of select="lo1 * $ratio" />
</xsl:variable>
<xsl:variable name="lat1">
<xsl:value-of select="la1 * $ratio" />
</xsl:variable>
<xsl:variable name="lon2">
<xsl:value-of select="lo2 * $ratio" />
</xsl:variable>
<xsl:variable name="lat2">
<xsl:value-of select="la2 * $ratio" />
</xsl:variable>
<xsl:value-of select="math:acos(math:sin($lat1) * math:sin($lat2) + math:cos($lat1) * math:cos($lat2) * math:cos($lon2 - $lon1)) * R" />
</xsl:template>



This could then be called using something like:

Code:

<xsl:variable name="distancedelta">
<xsl:call-template name="distCosineLaw">
<xsl:with-param name="lo1">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib - 1]/@lon|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lon)" />
</xsl:with-param>
<xsl:with-param name="la1">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib - 1]/@lat|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lat)" />
</xsl:with-param>
<xsl:with-param name="lo2">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib]/@lon|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lon)" />
</xsl:with-param>
<xsl:with-param name="la2">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib]/@lat|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lat)" />
</xsl:with-param>
</xsl:call-template>
</xsl:variable>



HTH

Mark

cybarber

unread,
Oct 7, 2005, 9:43:34 AM10/7/05
to KML Discussions
Thanks for the remarks.

I'll look into it over the weekend.

Cybarber

Auldthief

unread,
Nov 16, 2005, 4:44:05 AM11/16/05
to KML Discussions
Hi Cybarber!
I was looking for a KML to GPX conversion utility and Urs was perfect! But I wasn't able to transform this file.The file is 1round 1400 KB but the GPX file is only 3 KB.Am I doing something wrong here? Ur interface is so simple THere's hardly a possibility to go wrong, though! Can you please look into it?
199600-MyPlaces3.kml

cybarber

unread,
Nov 24, 2005, 3:04:32 PM11/24/05
to KML Discussions
Hi,

Sorry for the late reply.

The file is just a random set of folders with worldwide random placemarks.
Such a file is not suitable for GPX unless you want all the placemarks to be converted to gpx:wpt (waypoints).
There is no track nor route in your file.

So all in all it doesn't make sense to convert your My Places.kml file to a GPX file.

As is written in the renewed Gui (also zip file is updated) for a good transformation the KML file should have the structure of Waypoints folder, track folder with subfolders for tracks and a similar structure for routes.

Cybarber

marincho

unread,
Sep 29, 2006, 6:45:46 PM9/29/06
to KML Discussions
As a Real Estate developer I use Google Earth intensively to structure my geographical database that covers Dallas-Forth Worth and fifty small towns in the area. I have many sources and types of data: rents, land values demographics, plats, surveys, aerial photos, GPS field data etc etc.. Google Earth is great to structure the gepgraphical database but it only exports KSL files and you can not input other maps surveys aerial photos etc. Searching in the internet for a solution to my problem I found Gartrip and it worked wonderfully, Its clean, easy, elegant a superb German product. The only limitation was that it could not import KML files.. I sent a email to Heinrich and in a few days he had the solution which will soon be available to all Gartrip users. This globalized world of us is incredible, you can go as fast as you can think and you can match the power of Google with the wits of a German entrepreneur.. Best of all it all spreads like wildfire and benefits all. I no longer use Garmin Mapsource software, the Google Earth/Gartip solution is much more powerful and useful...

DavidAG

unread,
Dec 29, 2006, 10:38:28 PM12/29/06
to KML Discussions
Reply all
Reply to author
Forward
0 new messages