<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lx="http://www.landxml.org/schema/LandXML-1.1" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:landUtils="http://www.autodesk.com/land/civil/vcedit" xmlns:earthworkUtils="urn:schemas-earth" xmlns:lxml="urn:lx_utils">
	<!--Description:Earthwork volumes report-->
	<!--CreatedBy:Autodesk Inc. -->
	<!--DateCreated:04/20/2004 -->
	<!--LastModifiedBy:Autodesk Inc. -->
	<!--DateModified:04/20/2004 -->
	<!--OutputExtension:html -->
	<xsl:output method="html" encoding="UTF-8"/>
	<!-- ==== JavaScript Includes ==== -->
	<xsl:include href="../scripts/NumberFormatting.xsl"/>
	<xsl:include href="../scripts/StationFormatting.xsl"/>
	<!-- ============================= -->
	<!--
	<xsl:param name="SourceAreaUnit" select=".//Units/*/@areaUnit"/>
	<xsl:param name="SourceVolumeUnit" select="AeccEarthworkXML/Units/*/@volumeUnit"/>
	<xsl:param name="Surface.2D_Area.unit">default</xsl:param>
	<xsl:param name="Surface.2D_Area.precision">0.00</xsl:param>
	<xsl:param name="Surface.2D_Area.rounding">normal</xsl:param>
	<xsl:param name="Earthwork.Volume.unit">default</xsl:param>
	<xsl:param name="Earthwork.Volume.precision">0.00</xsl:param>
	<xsl:param name="Earthwork.Volume.rounding">normal</xsl:param>
	<xsl:param name="projectName" select="AeccEarthworkXML/Project/@name"/>
	<xsl:param name="alignmentName" select="AeccEarthworkXML/Alignments/Alignment/@name"/>
	-->
	
	<xsl:param name="SourceAreaUnit" select="AeccEarthworkXML/Settings/Area/@unit"/>
	<xsl:param name="SourceVolumeUnit" select="AeccEarthworkXML/Settings/Volume/@unit"/>
	<xsl:param name="Surface.2D_Area.unit">default</xsl:param>
	<xsl:param name="Surface.2D_Area.precision">0.00</xsl:param>
	<xsl:param name="Surface.2D_Area.rounding">normal</xsl:param>
	<xsl:param name="Earthwork.Volume.unit">default</xsl:param>
	<xsl:param name="Earthwork.Volume.precision">0.00</xsl:param>
	<xsl:param name="Earthwork.Volume.rounding">normal</xsl:param>
	<xsl:param name="projectName" select="AeccEarthworkXML/Project/@name"/>
	<xsl:param name="alignmentName" select="AeccEarthworkXML/Alignment/@name"/>
	
	<xsl:template match="/">
		<html>
			<head>
				<title>合計土量計算書<xsl:value-of select="//lx:Alignment/@name"/>
				</title>
			</head>
			<body>
				<div style="width:7in">
					<h1 align="center">合計土量計算書</h1>
					<table border="0" cellspacing="0" cellpadding="0">

						<tr>
							<td>
								<h3>
									平面線形名:&#160;&#160;<xsl:value-of select=".//Alignment/@name"/>
								</h3>
							</td>
						</tr>
					</table>
					<br/>
					<table bordercolor="black" border="1" cellspacing="0" cellpadding="3" width="98%" align="center">
						<tr style="font-size:10pt;font-family:Verdana;text-decoration">
							<xsl:variable name="linearUnit" select="AeccEarthworkXML/Units/Imperial/@linearUnit"/>
							<xsl:variable name="areaUnit" select="AeccEarthworkXML/Units/*/@areaUnit"/>
							<xsl:variable name="volumeUnit" select="AeccEarthworkXML/Units/*/@volumeUnit"/>
							<th>測点</th>
							<!--<th>Raw Station</th>-->
							<!--                                                   切土面積                                   -->
							<xsl:choose>
								<xsl:when test="$areaUnit='squareFoot'">
									<th>切土面積</th>
								</xsl:when>
								<xsl:when test="$areaUnit='squareMeter'">
									<th>切土面積</th>
								</xsl:when>
								<xsl:otherwise>
									<th>切土面積</th>
								</xsl:otherwise>
							</xsl:choose>
							<!--                                                   切土量                              -->
							<xsl:choose>
								<xsl:when test="$volumeUnit='cubicFoot'">
									<th>切土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicMeter'">
									<th>切土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicYard'">
									<th>切土量</th>
								</xsl:when>
								<xsl:otherwise>
									<th>切土量</th>
								</xsl:otherwise>
							</xsl:choose>
							<!--                                                   合計切土量          -->
							<xsl:choose>
								<xsl:when test="$volumeUnit='cubicFeet'">
									<th>合計切土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicMeter'">
									<th>合計切土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicYard'">
									<th>合計切土量</th>
								</xsl:when>
								<xsl:otherwise>
									<th>合計切土量</th>
								</xsl:otherwise>
							</xsl:choose>
							<!--                                                   盛土面積          -->
							<xsl:choose>
								<xsl:when test="$areaUnit='squareFoot'">
									<th>盛土面積</th>
								</xsl:when>
								<xsl:when test="$areaUnit='squareMeter'">
									<th>盛土面積</th>
								</xsl:when>
								<xsl:otherwise>
									<th>盛土面積</th>
								</xsl:otherwise>
							</xsl:choose>
							<!--                                                   盛土量          -->
							<xsl:choose>
								<xsl:when test="$volumeUnit='cubicFeet'">
									<th>盛土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicMeter'">
									<th>盛土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicYard'">
									<th>盛土量</th>
								</xsl:when>
								<xsl:otherwise>
									<th>盛土量</th>
								</xsl:otherwise>
							</xsl:choose>

							<!--                                                   合計盛土量          -->
							<xsl:choose>
								<xsl:when test="$volumeUnit='cubicFeet'">
									<th>合計盛土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicMeter'">
									<th>合計盛土量</th>
								</xsl:when>
								<xsl:when test="$volumeUnit='cubicYard'">
									<th>合計盛土量</th>
								</xsl:when>
								<xsl:otherwise>
									<th>合計盛土量</th>
								</xsl:otherwise>
							</xsl:choose>
							<!--<th>Net Volume</th>-->
							<!-- extra cell at the end is indroduced-->
						</tr>
						<tr>
							<!-- Indroduces a small gap between header and the data-->
						</tr>
						<!--     Following section presents earthwork data in tabular form-->
