-
Notifications
You must be signed in to change notification settings - Fork 1
/
Trimble Total Station Differential Levelling.xsl
4675 lines (4153 loc) · 204 KB
/
Trimble Total Station Differential Levelling.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<!-- (c) 2021, Trimble Inc. All rights reserved. -->
<!-- Permission is hereby granted to use, copy, modify, or distribute this style sheet for any -->
<!-- purpose and without fee, provided that the above copyright notice appears in all copies -->
<!-- and that both the copyright notice and the limited warranty and restricted rights notice -->
<!-- below appear in all supporting documentation. -->
<!-- TRIMBLE INC. PROVIDES THIS STYLE SHEET "AS IS" AND WITH ALL FAULTS. -->
<!-- TRIMBLE INC. SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY -->
<!-- OR FITNESS FOR A PARTICULAR USE. TRIMBLE INC. DOES NOT WARRANT THAT THE -->
<!-- OPERATION OF THIS STYLE SHEET WILL BE UNINTERRUPTED OR ERROR FREE. -->
<!-- Developed by Andrew Cleland 2023 -->
<!-- 230919 -->
<!-- Differential levelling data can be collected with a total station.
See https://github.com/UniSQ-Surveying/Differential_Levelling for instructions
on how to do this.
This stylesheet has been developed to output data collected with a total station
in standard level book format (BS, IS, FS, Rise, Fall).
-->
<xsl:output method="html" omit-xml-declaration="no" encoding="utf-8"/>
<!-- Set the numeric display details i.e. decimal point, thousands separator etc -->
<xsl:variable name="DecPt" select="'.'"/> <!-- Change as appropriate for US/European -->
<xsl:variable name="GroupSep" select="','"/> <!-- Change as appropriate for US/European -->
<!-- Also change decimal-separator & grouping-separator in decimal-format below
as appropriate for US/European output -->
<xsl:decimal-format name="Standard"
decimal-separator="."
grouping-separator=","
infinity="Infinity"
minus-sign="-"
NaN="?"
percent="%"
per-mille="߮"
zero-digit="0"
digit="#"
pattern-separator=";" />
<xsl:variable name="DecPl0" select="'#0'"/>
<xsl:variable name="DecPl1" select="concat('#0', $DecPt, '0')"/>
<xsl:variable name="DecPl2" select="concat('#0', $DecPt, '00')"/>
<xsl:variable name="DecPl3" select="concat('#0', $DecPt, '000')"/>
<xsl:variable name="DecPl4" select="concat('#0', $DecPt, '0000')"/>
<xsl:variable name="DecPl5" select="concat('#0', $DecPt, '00000')"/>
<xsl:variable name="DecPl6" select="concat('#0', $DecPt, '000000')"/>
<xsl:variable name="DecPl8" select="concat('#0', $DecPt, '00000000')"/>
<xsl:variable name="fileExt" select="'htm'"/>
<xsl:key name="atmosID-search" match="/JOBFile/FieldBook/AtmosphereRecord" use="@ID"/>
<xsl:key name="tgtHtID-search" match="/JOBFile/FieldBook/TargetRecord" use="@ID"/>
<xsl:key name="stnID-search" match="/JOBFile/FieldBook/StationRecord" use="@ID"/>
<xsl:key name="reducedPt-search" match="/JOBFile/Reductions/Point" use="Name"/>
<!-- User variable definitions - Appropriate fields are displayed on the -->
<!-- Survey Controller screen to allow the user to enter specific values -->
<!-- which can then be used within the style sheet definition to control the -->
<!-- output data. -->
<!-- -->
<!-- All user variables must be identified by a variable element definition -->
<!-- named starting with 'userField' (case sensitive) followed by one or more -->
<!-- characters uniquely identifying the user variable definition. -->
<!-- -->
<!-- The text within the 'select' field for the user variable description -->
<!-- references the actual user variable and uses the '|' character to -->
<!-- separate the definition details into separate fields as follows: -->
<!-- For all user variables the first field must be the name of the user -->
<!-- variable itself (this is case sensitive) and the second field is the -->
<!-- prompt that will appear on the Survey Controller screen. -->
<!-- The third field defines the variable type - there are four possible -->
<!-- variable types: Double, Integer, String and StringMenu. These variable -->
<!-- type references are not case sensitive. -->
<!-- The fields that follow the variable type change according to the type of -->
<!-- variable as follow: -->
<!-- Double and Integer: Fourth field = optional minimum value -->
<!-- Fifth field = optional maximum value -->
<!-- These minimum and maximum values are used by the Survey Controller for -->
<!-- entry validation. -->
<!-- String: No further fields are needed or used. -->
<!-- StringMenu: Fourth field = number of menu items -->
<!-- Remaining fields are the actual menu items - the number of -->
<!-- items provided must equal the specified number of menu items. -->
<!-- -->
<!-- The style sheet must also define the variable itself, named according to -->
<!-- the definition. The value within the 'select' field will be displayed in -->
<!-- the Survey Controller as the default value for the item. -->
<xsl:variable name="userField1" select="'StartHeight|Starting benchmark height|double|'"/>
<xsl:variable name="StartHeight" select="100"/>
<xsl:variable name="userField2" select="'EndHeight|Ending benchmark height|double|'"/>
<xsl:variable name="EndHeight" select="100"/>
<!-- **************************************************************** -->
<!-- Set global variables from the Environment section of JobXML file -->
<!-- **************************************************************** -->
<xsl:variable name="DistUnit" select="/JOBFile/Environment/DisplaySettings/DistanceUnits" />
<xsl:variable name="AngleUnit" select="/JOBFile/Environment/DisplaySettings/AngleUnits" />
<xsl:variable name="CoordOrder" select="/JOBFile/Environment/DisplaySettings/CoordinateOrder" />
<xsl:variable name="TempUnit" select="/JOBFile/Environment/DisplaySettings/TemperatureUnits" />
<xsl:variable name="PressUnit" select="/JOBFile/Environment/DisplaySettings/PressureUnits" />
<!-- Setup conversion factor for coordinate and distance values -->
<!-- Dist/coord values in JobXML file are always in metres -->
<xsl:variable name="DistConvFactor">
<xsl:choose>
<xsl:when test="$DistUnit='Metres'">1.0</xsl:when>
<xsl:when test="$DistUnit='InternationalFeet'">3.280839895</xsl:when>
<xsl:when test="$DistUnit='USSurveyFeet'">3.2808333333357</xsl:when>
<xsl:otherwise>1.0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="DistUnitStr">
<xsl:choose>
<xsl:when test="$DistUnit='InternationalFeet'">ft</xsl:when>
<xsl:when test="$DistUnit='USSurveyFeet'">sft</xsl:when>
<xsl:otherwise>m</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Setup conversion factor for angular values -->
<!-- Angular values in JobXML file are always in decimal degrees -->
<xsl:variable name="AngleConvFactor">
<xsl:choose>
<xsl:when test="$AngleUnit='DMSDegrees'">1.0</xsl:when>
<xsl:when test="$AngleUnit='Gons'">1.111111111111</xsl:when>
<xsl:when test="$AngleUnit='Mils'">17.77777777777</xsl:when>
<xsl:otherwise>1.0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="AngleUnitStr">
<xsl:choose>
<xsl:when test="$AngleUnit='DMSDegrees'">dms</xsl:when>
<xsl:when test="$AngleUnit='Gons'">gon</xsl:when>
<xsl:when test="$AngleUnit='Mils'">mil</xsl:when>
<xsl:otherwise>deg</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Setup boolean variable for coordinate order -->
<xsl:variable name="NECoords">
<xsl:choose>
<xsl:when test="$CoordOrder='North-East-Elevation'">true</xsl:when>
<xsl:when test="$CoordOrder='X-Y-Z'">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Setup conversion factor for pressure values -->
<!-- Pressure values in JobXML file are always in millibars (hPa) -->
<xsl:variable name="PressConvFactor">
<xsl:choose>
<xsl:when test="$PressUnit='MilliBar'">1.0</xsl:when>
<xsl:when test="$PressUnit='InchHg'">0.029529921</xsl:when>
<xsl:when test="$PressUnit='mmHg'">0.75006</xsl:when>
<xsl:otherwise>1.0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="PressUnitStr">
<xsl:choose>
<xsl:when test="$PressUnit='InchHg'">inHg</xsl:when>
<xsl:when test="$PressUnit='mmHg'">mmHg</xsl:when>
<xsl:otherwise>hPa</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="TempUnitStr">
<xsl:choose>
<xsl:when test="$TempUnit='Celsius'"><xsl:text>°C</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>°F</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="product">
<xsl:choose>
<xsl:when test="JOBFile/@product"><xsl:value-of select="JOBFile/@product"/></xsl:when>
<xsl:otherwise>Trimble Survey Controller</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="version">
<xsl:choose>
<xsl:when test="JOBFile/@productVersion"><xsl:value-of select="JOBFile/@productVersion"/></xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number(JOBFile/@version div 100, $DecPl2, 'Standard')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Pi" select="3.14159265358979323846264"/>
<xsl:variable name="halfPi" select="$Pi div 2.0"/>
<!-- **************************************************************** -->
<!-- ************************** Main Loop *************************** -->
<!-- **************************************************************** -->
<xsl:template match="/" >
<html>
<title>Total Station Differential Levelling</title>
<h1>Total Station Differential Levelling</h1>
<!-- Set the font size for use in tables -->
<style type="text/css">
html { font-family: Arial }
body, table, td, th
{
font-size:small;
padding: 5px;
}
table.border {border-style: solid; border-width: 1px; border-color: black; border-collapse: collapse;}
table.noBorder {border-style: none; border-width: 0;}
table {
table-layout: fixed;
}
tr:nth-child(even) {
background-color: #dfdfdf;
}
th {
text-align: center;
font-size: 20px;
font-weight: bold;
}
td {
text-align: center;
font-size: 18px;
}
tr:nth-child(1) {
font-weight: bold;
}
tr:nth-last-child(1) {
font-weight: bold;
}
<!-- // Hide delta h column -->
th:nth-child(8), td:nth-child(8) {
display: none;
}
<!-- // Hide slope distance -->
th:nth-child(9), td:nth-child(9) {
display: none;
}
<!-- // Hide obs type -->
th:nth-child(10), td:nth-child(10) {
display: none;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
}
</style>
<head>
</head>
<body>
<xsl:call-template name="ProjectDetails"/>
<span id="startHeight" style="visibility: hidden;">
<xsl:value-of select="$StartHeight"/>
</span>
<span id="endHeight" style="visibility: hidden;">
<xsl:value-of select="$EndHeight"/>
</span>
<h2>
Starting Benchmark Height: <xsl:value-of select="$StartHeight"/>
</h2>
<h2>
Ending Benchmark Height: <xsl:value-of select="$EndHeight"/>
</h2>
<br />
<br />
<h2>Level Book</h2>
<xsl:call-template name="StartTable">
<xsl:with-param name="includeBorders">true</xsl:with-param>
<xsl:with-param name="Id"><xsl:text>levelBook</xsl:text></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="OutputTwelveElementTableLine">
<xsl:with-param name="val1">
<xsl:text>BS</xsl:text>
</xsl:with-param>
<xsl:with-param name="val2">
<xsl:text>IS</xsl:text>
</xsl:with-param>
<xsl:with-param name="val3">
<xsl:text>FS</xsl:text>
</xsl:with-param>
<xsl:with-param name="val4">
<xsl:text>Rise</xsl:text>
</xsl:with-param>
<xsl:with-param name="val5">
<xsl:text>Fall</xsl:text>
</xsl:with-param>
<xsl:with-param name="val6">
<xsl:text>RL</xsl:text>
</xsl:with-param>
<xsl:with-param name="val7">
<xsl:text>Point Name</xsl:text>
</xsl:with-param>
<xsl:with-param name="val8">
<xsl:text>Delta Height</xsl:text>
</xsl:with-param>
<xsl:with-param name="val9">
<xsl:text>Slope Distance</xsl:text>
</xsl:with-param>
<xsl:with-param name="val10">
<xsl:text>Obs Type</xsl:text>
</xsl:with-param>
<xsl:with-param name="val11">
<xsl:text>BS Dist</xsl:text>
</xsl:with-param>
<xsl:with-param name="val12">
<xsl:text>FS Dist</xsl:text>
</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="OutputLevelData"/>
<tr>
<td id="sumBS"></td>
<td></td>
<td id="sumFS"></td>
<td id="sumRise"></td>
<td id="sumFall"></td>
<td id="delta"></td>
<td></td>
<td></td>
<td></td>
<td id="sumSlopeDistance"></td>
<td id="sumBSDist"></td>
<td id="sumFSDist"></td>
</tr>
<xsl:call-template name="EndTable"/>
<br/>
<br/>
<h2>Allowable Misclose</h2>
<h3>k = BS Dist + FS Dist</h3>
<h3 id="k"></h3>
<h3 id="12rootk"></h3>
<h3 id="6rootk"></h3>
<h3 id="2rootk"></h3>
<div class="footer">
<p>See <a href="https://github.com/UniSQ-Surveying/Differential_Levelling">here</a> for a detailed guide by Damian Forknall, Jordan Williams,
Garry Cislowski and Chris McAlister about how to do differential levelling with a total station.</p>
<p>This stylesheet was developed by Andrew Cleland.</p>
</div>
<script>
function updateSums() {
var table = document.getElementById("levelBook");
let subTotalBS = Array.from(table.rows).slice(1).reduce((total, row) => {
return total + parseFloat(row.cells[0].innerHTML || 0);
}, 0);
document.getElementById("sumBS").innerHTML = "Sum BS = " + subTotalBS.toFixed(4);
let subTotalFS = Array.from(table.rows).slice(1).reduce((total, row) => {
return total + parseFloat(row.cells[2].innerHTML || 0);
}, 0);
document.getElementById("sumFS").innerHTML = "Sum FS = " + subTotalFS.toFixed(4);
let subTotalRise = Array.from(table.rows).slice(1).reduce((total, row) => {
return total + parseFloat(row.cells[3].innerHTML || 0);
}, 0);
document.getElementById("sumRise").innerHTML = "Sum Rise = " + subTotalRise.toFixed(4);
let subTotalFall = Array.from(table.rows).slice(1).reduce((total, row) => {
return total + parseFloat(row.cells[4].innerHTML || 0);
}, 0);
document.getElementById("sumFall").innerHTML = "Sum Fall = " + subTotalFall.toFixed(4);
let subTotalSlopeDistance = Array.from(table.rows).slice(1).reduce((total, row) => {
let obsType = row.cells[9].innerHTML;
let bsOrFS = ['BS', 'FS'].includes(obsType);
return bsOrFS ? (total + (parseFloat(row.cells[8].innerHTML || 0))) : total;
}, 0);
document.getElementById("sumSlopeDistance").innerHTML = "Sum BS and FS (k) = " + subTotalSlopeDistance.toFixed(3);
let subTotalBSDistance = Array.from(table.rows).slice(1).reduce((total, row) => {
return total + (parseFloat(row.cells[10].innerHTML || 0));
}, 0);
document.getElementById("sumBSDist").innerHTML = "Sum BS = " + subTotalBSDistance.toFixed(3);
let subTotalFSDistance = Array.from(table.rows).slice(1).reduce((total, row) => {
return total + (parseFloat(row.cells[11].innerHTML || 0));
}, 0);
document.getElementById("sumFSDist").innerHTML = "Sum FS = " + subTotalFSDistance.toFixed(3);
// Update RL
let rowCount = table.rows.length - 1;
// Get the starting RL from the first level row
const startHeight = parseFloat(document.getElementById("startHeight").innerHTML) || 0;
const endHeight = parseFloat(document.getElementById("endHeight").innerHTML) || 0;
let currentRL = startHeight;
for (var r = 2; r < rowCount; r++){
const deltaHeight = parseFloat(table.rows[r].cells[7].innerHTML) || 0;
currentRL += deltaHeight;
let rlCell = table.rows[r].cells[5];
rlCell.innerHTML = currentRL.toFixed(4);
}
// Calculate diff between starting and ending benchmark readings
document.getElementById("delta").innerHTML = "Misclose = " + (currentRL - endHeight).toFixed(4);
let k = (subTotalBSDistance + subTotalFSDistance) / 1000;
document.getElementById("k").innerHTML = "k = " + k.toFixed(4);
document.getElementById("12rootk").innerHTML = "Third order (12√k) = " + (12 * Math.sqrt(k) / 1000).toFixed(4);
document.getElementById("6rootk").innerHTML = "Second order (6√k) = " + (6 * Math.sqrt(k) / 1000).toFixed(4);
document.getElementById("2rootk").innerHTML = "First order (2√k) = " + (2 * Math.sqrt(k) / 1000).toFixed(4);
}
updateSums();
</script>
</body>
</html>
</xsl:template>
<xsl:template name="ProjectDetails">
<h2>Job: <xsl:value-of select="JOBFile/@jobName" /></h2>
<h2>Date: <xsl:value-of select="substring(JOBFile/@TimeStamp, 1, 10)" /></h2>
<h2>Instrument Details</h2>
<h3>    Model: <xsl:value-of select="JOBFile/FieldBook/InstrumentRecord[last()]/Model" /></h3>
<h3>    Serial: <xsl:value-of select="JOBFile/FieldBook/InstrumentRecord[last()]/Serial" /></h3>
<xsl:variable name="haPrecision">
<xsl:call-template name="FormatAngle">
<xsl:with-param name="theAngle" select="JOBFile/FieldBook/InstrumentRecord[last()]/HorizontalAnglePrecision"/>
<xsl:with-param name="secDecPlaces">2</xsl:with-param>
<xsl:with-param name="DMSOutput">true</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="vaPrecision">
<xsl:call-template name="FormatAngle">
<xsl:with-param name="theAngle" select="JOBFile/FieldBook/InstrumentRecord[last()]/VerticalAnglePrecision"/>
<xsl:with-param name="secDecPlaces">2</xsl:with-param>
<xsl:with-param name="DMSOutput">true</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="edmPrecision">
<xsl:value-of select="format-number(JOBFile/FieldBook/InstrumentRecord[last()]/EDMPrecision, $DecPl3, 'Standard')" />
</xsl:variable>
<xsl:variable name="edmPPM">
<xsl:value-of select="format-number(JOBFile/FieldBook/InstrumentRecord[last()]/EDMppm, $DecPl1, 'Standard')" />
</xsl:variable>
<h3>    Horizontal Angle Precision: <xsl:value-of select="$haPrecision" /></h3>
<h3>    Vertical Angle Precision: <xsl:value-of select="$vaPrecision" /></h3>
<h3>    EDM Precision: <xsl:value-of select="$edmPrecision" /></h3>
<h3>    EDM ppm: <xsl:value-of select="$edmPPM" /></h3>
</xsl:template>
<xsl:template name="OutputLevelData">
<xsl:variable name="AllRounds">
<xsl:call-template name="GetLevelObs"/>
</xsl:variable>
<xsl:variable name="LevelBookRows">
<xsl:for-each select="msxsl:node-set($AllRounds)/StnPoint">
<xsl:variable name="i" select="position()" />
<xsl:variable name="stn" select="stnName" />
<xsl:variable name="ptName" select="pointName" />
<xsl:variable name="bsPoint" select="backsightPoint" />
<xsl:variable name="bsSD" select="backsightSD" />
<!-- Look ahead to the next row so that we can pull out the BS value on a FS row -->
<xsl:variable name="next" select="msxsl:node-set($AllRounds)/StnPoint[$i + 1]" />
<xsl:variable name="prev" select="msxsl:node-set($AllRounds)/StnPoint[$i - 1]" />
<xsl:variable name="firstBS">
<xsl:choose>
<xsl:when test="obsType = 'BS' and $i = 1">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="reducedVDiff">
<xsl:value-of select="format-number(-1 * ($prev/VD - VD), $DecPl4, 'Standard')" />
</xsl:variable>
<xsl:if test="$firstBS = 1 or obsType != 'BS'">
<xsl:element name="Row">
<xsl:element name="Index">
<xsl:value-of select="$i"/>
</xsl:element>
<xsl:element name="firstBS">
<xsl:value-of select="$firstBS"/>
</xsl:element>
<xsl:element name="deltaHeight">
<xsl:value-of select="$reducedVDiff"/>
</xsl:element>
<xsl:element name="SD">
<xsl:value-of select="format-number(SD, $DecPl3, 'Standard')"/>
</xsl:element>
<xsl:element name="backsightSD">
<xsl:value-of select="format-number(backsightSD, $DecPl3, 'Standard')"/>
</xsl:element>
<xsl:element name="ObsType">
<xsl:value-of select="obsType"/>
</xsl:element>
<xsl:choose>
<xsl:when test="obsType = 'BS'">
<xsl:element name="BS">
<xsl:value-of select="VD"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="BS">
<xsl:text />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="obsType = 'IS'">
<xsl:element name="ISRow">
<xsl:element name="IS">
<xsl:value-of select="VD"/>
</xsl:element>
<xsl:element name="Rise">
<xsl:choose>
<xsl:when test="$reducedVDiff >= 0">
<xsl:value-of select="$reducedVDiff"/>
</xsl:when>
<xsl:otherwise>
<xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="Fall">
<xsl:choose>
<xsl:when test="$reducedVDiff < 0">
<xsl:value-of select="$reducedVDiff * -1"/>
</xsl:when>
<xsl:otherwise>
<xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="ISRow">
<xsl:text />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="obsType = 'FS'">
<xsl:element name="FSRow">
<xsl:element name="FS">
<xsl:value-of select="VD"/>
</xsl:element>
<xsl:element name="BS">
<xsl:value-of select="$next/VD"/>
</xsl:element>
<xsl:element name="Rise">
<xsl:choose>
<xsl:when test="$reducedVDiff >= 0">
<xsl:value-of select="$reducedVDiff"/>
</xsl:when>
<xsl:otherwise>
<xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="Fall">
<xsl:choose>
<xsl:when test="$reducedVDiff < 0">
<xsl:value-of select="$reducedVDiff * -1"/>
</xsl:when>
<xsl:otherwise>
<xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:element name="FSDist">
<xsl:value-of select="SD"/>
</xsl:element>
<xsl:element name="BSDist">
<xsl:value-of select="backsightSD"/>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="FSRow">
<xsl:text />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="StnName">
<xsl:value-of select="stnName"/>
</xsl:element>
<xsl:element name="PointName">
<xsl:value-of select="pointName"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($LevelBookRows)/Row">
<xsl:variable name="j" select="position()" />
<xsl:call-template name="OutputTwelveElementTableLine">
<xsl:with-param name="val1">
<!-- Only one of these variables shouild ever have a value.
Using concat to just grab whatever is available -->
<xsl:value-of select="concat(BS, FSRow/BS)"/>
</xsl:with-param>
<xsl:with-param name="val2">
<xsl:value-of select="ISRow/IS"/>
</xsl:with-param>
<xsl:with-param name="val3">
<xsl:value-of select="FSRow/FS"/>
</xsl:with-param>
<xsl:with-param name="val4">
<xsl:value-of select="concat(FSRow/Rise, ISRow/Rise)"/>
</xsl:with-param>
<xsl:with-param name="val5">
<xsl:value-of select="concat(FSRow/Fall, ISRow/Fall)"/>
</xsl:with-param>
<xsl:with-param name="val6">
<xsl:value-of select="format-number($StartHeight, $DecPl4, 'Standard')"/>
</xsl:with-param>
<xsl:with-param name="val7">
<xsl:value-of select="PointName"/>
</xsl:with-param>
<xsl:with-param name="val8">
<xsl:value-of select="deltaHeight"/>
</xsl:with-param>
<xsl:with-param name="val9">
<xsl:value-of select="SD"/>
</xsl:with-param>
<xsl:with-param name="val10">
<xsl:value-of select="ObsType"/>
</xsl:with-param>
<xsl:with-param name="val11">
<xsl:value-of select="FSRow/BSDist"/>
</xsl:with-param>
<xsl:with-param name="val12">
<xsl:value-of select="FSRow/FSDist"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="GetLevelObs">
<xsl:for-each select="/JOBFile/FieldBook/StationRecord">
<xsl:variable name="stnName" select="StationName"/>
<xsl:variable name="instHt" select="TheodoliteHeight"/>
<!-- Now output any Rounds data collected at this Station -->
<xsl:variable name="tempStationRecordPosn">
<xsl:for-each select="following-sibling::*">
<xsl:if test="name(.) = 'StationRecord'">
<xsl:value-of select="concat(position(), ' ')"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="nextStationRecordPosn" select="substring-before($tempStationRecordPosn, ' ')"/>
<xsl:for-each select="following-sibling::*">
<xsl:if test="name(.) = 'StartRoundsRecord'">
<xsl:if test="(position() > 0) and
((position() < $nextStationRecordPosn) or
($nextStationRecordPosn = ''))">
<!-- The current context record is the next appropriate StartRoundsRecord -->
<!-- Now output the rounds data for these rounds. -->
<!-- <xsl:variable name="StnRounds"> -->
<xsl:call-template name="OutputRoundsData">
<xsl:with-param name="stnName" select="$stnName"/>
<xsl:with-param name="instHt" select="$instHt"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:for-each> <!-- /JOBFile/FieldBook/StationRecord -->
</xsl:template>
<!-- **************************************************************** -->
<!-- *************** Output Backsight Point Coordinates ************* -->
<!-- **************************************************************** -->
<xsl:template name="OutputBacksightPoints">
<xsl:param name="stationID"/>
<!-- Get a list of all the backsight point names into a node-set variable -->
<xsl:variable name="BSPtNames">
<xsl:for-each select="/JOBFile/FieldBook/PointRecord[(StationID = $stationID) and (Classification = 'BackSight')]">
<xsl:element name="PtName">
<xsl:element name="Name">
<xsl:value-of select="Name"/>
</xsl:element>
<xsl:variable name="ptName" select="Name"/>
<xsl:element name="North">
<xsl:variable name="north">
<xsl:for-each select="/JOBFile/Reductions/Point[Name = $ptName]">
<xsl:value-of select="Grid/North"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$north"/>
</xsl:element>
<xsl:element name="East">
<xsl:variable name="east">
<xsl:for-each select="/JOBFile/Reductions/Point[Name = $ptName]">
<xsl:value-of select="Grid/East"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$east"/>
</xsl:element>
<xsl:element name="Elevation">
<xsl:variable name="elev">
<xsl:for-each select="/JOBFile/Reductions/Point[Name = $ptName]">
<xsl:value-of select="Grid/Elevation"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$elev"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="StartTable">
<xsl:with-param name="includeBorders">false</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="OutputFourElementTableLine">
<xsl:with-param name="val1">Point Name</xsl:with-param>
<xsl:with-param name="val2">
<xsl:choose>
<xsl:when test="$NECoords = 'true'">Northing</xsl:when>
<xsl:otherwise>Easting</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="val3">
<xsl:choose>
<xsl:when test="$NECoords = 'true'">Easting</xsl:when>
<xsl:otherwise>Northing</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="val4">Elevation</xsl:with-param>
<xsl:with-param name="bold">true</xsl:with-param>
</xsl:call-template>
<xsl:for-each select="msxsl:node-set($BSPtNames)/PtName">
<xsl:variable name="currPos" select="position()"/>
<xsl:variable name="currName" select="Name"/>
<xsl:variable name="prevPts">
<xsl:value-of select="count(msxsl:node-set($BSPtNames)/PtName[(position() < $currPos) and ($currName = Name)])"/>
</xsl:variable>
<xsl:if test="$prevPts = 0"> <!-- Only want to output each point once -->
<xsl:call-template name="OutputFourElementTableLine">
<xsl:with-param name="val1" select="Name"/>
<xsl:with-param name="val2">
<xsl:choose>
<xsl:when test="$NECoords = 'true'"><xsl:value-of select="format-number(North * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(East * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="val3">
<xsl:choose>
<xsl:when test="$NECoords = 'true'"><xsl:value-of select="format-number(East * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(North * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="val4" select="format-number(Elevation * $DistConvFactor, $DecPl4, 'Standard')"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
<xsl:call-template name="EndTable"/>
</xsl:template>
<!-- **************************************************************** -->
<!-- ***************** Output Backsight Measurements **************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputBacksightMeasurements">
<xsl:param name="stationID"/>
<xsl:call-template name="StartTable">
<xsl:with-param name="includeBorders">false</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="OutputEightElementTableLine">
<xsl:with-param name="val1">Point Name</xsl:with-param>
<xsl:with-param name="val2">Code</xsl:with-param>
<xsl:with-param name="val3">SD [<xsl:value-of select="$DistUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val4">HA [<xsl:value-of select="$AngleUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val5">VA [<xsl:value-of select="$AngleUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val6">th [<xsl:value-of select="$DistUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val7">PC [mm]</xsl:with-param>
<xsl:with-param name="bold">true</xsl:with-param>
</xsl:call-template>
<xsl:for-each select="/JOBFile/FieldBook/PointRecord[(StationID = $stationID) and (Classification = 'BackSight')]">
<xsl:variable name="prismConst" select="key('tgtHtID-search', TargetID)[1]/PrismConstant"/>
<xsl:variable name="ppm">
<xsl:for-each select="key('stnID-search', StationID)">
<xsl:value-of select="key('atmosID-search', AtmosphereID)/PPM"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="slopeDist">
<xsl:call-template name="CorrectedDistance">
<xsl:with-param name="slopeDist" select="Circle/EDMDistance"/>
<xsl:with-param name="prismConst" select="$prismConst"/>
<xsl:with-param name="atmosPPM" select="$ppm"/>
<xsl:with-param name="applyStationSF">false</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="OutputEightElementTableLine">
<xsl:with-param name="val1" select="Name"/>
<xsl:with-param name="val2" select="Code"/>
<xsl:with-param name="val3" select="format-number($slopeDist * $DistConvFactor, $DecPl4, 'Standard')"/>
<xsl:with-param name="val4">
<xsl:call-template name="FormatAngle">
<xsl:with-param name="theAngle" select="Circle/HorizontalCircle"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="val5">
<xsl:call-template name="FormatAngle">
<xsl:with-param name="theAngle" select="Circle/VerticalCircle"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="val6">
<xsl:for-each select="key('tgtHtID-search', TargetID)[1]">
<xsl:value-of select="format-number(TargetHeight * $DistConvFactor, $DecPl4, 'Standard')"/>
</xsl:for-each>
</xsl:with-param>
<xsl:with-param name="val7">
<xsl:value-of select="format-number($prismConst * 1000, $DecPl0, 'Standard')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:call-template name="EndTable"/>
</xsl:template>
<!-- **************************************************************** -->
<!-- ******************* Output Station Residuals ******************* -->
<!-- **************************************************************** -->
<xsl:template name="OutputStationResiduals">
<xsl:variable name="stnName" select="StationName"/>
<xsl:call-template name="StartTable">
<xsl:with-param name="includeBorders">false</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="OutputEightElementTableLine">
<xsl:with-param name="val1">Point Name</xsl:with-param>
<xsl:with-param name="val2">Code</xsl:with-param>
<xsl:with-param name="val3">Station [<xsl:value-of select="$DistUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val4">Offset [<xsl:value-of select="$DistUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val5">delta Hz [<xsl:value-of select="$AngleUnitStr"/>]</xsl:with-param>
<xsl:with-param name="val6">
<xsl:choose>
<xsl:when test="$NECoords = 'true'">delta N</xsl:when>
<xsl:otherwise>delta E</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="concat(' [', $DistUnitStr, ']')"/>
</xsl:with-param>
<xsl:with-param name="val7">
<xsl:choose>
<xsl:when test="$NECoords = 'true'">delta E</xsl:when>
<xsl:otherwise>delta N</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="concat(' [', $DistUnitStr, ']')"/>
</xsl:with-param>
<xsl:with-param name="val8">delta El [<xsl:value-of select="$DistUnitStr"/>]</xsl:with-param>
<xsl:with-param name="bold">true</xsl:with-param>
</xsl:call-template>
<!-- First locate the first StationResiduals record following the current StationRecord -->
<xsl:for-each select="following-sibling::StationResiduals[1]">
<!-- Now work through each ResidualsRecord under the StationResiduals -->
<xsl:for-each select="ResidualsRecord">
<xsl:variable name="ptName" select="PointName"/>
<xsl:call-template name="OutputEightElementTableLine">
<!-- Point name -->
<xsl:with-param name="val1" select="PointName"/>
<!-- Point code -->
<xsl:with-param name="val2"> <!-- Get point code from Reductions section -->
<xsl:for-each select="/JOBFile/Reductions/Point[Name = $ptName]">
<xsl:value-of select="Code"/>
</xsl:for-each>
</xsl:with-param>
<!-- Residual expressed along observed line -->
<xsl:with-param name="val3">
<xsl:variable name="station">
<xsl:call-template name="ResidualAlongObsLine">
<xsl:with-param name="stnName" select="$stnName"/>
<xsl:with-param name="ptName" select="$ptName"/>
<xsl:with-param name="resDeltaN" select="GridResidual/DeltaNorth"/>
<xsl:with-param name="resDeltaE" select="GridResidual/DeltaEast"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="format-number($station * $DistConvFactor, $DecPl4, 'Standard')"/>
</xsl:with-param>
<!-- Residual expressed as offset to observed line -->
<xsl:with-param name="val4">
<xsl:variable name="offset">
<xsl:call-template name="ResidualOrthogonalToObsLine">
<xsl:with-param name="stnName" select="$stnName"/>
<xsl:with-param name="ptName" select="$ptName"/>
<xsl:with-param name="resDeltaN" select="GridResidual/DeltaNorth"/>
<xsl:with-param name="resDeltaE" select="GridResidual/DeltaEast"/>
</xsl:call-template>
</xsl:variable>
<!-- Output offset with switched sign to match example -->
<xsl:value-of select="format-number($offset * -1.0 * $DistConvFactor, $DecPl4, 'Standard')"/>
</xsl:with-param>
<!-- Delta horizontal angle -->
<xsl:with-param name="val5">
<xsl:call-template name="FormatAngle">
<xsl:with-param name="theAngle" select="AngleResidual/HorizontalCircle"/>
</xsl:call-template>
</xsl:with-param>
<!-- Residual delta north/east -->
<xsl:with-param name="val6">
<xsl:choose>
<xsl:when test="$NECoords = 'true'"><xsl:value-of select="format-number(GridResidual/DeltaNorth * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(GridResidual/DeltaEast * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<!-- Residual delta east/north -->
<xsl:with-param name="val7">
<xsl:choose>
<xsl:when test="$NECoords = 'true'"><xsl:value-of select="format-number(GridResidual/DeltaEast * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(GridResidual/DeltaNorth * $DistConvFactor, $DecPl4, 'Standard')"/></xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<!-- Residual delta elevation -->
<xsl:with-param name="val8" select="format-number(GridResidual/DeltaElevation * $DistConvFactor, $DecPl4, 'Standard')"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
<xsl:call-template name="EndTable"/>
</xsl:template>
<!-- **************************************************************** -->
<!-- ******************* Output Station Position ******************** -->
<!-- **************************************************************** -->
<xsl:template name="OutputStationPosition">
<xsl:param name="stnName"/>
<xsl:param name="scale"/>
<xsl:param name="scaleSE"/>
<xsl:param name="resectedStn"/>
<xsl:variable name="stnNorth">
<xsl:choose>
<xsl:when test="$resectedStn = 'true'">
<xsl:for-each select="following-sibling::PointRecord[(Name = $stnName) and (Method = 'Resection')][1]">
<xsl:value-of select="Grid/North"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="key('reducedPt-search', $stnName)">
<xsl:value-of select="Grid/North"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>