Debian Codegraph @

test/footleg/cavesurvey/data/model/SurveySeriesTest.java

raw symbols SCIP
1 /**
2 * Copyright (C) 2009-2017 Paul Fretwell - aka 'Footleg' ([email protected])
3 *
4 * This file is part of Cave Converter.
5 *
6 * Cave Converter is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Cave Converter is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Cave Converter. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package footleg.cavesurvey.data.model;
20
21 import static org.junit.Assert.*;
22
23 import java.text.ParseException;
24 import java.util.Date;
25
26 import org.junit.Test;
27
28 import footleg.cavesurvey.converter.CaveConverter.BearingUnit;
29 import footleg.cavesurvey.converter.CaveConverter.GradientUnit;
30 import footleg.cavesurvey.converter.CaveConverter.LengthUnit;
31 import footleg.cavesurvey.data.model.SeriesLink;
32 import footleg.cavesurvey.data.model.SurveySeries;
33 import footleg.cavesurvey.data.model.SurveyStation;
34 import footleg.cavesurvey.tools.TestHelper;
35 import footleg.cavesurvey.tools.UtilityFunctions;
36
37 /**
38 * Unit test class for {@link footleg.cavesurvey.data.model.SurveySeries}
39 *
40 * @author Footleg
41 * @version 2017.01.07 (ISO 8601 YYYY.MM.DD)
42 * @since 1.6 (The Java version used)
43 */
44 public class SurveySeriesTest {
45
46 /**
47 * Test method for {@link footleg.cavesurvey.data.model.SurveyLeg#constructor(String)},
48 * {@link footleg.cavesurvey.data.model.SurveyLeg#getSeriesName(String)},
49 * {@link footleg.cavesurvey.data.model.SurveyLeg#setSeriesName(String)}.
50 */
51 @Test
52 public void testSurveySeriesName() {
53 String seriesName1 = "Test Series";
54 String seriesName2 = "Renamed Series";
55
56 //Create series with a name
57 SurveySeries series = new SurveySeries( seriesName1 );
58
59 //Check name returned matches the name given
60 assertTrue("Series name matches name given in contructor.", series.getSeriesName() == seriesName1 );
61
62 //Change the series name
63 series.setSeriesName( seriesName2 );
64
65 //Check the name returned matches the updated name
66 assertTrue("Series name matches the updated name.", series.getSeriesName() == seriesName2 );
67 }
68
69 @Test
70 public void testSeriesDateGetSet() {
71 SurveySeries series = new SurveySeries( "Test" );
72 String dateString = "12/02/1982 01:15:53";
73 String dateFormat = "dd/MM/yyyy HH:mm:ss";
74 try {
75 Date date = UtilityFunctions.stringToDate(dateString, dateFormat);
76 series.setSurveyDate(date);
77 } catch (ParseException e) {
78 //Just print out error (will never happen with hard coded arguments used in method call above)
79 e.printStackTrace();
80 }
81
82 assertEquals("Date returned should match date set.",
83 dateString, UtilityFunctions.dateToString(series.getSurveyDate(), dateFormat) );
84
85 }
86
87 @Test
88 public void testSeriesCommentSetSet() {
89 SurveySeries series = new SurveySeries( "Test" );
90 String comment = "My surveying is perfect.";
91
92 series.setComment(comment);
93
94 assertEquals("Comment returned should match comment set.", comment, series.getComment() );
95 }
96
97 @Test
98 public void testSetStationIdFromName() {
99 SurveySeries series = new SurveySeries( "Test" );
100 SurveyStation stn = new SurveyStation(0);
101
102 //Set name which is numeric
103 stn.setName("42");
104 series.setStationIdFromName( stn );
105 assertTrue("Station id matches name string as number 42.", stn.getId() == 42 );
106
107 stn.setName("text");
108 series.setStationIdFromName( stn );
109 assertTrue("Station id from non-numeric name should be negative.", stn.getId() == -1 );
110 }
111
112 @Test
113 public void testAddLegSurveyLeg() {
114 SurveySeries series = new SurveySeries( "Test" );
115 double leg1Length = 1.0;
116 double leg2Length = 2.0;
117 double leg3Length = 3.0;
118
119 assertEquals("Series leg count is zero when first created.", 0, series.legCount() );
120
121 series.addLeg( TestHelper.createTestLeg(1,2,leg1Length,58,-14) );
122 assertEquals("Series leg count is one when one leg added.", 1, series.legCount() );
123
124 //Add leg 3 next
125 series.addLeg( TestHelper.createTestLeg(3,4,leg3Length,0,0) );
126 assertEquals("Series leg count is 2 when 2 legs added.", 2, series.legCount() );
127 assertEquals("First leg added is at the start.", series.getLegRaw(0).getLength( LengthUnit.Metres ), leg1Length, 1e-9 );
128 assertEquals("Last leg added is at the end.", series.getLegRaw(series.legCount() - 1).getLength( LengthUnit.Metres ), leg3Length, 1e-9 );
129
130 //Insert leg 2 into second position
131 series.addLeg( TestHelper.createTestLeg(2,3,leg2Length,12,34), 1 );
132 assertEquals("Series leg count is 3 when 3 legs added.", 3, series.legCount() );
133 assertEquals("First leg added is at the start.", series.getLegRaw(0).getLength( LengthUnit.Metres ), leg1Length, 1e-9 );
134 assertEquals("Leg 3 is at the end.", series.getLegRaw(series.legCount() - 1).getLength( LengthUnit.Metres ), leg3Length, 1e-9 );
135 assertEquals("Leg 2 is in the middle.", series.getLegRaw(1).getLength( LengthUnit.Metres ), leg2Length, 1e-9 );
136 }
137
138 /**
139 * Test method for {@link footleg.cavesurvey.data.model.SurveyLeg#getNumberToRepresentStnName(String)}.
140 */
141 @Test
142 public void testGetNumberToRepresentStnName() {
143 SurveySeries series = new SurveySeries( "Test" );
144
145 //Add first station name to get a mapped number
146 String stn1A = "1A";
147 int stn1 = series.getNumberToRepresentStnName(stn1A);
148
149 //Check number is negative
150 assertTrue("Mapped station number should be negative.", stn1 < 0 );
151
152 //Add a second station name
153 String stn2A = "2A";
154 int stn2 = series.getNumberToRepresentStnName(stn2A);
155
156 //Check number is negative
157 assertTrue("Mapped station number should be negative.", stn2 < 0 );
158
159 //Check number is not the same as previous station number
160 assertFalse("Mapped station numbers should be unique.", stn1 == stn2 );
161
162 //Add same mapped name again
163 int stn1b = series.getNumberToRepresentStnName(stn1A);
164
165 //Check same number was returned as last time this name was added
166 assertTrue("Mapped station number should be the same when the same string is passed in a second time.", stn1 == stn1b );
167
168 }
169
170 /**
171 * Test method for {@link footleg.cavesurvey.data.model.SurveyLeg#getMappedStnName(String)}.
172 */
173 @Test
174 public void testGetMappedStnName() {
175 SurveySeries series = new SurveySeries( "Test" );
176
177 //Add first station name to get a mapped number
178 String stn1A = "1A";
179 int stn1 = series.getNumberToRepresentStnName(stn1A);
180 assertTrue("Station number should be negative for a numeric name.", stn1 < 0);
181
182 //Add a second station name
183 String stn2A = "2A";
184 int stn2 = series.getNumberToRepresentStnName(stn2A);
185 assertTrue("Station number should be negative for a numeric name.", stn2 < 0);
186
187 //Add a third station name with a name already used
188 String stn3N = stn2A;
189 int stn3 = series.getNumberToRepresentStnName(stn3N);
190 assertEquals("Station number should be same as last time this name was used.", stn2, stn3);
191
192 //Check name returned for first number
193 assertEquals("Returned station name should match name specified for number.", stn1A, series.getMappedStnName( stn1 ) );
194
195 //Check name returned for 2nd number
196 assertEquals("Returned station name should match name specified for number.", stn2A, series.getMappedStnName( stn2 ) );
197
198 //Check name returned for 3rd number
199 assertEquals("Returned station name should match name specified for number.", stn3N, series.getMappedStnName( stn3 ) );
200
201 //Check that a positive numeric ID returns the name which is that number
202 assertEquals("Station name should match number for positive ids", "123", series.getMappedStnName( 123 ));
203
204 }
205
206 @Test
207 public void testCalibrationGettersSetters() {
208 SurveySeries series = new SurveySeries( "Test" );
209
210 assertEquals("Tape calibration should be zero by default.", 0.0, series.getTapeCalibration( LengthUnit.Metres ), 1e-9);
211 assertEquals("Compass calibration should be zero by default.", 0.0, series.getCompassCalibration( BearingUnit.Degrees ), 1e-9);
212 assertEquals("Clino calibration should be zero by default.", 0.0, series.getClinoCalibration( GradientUnit.Degrees ), 1e-9);
213 assertEquals("Declination should be zero by default.", 0.0, series.getDeclination(), 1e-9);
214
215 double tapeCal = 1.45;
216 double compassCal = 0.52;
217 double clinoCal = -3.74;
218 double decl = 2.56;
219
220 series.setTapeCalibration( tapeCal, LengthUnit.Metres );
221 series.setCompassCalibration(compassCal, BearingUnit.Degrees);
222 series.setClinoCalibration(clinoCal, GradientUnit.Degrees );
223 series.setDeclination(decl);
224
225 assertEquals("Tape calibration should match value that was set.", tapeCal, series.getTapeCalibration( LengthUnit.Metres ), 1e-9);
226 assertEquals("Compass calibration should match value that was set.", compassCal, series.getCompassCalibration( BearingUnit.Degrees ), 1e-9);
227 assertEquals("Clino calibration should match value that was set.", clinoCal, series.getClinoCalibration( GradientUnit.Degrees ), 1e-9);
228 assertEquals("Declination should match value that was set.", decl, series.getDeclination(), 1e-9);
229 }
230
231 @Test
232 public void testAddLink() {
233 SurveySeries series = new SurveySeries( "Test" );
234 String series1 = "ser1";
235 SurveyStation stn1 = new SurveyStation(1);
236 String series2 = "ser2";
237 SurveyStation stn2 = new SurveyStation(2);
238
239
240 assertEquals("Series link count is zero when first created.", 0, series.getLinks().size() );
241 series.addLink(series1, stn1, series2, stn2);
242 assertEquals("Series link count is one when first link has been added.", 1, series.getLinks().size() );
243 SeriesLink link = series.getLinks().get(0);
244 assertEquals("Link series 1 matches series set when adding link.", series1, link.getSeries1() );
245 assertEquals("Link station 1 matches station set when adding link.", stn1, link.getStn1() );
246 assertEquals("Link series 2 matches series set when adding link.", series2, link.getSeries2() );
247 assertEquals("Link station 2 matches station set when adding link.", stn2, link.getStn2() );
248 }
249
250 @Test
251 public void testAddSeries() {
252 SurveySeries series = new SurveySeries( "Parent" );
253
254 assertEquals("Inner series count is zero when first created.", 0, series.innerSeriesCount() );
255
256 String innerSeries1 = "inner1";
257 SurveySeries inner1 = new SurveySeries( innerSeries1 );
258 series.addSeries(inner1);
259 assertEquals("Inner series count is one when first inner series is added.", 1, series.innerSeriesCount() );
260
261 String innerSeries2 = "inner2";
262 SurveySeries inner2 = new SurveySeries( innerSeries2 );
263 series.addSeries(inner2);
264 assertEquals("Inner series count is two when 2nd inner series is added.", 2, series.innerSeriesCount() );
265
266 String innerSeries3 = "inner3";
267 SurveySeries inner3 = new SurveySeries( innerSeries3 );
268 series.addSeries(inner3);
269 assertEquals("Inner series count is 3 when 3rd inner series is added.", 3, series.innerSeriesCount() );
270
271 SurveySeries inner3rd = series.getInnerSeries(2);
272 assertEquals("Inner series at index 2 is 3rd inner series added.", innerSeries3, inner3rd.getSeriesName() );
273
274 SurveySeries innerSearchMatch = series.findInnerSeriesByName(innerSeries2);
275 assertEquals("Inner series matching name used to fin by name.", innerSeries2, innerSearchMatch.getSeriesName() );
276
277 }
278
279 /*
280 * TODO Test support for true vertical legs and true horizontal legs
281 *
282 * TODO Test that calibrations are applied somehow to inner series
283 *
284 * TODO Test that clino readings from 0 to 180 work with appropriate calibration
285 */
286 @Test
287 public void testGetLegCorrectedWithCalibrations() {
288 SurveySeries series = new SurveySeries( "Test" );
289 double leg1Length = 1.0;
290 double leg1Compass = 83.0;
291 double leg1Clino = -2.0;
292
293 double leg2Length = 2.0;
294 double leg2Compass = 359.9;
295 double leg2Clino = -90.0;
296
297 double leg3Length = 3.0;
298 double leg3Compass = 260.5;
299 double leg3Clino = 0.0;
300
301 //Add 3 test legs to series
302 series.addLeg( TestHelper.createTestLeg(1,2,leg1Length,leg1Compass,leg1Clino) );
303 series.addLeg( TestHelper.createTestLeg(2,3,leg2Length,leg2Compass,leg2Clino) );
304 series.addLeg( TestHelper.createTestLeg(3,4,leg3Length,leg3Compass,leg3Clino) );
305
306 //Check lengths are the same as set when no calibration
307 assertEquals("First leg length with no calibration set.", leg1Length, series.getLegCorrected(0).getLength( LengthUnit.Metres ), 1e-9 );
308 assertEquals("Second leg length with no calibration set.", leg2Length, series.getLegCorrected(1).getLength( LengthUnit.Metres ), 1e-9 );
309 assertEquals("Third leg length with no calibration set.", leg3Length, series.getLegCorrected(2).getLength( LengthUnit.Metres ), 1e-9 );
310
311 //Check compass bearings are the same as set when no calibration
312 assertEquals("First leg bearing with no calibration set.", leg1Compass, series.getLegCorrected(0).getCompass(BearingUnit.Degrees), 1e-9 );
313 assertEquals("Second leg bearing with no calibration set.", leg2Compass, series.getLegCorrected(1).getCompass(BearingUnit.Degrees), 1e-9 );
314 assertEquals("Third leg bearing with no calibration set.", leg3Compass, series.getLegCorrected(2).getCompass(BearingUnit.Degrees), 1e-9 );
315
316 //Check clino readings are the same as set when no calibration
317 assertEquals("First leg clino with no calibration set.", leg1Clino, series.getLegCorrected(0).getClino(GradientUnit.Degrees), 1e-9 );
318 assertEquals("Second leg clino with no calibration set.", leg2Clino, series.getLegCorrected(1).getClino(GradientUnit.Degrees), 1e-9 );
319 assertEquals("Third leg clino with no calibration set.", leg3Clino, series.getLegCorrected(2).getClino(GradientUnit.Degrees), 1e-9 );
320
321 //Set tape calibration
322 double tapeCal = 0.1; //Tape is 10cm short
323 series.setTapeCalibration( tapeCal, LengthUnit.Metres );
324 //Lengths recorded in legs are now 10cm too long, so corrected lengths should be shorter
325 leg1Length -= tapeCal;
326 leg2Length -= tapeCal;
327 leg3Length -= tapeCal;
328
329 //Check lengths are the same as set when no calibration
330 assertEquals("First leg length with tape calibration set.", leg1Length, series.getLegCorrected(0).getLength( LengthUnit.Metres ), 1e-9 );
331 assertEquals("Second leg length with tape calibration set.", leg2Length, series.getLegCorrected(1).getLength( LengthUnit.Metres ), 1e-9 );
332 assertEquals("Third leg length with tape calibration set.", leg3Length, series.getLegCorrected(2).getLength( LengthUnit.Metres ), 1e-9 );
333
334 //Check compass bearings are the same as set when no calibration
335 assertEquals("First leg bearing with tape calibration set.", leg1Compass, series.getLegCorrected(0).getCompass(BearingUnit.Degrees), 1e-9 );
336 assertEquals("Second leg bearing with tape calibration set.", leg2Compass, series.getLegCorrected(1).getCompass(BearingUnit.Degrees), 1e-9 );
337 assertEquals("Third leg bearing with tape calibration set.", leg3Compass, series.getLegCorrected(2).getCompass(BearingUnit.Degrees), 1e-9 );
338
339 //Check clino readings are the same as set when no calibration
340 assertEquals("First leg clino with tape calibration set.", leg1Clino, series.getLegCorrected(0).getClino(GradientUnit.Degrees), 1e-9 );
341 assertEquals("Second leg clino with tape calibration set.", leg2Clino, series.getLegCorrected(1).getClino(GradientUnit.Degrees), 1e-9 );
342 assertEquals("Third leg clino with tape calibration set.", leg3Clino, series.getLegCorrected(2).getClino(GradientUnit.Degrees), 1e-9 );
343
344 //Set compass calibration
345 double compassCal = 0.5; //Compass reads 0.5 for North
346 series.setCompassCalibration(compassCal, BearingUnit.Degrees);
347 //Bearing of 0.5 should be zero degrees, so subtract cal value from actuals
348 leg1Compass -= compassCal;
349 leg2Compass -= compassCal;
350 leg3Compass -= compassCal;
351
352 //Check lengths are the same as set when no calibration
353 assertEquals("First leg length with tape and compass calibration set.", leg1Length, series.getLegCorrected(0).getLength( LengthUnit.Metres ), 1e-9 );
354 assertEquals("Second leg length with tape and compass calibration set.", leg2Length, series.getLegCorrected(1).getLength( LengthUnit.Metres ), 1e-9 );
355 assertEquals("Third leg length with tape and compass calibration set.", leg3Length, series.getLegCorrected(2).getLength( LengthUnit.Metres ), 1e-9 );
356
357 //Check compass bearings are the same as set when no calibration
358 assertEquals("First leg bearing with tape and compass calibration set.", leg1Compass, series.getLegCorrected(0).getCompass(BearingUnit.Degrees), 1e-9 );
359 assertEquals("Second leg bearing with tape and compass calibration set.", leg2Compass, series.getLegCorrected(1).getCompass(BearingUnit.Degrees), 1e-9 );
360 assertEquals("Third leg bearing with tape and compass calibration set.", leg3Compass, series.getLegCorrected(2).getCompass(BearingUnit.Degrees), 1e-9 );
361
362 //Check clino readings are the same as set when no calibration
363 assertEquals("First leg clino with tape and compass calibration set.", leg1Clino, series.getLegCorrected(0).getClino(GradientUnit.Degrees), 1e-9 );
364 assertEquals("Second leg clino with tape and compass calibration set.", leg2Clino, series.getLegCorrected(1).getClino(GradientUnit.Degrees), 1e-9 );
365 assertEquals("Third leg clino with tape and compass calibration set.", leg3Clino, series.getLegCorrected(2).getClino(GradientUnit.Degrees), 1e-9 );
366
367 //Set clino calibration
368 double clinoCal = -1.2; //Clino reads -1.2 for level
369 series.setClinoCalibration(clinoCal, GradientUnit.Degrees);
370 //Bearing of 0.5 should be zero degrees, so subtract cal value from actuals
371 leg1Clino -= clinoCal;
372 leg2Clino -= clinoCal;
373 leg3Clino -= clinoCal;
374
375 //Check lengths are the same as set when no calibration
376 assertEquals("First leg length with tape, compass and clino calibration set.", leg1Length, series.getLegCorrected(0).getLength( LengthUnit.Metres ), 1e-9 );
377 assertEquals("Second leg length with tape, compass and clino calibration set.", leg2Length, series.getLegCorrected(1).getLength( LengthUnit.Metres ), 1e-9 );
378 assertEquals("Third leg length with tape, compass and clino calibration set.", leg3Length, series.getLegCorrected(2).getLength( LengthUnit.Metres ), 1e-9 );
379
380 //Check compass bearings are the same as set when no calibration
381 assertEquals("First leg bearing with tape, compass and clino calibration set.", leg1Compass, series.getLegCorrected(0).getCompass(BearingUnit.Degrees), 1e-9 );
382 assertEquals("Second leg bearing with tape, compass and clino calibration set.", leg2Compass, series.getLegCorrected(1).getCompass(BearingUnit.Degrees), 1e-9 );
383 assertEquals("Third leg bearing with tape, compass and clino calibration set.", leg3Compass, series.getLegCorrected(2).getCompass(BearingUnit.Degrees), 1e-9 );
384
385 //Check clino readings are the same as set when no calibration
386 assertEquals("First leg clino with tape, compass and clino calibration set.", leg1Clino, series.getLegCorrected(0).getClino(GradientUnit.Degrees), 1e-9 );
387 assertEquals("Second leg clino with tape, compass and clino calibration set.", leg2Clino, series.getLegCorrected(1).getClino(GradientUnit.Degrees), 1e-9 );
388 assertEquals("Third leg clino with tape, compass and clino calibration set.", leg3Clino, series.getLegCorrected(2).getClino(GradientUnit.Degrees), 1e-9 );
389
390 //Set declination adjustment
391 double declination = 2.36; //
392 series.setDeclination(declination);
393 //Bearing of 0.5 should be zero degrees, so subtract cal value from actuals
394 leg1Compass -= declination;
395 leg2Compass -= declination;
396 leg3Compass -= declination;
397
398 //Check lengths are the same as set when no calibration
399 assertEquals("First leg length with all calibrations set plus declination.", leg1Length, series.getLegCorrected(0).getLength( LengthUnit.Metres ), 1e-9 );
400 assertEquals("Second leg length with all calibrations set plus declination.", leg2Length, series.getLegCorrected(1).getLength( LengthUnit.Metres ), 1e-9 );
401 assertEquals("Third leg length with all calibrations set plus declination.", leg3Length, series.getLegCorrected(2).getLength( LengthUnit.Metres ), 1e-9 );
402
403 //Check compass bearings are the same as set when no calibration
404 assertEquals("First leg bearing with all calibrations set plus declination.", leg1Compass, series.getLegCorrected(0).getCompass(BearingUnit.Degrees), 1e-9 );
405 assertEquals("Second leg bearing with all calibrations set plus declination.", leg2Compass, series.getLegCorrected(1).getCompass(BearingUnit.Degrees), 1e-9 );
406 assertEquals("Third leg bearing with all calibrations set plus declination.", leg3Compass, series.getLegCorrected(2).getCompass(BearingUnit.Degrees), 1e-9 );
407
408 //Check clino readings are the same as set when no calibration
409 assertEquals("First leg clino with all calibrations set plus declination.", leg1Clino, series.getLegCorrected(0).getClino(GradientUnit.Degrees), 1e-9 );
410 assertEquals("Second leg clino with all calibrations set plus declination.", leg2Clino, series.getLegCorrected(1).getClino(GradientUnit.Degrees), 1e-9 );
411 assertEquals("Third leg clino with all calibrations set plus declination.", leg3Clino, series.getLegCorrected(2).getClino(GradientUnit.Degrees), 1e-9 );
412 }
413
414 /*
415 * On Vulcain topofil the clino is from 0 to 180 and
416 * 0 = +90
417 * 90 = 0
418 * 180 = -90
419 *
420 * measured value = (read value - zero error) x scale
421 * calibrate clino 90 -1
422 *
423 */
424 @Test
425 public void testClinoCalibrationsForTopofil() {
426 SurveySeries series = new SurveySeries( "Test" );
427
428 //Set clino calibration for topofil
429 series.setClinoCalibration(90.0, GradientUnit.Degrees, -1);
430
431 //Clino of 0 should be +90 degrees
432 double clinoReading = 0.0;
433 double clinoCorrected = 90.0;
434
435 series.addLeg( TestHelper.createTestLeg(1,2,1.1,158.0,clinoReading) );
436 assertEquals("Clino corrected for topofil data.", clinoCorrected, series.getLegCorrected(0).getClino(GradientUnit.Degrees), 1e-9 );
437
438 //Clino of 90 should be 0 degrees
439 clinoReading = 90.0;
440 clinoCorrected = 0.0;
441
442 series.addLeg( TestHelper.createTestLeg(2,3,2.2,274.0,clinoReading) );
443 assertEquals("Clino corrected for topofil data.", clinoCorrected, series.getLegCorrected(1).getClino(GradientUnit.Degrees), 1e-9 );
444
445 //Clino of 180 should be -90 degrees
446 clinoReading = 180.0;
447 clinoCorrected = -90.0;
448
449 series.addLeg( TestHelper.createTestLeg(3,4,3.3,64.0,clinoReading) );
450 assertEquals("Clino corrected for topofil data.", clinoCorrected, series.getLegCorrected(2).getClino(GradientUnit.Degrees), 1e-9 );
451 }
452
453 /* Reverse series method is no longer used, so is commented out in series class
454 @Test
455 public void testReverseSeries() {
456 SurveySeries series = new SurveySeries( "Test" );
457
458 double tape1 = 1.0;
459 double tape2 = 2.0;
460 double tape3 = 3.0;
461 double tape4 = 4.0;
462
463 series.addLeg( TestHelper.createTestLeg( 1, 2, tape1, 10, 10 ) );
464 series.addLeg( TestHelper.createTestLeg( 2, 3, tape2, 100, 20 ) );
465 series.addLeg( TestHelper.createTestLeg( 3, 4, tape3, 190, 0 ) );
466 series.addLeg( TestHelper.createTestLeg( 4, 5, tape4, 340, -5 ) );
467
468 series.reverseSeries();
469
470 SurveyLeg leg = series.getLegRaw(0);
471 assertEquals("From stn of first leg", 5, leg.getFromStn().getId() );
472 assertEquals("To stn of first leg", 4, leg.getToStn().getId() );
473 assertEquals("Length of first leg", tape4, leg.getLength( LengthUnit.Metres ), 1e-9 );
474 assertEquals("Compass for first leg", 160, leg.getCompass(BearingUnit.Degrees), 1e-9 );
475 assertEquals("Clino for first leg", 5, leg.getClino(GradientUnit.Degrees), 1e-9 );
476
477 leg = series.getLegRaw(1);
478 assertEquals("From stn of 2nd leg", 4, leg.getFromStn().getId() );
479 assertEquals("To stn of 2nd leg", 3, leg.getToStn().getId() );
480 assertEquals("Length of 2nd leg", tape3, leg.getLength( LengthUnit.Metres ), 1e-9 );
481 assertEquals("Compass for 2nd leg", 10, leg.getCompass(BearingUnit.Degrees), 1e-9 );
482 assertEquals("Clino for 2nd leg", 0, leg.getClino(GradientUnit.Degrees), 1e-9 );
483
484 leg = series.getLegRaw(2);
485 assertEquals("From stn of 3rd leg", 3, leg.getFromStn().getId() );
486 assertEquals("To stn of 3rd leg", 2, leg.getToStn().getId() );
487 assertEquals("Length of 3rd leg", tape2, leg.getLength( LengthUnit.Metres ), 1e-9 );
488 assertEquals("Compass for 3rd leg", 280, leg.getCompass(BearingUnit.Degrees), 1e-9 );
489 assertEquals("Clino for 3rd leg", -20, leg.getClino(GradientUnit.Degrees), 1e-9 );
490
491 leg = series.getLegRaw(3);
492 assertEquals("From stn of 4th leg", 2, leg.getFromStn().getId() );
493 assertEquals("To stn of 4th leg", 1, leg.getToStn().getId() );
494 assertEquals("Length of 4th leg", tape1, leg.getLength( LengthUnit.Metres ), 1e-9 );
495 assertEquals("Compass for 4th leg", 190, leg.getCompass(BearingUnit.Degrees), 1e-9 );
496 assertEquals("Clino for 4th leg", -10, leg.getClino(GradientUnit.Degrees), 1e-9 );
497 }
498 */
499
500 }