commit
cd6fde8a3a
2 changed files with 137 additions and 106 deletions
|
@ -1447,6 +1447,26 @@ public class GPXUtilities {
|
|||
((TrkSegment) parse).points.add(wptPt);
|
||||
parserState.push(wptPt);
|
||||
}
|
||||
if (parser.getName().equals("csvattributes")) {
|
||||
String segmentPoints = readText(parser, "csvattributes");
|
||||
String[] pointsArr = segmentPoints.split("\n");
|
||||
for (int i = 0; i < pointsArr.length; i++) {
|
||||
String[] pointAttrs = pointsArr[i].split(",");
|
||||
try {
|
||||
int arrLength = pointsArr.length;
|
||||
if (arrLength > 1) {
|
||||
WptPt wptPt = new WptPt();
|
||||
wptPt.lon = Double.parseDouble(pointAttrs[0]);
|
||||
wptPt.lat = Double.parseDouble(pointAttrs[1]);
|
||||
((TrkSegment) parse).points.add(wptPt);
|
||||
if (arrLength > 2) {
|
||||
wptPt.ele = Double.parseDouble(pointAttrs[2]);
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// main object to parse
|
||||
} else if (parse instanceof WptPt) {
|
||||
if (parser.getName().equals("name")) {
|
||||
|
|
|
@ -6,20 +6,20 @@
|
|||
http://opensource.org/licenses/gpl-2.0.php
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:kml="http://www.opengis.net/kml/2.2"
|
||||
xmlns:gx="http://www.google.com/kml/ext/2.2"
|
||||
<xsl:stylesheet xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:ge="http://earth.google.com/kml/2.2"
|
||||
xmlns:gx="http://www.google.com/kml/ext/2.2"
|
||||
xmlns:kml="http://www.opengis.net/kml/2.2"
|
||||
|
||||
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
|
||||
<xsl:output method="xml"
|
||||
indent="yes" />
|
||||
<xsl:output indent="yes"
|
||||
method="xml"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<gpx version="1.1"
|
||||
creator="kml2gpx.xslt"
|
||||
<gpx creator="kml2gpx.xslt"
|
||||
version="1.1"
|
||||
xmlns="http://www.topografix.com/GPX/1/1">
|
||||
<metadata>
|
||||
<name><xsl:value-of select="kml:kml/kml:Document/kml:name"/></name>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,',')">
|
||||
<ele> <xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
<ele><xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<type>
|
||||
|
@ -67,6 +67,7 @@
|
|||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//kml:Placemark">
|
||||
<xsl:if test="kml:Point">
|
||||
<xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,',')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,',')"/>
|
||||
|
@ -86,7 +87,7 @@
|
|||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,',')">
|
||||
<ele> <xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
<ele><xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<type>
|
||||
|
@ -102,6 +103,16 @@
|
|||
</xsl:if>
|
||||
</wpt>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="kml:MultiGeometry/kml:LineString/kml:coordinates">
|
||||
<trk>
|
||||
<trkseg>
|
||||
<csvattributes><xsl:value-of select="kml:MultiGeometry/kml:LineString/kml:coordinates"/></csvattributes>
|
||||
</trkseg>
|
||||
</trk>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//gx:Track">
|
||||
<trk>
|
||||
|
@ -124,7 +135,7 @@
|
|||
<trkpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<ele> <xsl:value-of select="substring-after($latele,' ')"/></ele>
|
||||
<ele><xsl:value-of select="substring-after($latele,' ')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:variable name="ts" select="../kml:when[$i]"/>
|
||||
|
|
Loading…
Reference in a new issue