<!--						<xsl:for-each select="AeccEarthworkXML/Alignments">-->
						<xsl:for-each select="AeccEarthworkXML">
							<xsl:for-each select="//Alignment/CrossSects">
								<xsl:for-each select="./CrossSect">
									<tr style="font-size:10pt;font-family:Verdana">
										<xsl:variable name="station" select="@sta"/>
										<td align="right">
											<xsl:value-of select="landUtils:getFormattedStation(string($station))"/>
										</td>
										<xsl:variable name="areaCut" select="@areaCut"/>
										<xsl:variable name="areaFill" select="@areaFill"/>
										<xsl:variable name="areaUsable" select="@areaUsable"/>
										<xsl:variable name="incVolCut" select="@volumeCut"/>
										<xsl:variable name="incVolFill" select="@volumeFill"/>
										<xsl:variable name="incVolUsable" select="@volumeUsable"/>
										<xsl:variable name="cumVolCut" select="@cumVolumeCut"/>
										<xsl:variable name="cumVolFill" select="@cumVolumeFill"/>
										<xsl:variable name="cumVolUsable" select="@cumVolumeUsable"/>
										<xsl:variable name="massHaul" select="@massHaul"/>
										<!--                                                   切土面積                                   -->
										<xsl:choose>
											<xsl:when test="@areaCut">
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string($areaCut), string($SourceAreaUnit), string($Surface.2D_Area.unit), string($Surface.2D_Area.precision), string($Surface.2D_Area.rounding))"/>
												</td>
											</xsl:when>
											<xsl:otherwise>
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string(0.0), string($SourceAreaUnit), string($Surface.2D_Area.unit), string($Surface.2D_Area.precision), string($Surface.2D_Area.rounding))"/>
												</td>
											</xsl:otherwise>
										</xsl:choose>
										<!--                                                   切土量                                   -->
										<xsl:choose>
											<xsl:when test="@volumeCut">
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string($incVolCut), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:when>
											<xsl:otherwise>
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string(0.0), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:otherwise>
										</xsl:choose>
										<!--                                                   合計切土量                   -->
										<xsl:choose>
											<xsl:when test="@cumVolumeCut">
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string($cumVolCut), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:when>
											<xsl:otherwise>
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string(0.0), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:otherwise>
										</xsl:choose>
										<!--                                                   盛土面積                                   -->
										<xsl:choose>
											<xsl:when test="@areaFill">
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string($areaFill), string($SourceAreaUnit), string($Surface.2D_Area.unit), string($Surface.2D_Area.precision), string($Surface.2D_Area.rounding))"/>
												</td>
											</xsl:when>
											<xsl:otherwise>
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string(0.0), string($SourceAreaUnit), string($Surface.2D_Area.unit), string($Surface.2D_Area.precision), string($Surface.2D_Area.rounding))"/>
												</td>
											</xsl:otherwise>
										</xsl:choose>
										<!--                                                   盛土量                                   -->
										<xsl:choose>
											<xsl:when test="@volumeFill">
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string($incVolFill), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:when>
											<xsl:otherwise>
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string(0.0), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:otherwise>
										</xsl:choose>
										<!--                                                   合計盛土量                                   -->
										<xsl:choose>
											<xsl:when test="@cumVolumeFill">
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string($cumVolFill), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:when>
											<xsl:otherwise>
												<td align="right">
													<xsl:value-of select="landUtils:FormatNumber(string(0.0), string($SourceVolumeUnit), string($Earthwork.Volume.unit), string($Earthwork.Volume.precision), string($Earthwork.Volume.rounding))"/>
												</td>
											</xsl:otherwise>
										</xsl:choose>
									</tr>
								</xsl:for-each>
							</xsl:for-each>
						</xsl:for-each>
					</table>
				</div>
			</body>
		</html>
	</xsl:template>
	<msxsl:script language="vbScript" implements-prefix="earthworkUtils"><![CDATA[
function FormatVolume(numberStr, fromStr, toStr, precisionStr, roundingStr)

	dim numStr,fStr,tStr,pStr,rStr,origNumber,convNumber,precDepth,fixedDec,rNumber
	fStr = fromStr
	tStr = toStr
	pStr = precisionStr
	rStr = roundingStr
	
	numStr = numberStr


	origNumber = numStr
	
	convNumber = 0
	rNumber = numberStr
	
	' Do conversion if necessary
	if  (tStr = "default") then
		convNumber = origNumber
	else
		convNumber = ConvertVolume(origNumber, fStr, tStr)
	end if
	rNumber = FormatPrecision(convNumber, pStr, rStr)
	
	FormatVolume = CStr(rNumber)

end function

function ConvertVolume(num, fromStr, toStr)

	dim convNumber 
	dim numer 

	convNumber = num
	numer = num

	if(fromStr = "cubicFeet") then
		if(toStr = "cubicMeter") then
			convNumber = CubicFeetToMeters(numer)
		end if
	
	elseif(fromStr = "cubicMeter") then
		if(toStr = "cubicFeet") then
		
			convNumber = CubicMeterToFeet(numer)
		end if
	else
		convNumber = numer
	end if
	
	ConvertVolume = convNumber
end function


function CubicMeterToFeet(d)

	CubicMeterToFeet = d/(.3048^3)
end function

function CubicFeetToMeters(d)

	CubicFeetToMeters =  d * (.3048^3)
end function



]]></msxsl:script>
</xsl:stylesheet>
