[PATCH 2/2] Support for Imperial units on MacDive log import

Nick Shore support at mac-dive.com
Thu Feb 7 22:11:47 PST 2013


On 08/02/2013, at 6:47 PM, Miika Turkia <miika.turkia at gmail.com> wrote:

> Thanks Nick, I think this is much clearer now. Even though the
> Imperial units are and will always be a mess from my point of view.

My ones, or Imperial in general? Happy to make any changes that make life easier - I haven't released this update yet so it's no drama to change.


> I noticed you have avergeDepth (mis-spelled) in the XML. Should I go
> for averageDepth assuming you will fix it or will that remain as it
> currently is?

Ah, good catch. Thanks - this is fixed. :)

-nick



> 
> miika
> 
> On Thu, Feb 7, 2013 at 9:49 PM, Nick Shore <support at mac-dive.com> wrote:
>> Hey Miika,
>> 
>> Dirk forwarded your emails to me so here goes some clarification -
>> 
>> Internally in MacDive, tankSize and workingPressure are just plain numbers,
>> no conversions are performed. For Metric units, the working pressure is
>> typically disabled in the ui as it is not used.
>> 
>> I have probably led you slightly astray with the Imperial example I sent
>> you. My personal data is metric so I don't provide a working pressure, and
>> the tank size is in litres. These are just being exported raw so they aren't
>> really correct in that example. Typical data would make more sense I think.
>> 
>> So for Metric, treat the tank size as litres, and ignore working pressure.
>> For Imperial, treat the tank size as cuft and the working pressure as PSI.
>> Hope that helps?  If there's anything I can do to make this easier on your
>> end, let me know.
>> 
>> I saw your other question about rating - I'm not sure if you wanted info
>> from me at all, but the rating is just an integer from 1-5, displayed as 1-5
>> stars in MacDive itself.
>> 
>> cheers,
>> -nick
>> 
>> 
>> 
>> 
>> 
>> On Fri, Feb 8, 2013 at 8:20 AM, Miika Turkia <miika.turkia at gmail.com> wrote:
>>> 
>>> The cylinder size is treated as metric as the samples received indicate
>>> it would be so.
>>> 
>>> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
>>> ---
>>> xslt/MacDive.xslt |   31 ++++++++++++++++++++++++++++---
>>> 1 file changed, 28 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/xslt/MacDive.xslt b/xslt/MacDive.xslt
>>> index 2ddeb27..bd1ba9c 100644
>>> --- a/xslt/MacDive.xslt
>>> +++ b/xslt/MacDive.xslt
>>> @@ -114,12 +114,18 @@
>>>           </xsl:if>
>>>           <xsl:if test="pressureStart != ''">
>>>             <xsl:attribute name="start">
>>> -              <xsl:value-of select="concat(pressureStart, ' bar')"/>
>>> +              <xsl:call-template name="pressureConvert">
>>> +                <xsl:with-param name="number" select="pressureStart"/>
>>> +                <xsl:with-param name="units" select="$units"/>
>>> +              </xsl:call-template>
>>>             </xsl:attribute>
>>>           </xsl:if>
>>>           <xsl:if test="pressureEnd != ''">
>>>             <xsl:attribute name="end">
>>> -              <xsl:value-of select="concat(pressureEnd, ' bar')"/>
>>> +              <xsl:call-template name="pressureConvert">
>>> +                <xsl:with-param name="number" select="pressureEnd"/>
>>> +                <xsl:with-param name="units" select="$units"/>
>>> +              </xsl:call-template>
>>>             </xsl:attribute>
>>>           </xsl:if>
>>>           <xsl:if test="tankSize != ''">
>>> @@ -129,7 +135,10 @@
>>>           </xsl:if>
>>>           <xsl:if test="workingPressure != ''">
>>>             <xsl:attribute name="workpressure">
>>> -              <xsl:value-of select="concat(workingPressure, ' bar')"/>
>>> +              <xsl:call-template name="pressureConvert">
>>> +                <xsl:with-param name="number" select="workingPressure"/>
>>> +                <xsl:with-param name="units" select="$units"/>
>>> +              </xsl:call-template>
>>>             </xsl:attribute>
>>>           </xsl:if>
>>>         </cylinder>
>>> @@ -242,6 +251,22 @@
>>>     </dive>
>>>   </xsl:template>
>>> 
>>> +  <!-- convert pressure to bars -->
>>> +  <xsl:template name="pressureConvert">
>>> +    <xsl:param name="number"/>
>>> +    <xsl:param name="units"/>
>>> +
>>> +    <xsl:choose>
>>> +      <xsl:when test="$units = 'Imperial'">
>>> +        <xsl:value-of select="concat(round($number div 14.5037738007), '
>>> bar')"/>
>>> +      </xsl:when>
>>> +      <xsl:otherwise>
>>> +        <xsl:value-of select="concat($number, ' bar')"/>
>>> +      </xsl:otherwise>
>>> +    </xsl:choose>
>>> +  </xsl:template>
>>> +  <!-- end convert pressure -->
>>> +
>>>   <!-- convert time in seconds to minutes:seconds -->
>>>   <xsl:template name="timeConvert">
>>>     <xsl:param name="timeSec"/>
>>> --
>>> 1.7.9.5
>>> 
>>> _______________________________________________
>>> subsurface mailing list
>>> subsurface at hohndel.org
>>> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
>> 
>> 



More information about the subsurface mailing list