[PATCH] Allow more flexible GPS coordinates for CSV import

Miika Turkia miika.turkia at gmail.com
Wed Dec 10 09:44:53 PST 2014


This theoretically allows one to use format like
1°36'11.711"N 124°46'00.368"E for GPS coordinates. However, in practice
this is not allowed without properly parsing this format in C/C++ side.

This patch changes the export format to UTF8 and improves the location
import by allowing either gps or location attributes to be imported.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 xslt/manualcsv2xml.xslt | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt
index cbfb9ea..1ad9651 100644
--- a/xslt/manualcsv2xml.xslt
+++ b/xslt/manualcsv2xml.xslt
@@ -19,7 +19,7 @@
   <xsl:param name="notesField" select="notesField"/>
   <xsl:param name="weightField" select="weightField"/>
   <xsl:param name="dateformat" select="dateformat"/>
-  <xsl:output method="xml" indent="yes"/>
+  <xsl:output method="xml" encoding="utf-8" indent="yes"/>
 
   <xsl:variable name="lf"><xsl:text>
 </xsl:text></xsl:variable>
@@ -166,9 +166,9 @@
 
       <divecomputerid deviceid="ffffffff" model="csv" />
 
-      <xsl:if test="$locationField >= 0">
+      <xsl:if test="$locationField != '' or $gpsField != ''">
         <location>
-          <xsl:if test="$gpsField >= 0">
+          <xsl:if test="$gpsField != ''">
             <xsl:attribute name="gps">
               <xsl:call-template name="getFieldByIndex">
                 <xsl:with-param name="index" select="$gpsField"/>
@@ -176,10 +176,12 @@
               </xsl:call-template>
             </xsl:attribute>
           </xsl:if>
-          <xsl:call-template name="getFieldByIndex">
-            <xsl:with-param name="index" select="$locationField"/>
-            <xsl:with-param name="line" select="$line"/>
-          </xsl:call-template>
+          <xsl:if test="$locationField != ''">
+            <xsl:call-template name="getFieldByIndex">
+              <xsl:with-param name="index" select="$locationField"/>
+              <xsl:with-param name="line" select="$line"/>
+            </xsl:call-template>
+          </xsl:if>
         </location>
       </xsl:if>
 
-- 
1.9.1



More information about the subsurface mailing list