| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package footleg.cavesurvey.data.reader; |
| 20 |
|
| 21 |
import java.text.ParseException; |
| 22 |
import java.util.ArrayList; |
| 23 |
import java.util.Date; |
| 24 |
import java.util.List; |
| 25 |
|
| 26 |
import footleg.cavesurvey.converter.Logger; |
| 27 |
import footleg.cavesurvey.converter.CaveConverter.BearingUnit; |
| 28 |
import footleg.cavesurvey.converter.CaveConverter.GradientUnit; |
| 29 |
import footleg.cavesurvey.converter.CaveConverter.LengthUnit; |
| 30 |
import footleg.cavesurvey.data.model.CaveSurvey; |
| 31 |
import footleg.cavesurvey.data.model.Equate; |
| 32 |
import footleg.cavesurvey.data.model.SurveyLeg; |
| 33 |
import footleg.cavesurvey.data.model.SurveySeries; |
| 34 |
import footleg.cavesurvey.data.model.SurveyStation; |
| 35 |
import footleg.cavesurvey.tools.UtilityFunctions; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public class PocketTopoParser { |
| 45 |
private Logger logger; |
| 46 |
|
| 47 |
|
| 48 |
private final int LINE_TYPE_LEG = 1; |
| 49 |
private final int LINE_TYPE_SPLAY = 2; |
| 50 |
private final int LINE_TYPE_EQUATE = 3; |
| 51 |
private final int LINE_TYPE_COMMENT = 4; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
public PocketTopoParser( Logger logger ) { |
| 58 |
super(); |
| 59 |
this.logger = logger; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
private class TopoDataLine { |
| 66 |
|
| 67 |
private String fromStn = ""; |
| 68 |
private String toStn = ""; |
| 69 |
private double tape = 0; |
| 70 |
private double compass = 0; |
| 71 |
private double clino = 0; |
| 72 |
private String trip = ""; |
| 73 |
private String comment = ""; |
| 74 |
private int lineType = -1; |
| 75 |
|
| 76 |
public String getFromStn() { |
| 77 |
return fromStn; |
| 78 |
} |
| 79 |
public void setFromStn(String fromStn) { |
| 80 |
this.fromStn = fromStn; |
| 81 |
} |
| 82 |
public String getToStn() { |
| 83 |
return toStn; |
| 84 |
} |
| 85 |
public void setToStn(String toStn) { |
| 86 |
this.toStn = toStn; |
| 87 |
} |
| 88 |
public double getTape() { |
| 89 |
return tape; |
| 90 |
} |
| 91 |
public void setTape(double tape) { |
| 92 |
this.tape = tape; |
| 93 |
} |
| 94 |
public double getCompass() { |
| 95 |
return compass; |
| 96 |
} |
| 97 |
public void setCompass(double compass) { |
| 98 |
this.compass = compass; |
| 99 |
} |
| 100 |
public double getClino() { |
| 101 |
return clino; |
| 102 |
} |
| 103 |
public void setClino(double clino) { |
| 104 |
this.clino = clino; |
| 105 |
} |
| 106 |
public String getTrip() { |
| 107 |
return trip; |
| 108 |
} |
| 109 |
public void setTrip(String trip) { |
| 110 |
this.trip = trip; |
| 111 |
} |
| 112 |
public String getComment() { |
| 113 |
return comment; |
| 114 |
} |
| 115 |
public void setComment(String comment) { |
| 116 |
this.comment = comment; |
| 117 |
} |
| 118 |
public int getLineType() { |
| 119 |
return lineType; |
| 120 |
} |
| 121 |
public void setLineType(int lineType) { |
| 122 |
this.lineType = lineType; |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
public CaveSurvey parseFile( List<String> surveyFileData ) throws ParseException { |
| 134 |
|
| 135 |
|
| 136 |
CaveSurvey surveyData = new CaveSurvey(logger); |
| 137 |
SurveySeries outerSeries = null; |
| 138 |
|
| 139 |
String caveName = ""; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
List<String[]> trips = new ArrayList<String[]>(); |
| 144 |
|
| 145 |
|
| 146 |
List<Equate> equates = new ArrayList<Equate>(); |
| 147 |
|
| 148 |
|
| 149 |
int state = 0; |
| 150 |
|
| 151 |
|
| 152 |
List<SurveyLeg> legShots = new ArrayList<SurveyLeg>(); |
| 153 |
List<SurveyLeg> splayShots = new ArrayList<SurveyLeg>(); |
| 154 |
|
| 155 |
|
| 156 |
String lastShotStart = ""; |
| 157 |
int lastToStn = -1; |
| 158 |
int lastSeriesNo = -1; |
| 159 |
String lastTripCode = ""; |
| 160 |
boolean newLeg = false; |
| 161 |
|
| 162 |
SurveySeries series = null; |
| 163 |
int activeSeries = -1; |
| 164 |
|
| 165 |
|
| 166 |
for ( int lineIdx = 0; lineIdx <= surveyFileData.size(); lineIdx++ ) { |
| 167 |
int lineNo = lineIdx + 1; |
| 168 |
|
| 169 |
|
| 170 |
String dataLine = null; |
| 171 |
if ( lineIdx < surveyFileData.size() ) { |
| 172 |
dataLine = surveyFileData.get(lineIdx); |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
if ( ( dataLine == null ) || ( dataLine.length() > 0 ) ) { |
| 178 |
|
| 179 |
switch (state) { |
| 180 |
case 0: |
| 181 |
|
| 182 |
|
| 183 |
int pos = dataLine.indexOf(" ("); |
| 184 |
if ( pos > 0 ) { |
| 185 |
String part1 = dataLine.substring(0, pos); |
| 186 |
String part2 = dataLine.substring(pos + 3); |
| 187 |
if ( part2.compareTo("(m, 360)") != 0 ) { |
| 188 |
|
| 189 |
ParseException ex = new ParseException("Invalid file header. Unsupported units: " + part2, lineNo); |
| 190 |
throw ex; |
| 191 |
} |
| 192 |
else { |
| 193 |
|
| 194 |
caveName = part1.replace(' ', '_'); |
| 195 |
outerSeries = new SurveySeries( caveName ); |
| 196 |
surveyData.add( outerSeries ); |
| 197 |
logger.logMessage("Cave name: " + caveName); |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
state = 1; |
| 202 |
break; |
| 203 |
case 1: |
| 204 |
if ( dataLine.substring(0, 1).compareTo("[") == 0 ){ |
| 205 |
|
| 206 |
List<String> tripData = UtilityFunctions.parseDataStringIntoDataItems(dataLine); |
| 207 |
|
| 208 |
String[] trip = new String[tripData.size()]; |
| 209 |
if ( tripData.size() >= 3 ) { |
| 210 |
if ( tripData.size() <= 4 ) { |
| 211 |
|
| 212 |
for (int i = 0; i < tripData.size(); i++) { |
| 213 |
trip[i] = tripData.get(i); |
| 214 |
} |
| 215 |
} |
| 216 |
else { |
| 217 |
|
| 218 |
ParseException ex = new ParseException("Invalid file header. Trip data contain more than 4 items in line: " + dataLine, lineNo ); |
| 219 |
throw ex; |
| 220 |
} |
| 221 |
} |
| 222 |
else { |
| 223 |
|
| 224 |
ParseException ex = new ParseException("Invalid file header. Trip data does not contain at least 3 items in line: " + dataLine, lineNo ); |
| 225 |
throw ex; |
| 226 |
} |
| 227 |
|
| 228 |
if ( trip[0].charAt( trip[0].length() - 1 ) == ':' ) { |
| 229 |
trip[0] = trip[0].substring( 0, trip[0].length() - 1 ); |
| 230 |
} |
| 231 |
else { |
| 232 |
|
| 233 |
ParseException ex = new ParseException("Invalid file header. Unexpected trip code: " + trip[0] + " in line: " + dataLine, lineNo ); |
| 234 |
throw ex; |
| 235 |
} |
| 236 |
trips.add(trip); |
| 237 |
logger.logMessage("Trip settings: " + trip[0] + " " + trip[1] + " " + trip[2]); |
| 238 |
break; |
| 239 |
} |
| 240 |
else { |
| 241 |
|
| 242 |
state = 2; |
| 243 |
} |
| 244 |
case 2: |
| 245 |
|
| 246 |
SurveyLeg shot = new SurveyLeg(); |
| 247 |
int seriesNo = -1; |
| 248 |
String trip = ""; |
| 249 |
TopoDataLine data = null; |
| 250 |
|
| 251 |
if ( dataLine != null ) { |
| 252 |
|
| 253 |
|
| 254 |
data = parseDataLine( UtilityFunctions.parseDataStringIntoDataItems( dataLine ) ); |
| 255 |
|
| 256 |
if ( data.getLineType() > 0 ) { |
| 257 |
|
| 258 |
int[] seriesStn = splitSeriesFromStn( data.getFromStn() ); |
| 259 |
seriesNo = seriesStn[0]; |
| 260 |
shot.setFromStn( new SurveyStation( seriesStn[1] ) ); |
| 261 |
shot.setLength( data.getTape(), LengthUnit.Metres ); |
| 262 |
shot.setCompass( data.getCompass(), BearingUnit.Degrees ); |
| 263 |
shot.setClino( data.getClino(), GradientUnit.Degrees ); |
| 264 |
shot.setComment( data.getComment() ); |
| 265 |
trip = data.getTrip(); |
| 266 |
if ( ( data.getLineType() == LINE_TYPE_LEG ) || ( data.getLineType() == LINE_TYPE_EQUATE ) ) { |
| 267 |
|
| 268 |
int[] seriesStn2 = splitSeriesFromStn( data.getToStn() ); |
| 269 |
shot.setToStn( new SurveyStation( seriesStn2[1] ) ); |
| 270 |
|
| 271 |
|
| 272 |
if ( seriesNo != seriesStn2[0] ) { |
| 273 |
if ( data.getLineType() != LINE_TYPE_EQUATE ) { |
| 274 |
|
| 275 |
ParseException ex = new ParseException("Legs linking different series must be zero length.", lineNo ); |
| 276 |
throw ex; |
| 277 |
} |
| 278 |
else { |
| 279 |
|
| 280 |
Equate equate = new Equate( outerSeries.getSeriesName() + "." + seriesNo, shot.getFromStn().getName(), |
| 281 |
outerSeries.getSeriesName() + "." + seriesStn2[0], shot.getToStn().getName() ); |
| 282 |
|
| 283 |
equates.add(equate); |
| 284 |
} |
| 285 |
} |
| 286 |
else if ( data.getLineType() == LINE_TYPE_EQUATE ) { |
| 287 |
|
| 288 |
Equate equate = new Equate( outerSeries.getSeriesName() + "." + seriesNo, shot.getFromStn().getName(), |
| 289 |
outerSeries.getSeriesName() + "." + seriesStn2[0], shot.getToStn().getName() ); |
| 290 |
|
| 291 |
equates.add(equate); |
| 292 |
} |
| 293 |
|
| 294 |
} |
| 295 |
else { |
| 296 |
|
| 297 |
|
| 298 |
shot.setToStn( new SurveyStation( -1 ) ); |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
else { |
| 303 |
|
| 304 |
|
| 305 |
data = parseDataLine( UtilityFunctions.parseDataStringIntoDataItems( "DUMMY DUMMY 42.0 0.0 0.0 [1]" ) ); |
| 306 |
shot.setLength( data.getTape(), LengthUnit.Metres ); |
| 307 |
} |
| 308 |
|
| 309 |
if ( shot.getLength(LengthUnit.Metres) > 0 ) { |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
if ( lastShotStart.length() == 0 ) { |
| 317 |
|
| 318 |
lastShotStart = data.getFromStn(); |
| 319 |
} |
| 320 |
else if ( data.getFromStn().compareTo( lastShotStart ) != 0 ) { |
| 321 |
|
| 322 |
newLeg = true; |
| 323 |
} |
| 324 |
else if ( ( shot.getToStn().getId() != -1 ) |
| 325 |
&& ( ( lastToStn != -1 ) ) |
| 326 |
&& ( shot.getToStn().getId() != lastToStn ) ) { |
| 327 |
|
| 328 |
newLeg = true; |
| 329 |
} |
| 330 |
else if ( ( lastToStn != -1 ) && ( shot.getToStn().getId() == -1 ) ) { |
| 331 |
|
| 332 |
newLeg = true; |
| 333 |
} |
| 334 |
|
| 335 |
if ( newLeg ) { |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
SurveyLeg masterLeg = new SurveyLeg(); |
| 341 |
|
| 342 |
if ( legShots.size() > 0 ) { |
| 343 |
|
| 344 |
masterLeg.setFromStn( legShots.get(0).getFromStn() ); |
| 345 |
masterLeg.setToStn( legShots.get(0).getToStn() ); |
| 346 |
|
| 347 |
|
| 348 |
double tape = 0.0; |
| 349 |
double clino = 0.0; |
| 350 |
String comments = ""; |
| 351 |
|
| 352 |
double[] bearings = new double[legShots.size()]; |
| 353 |
for ( int i = 0; i < legShots.size(); i++ ) { |
| 354 |
tape += legShots.get(i).getLength(LengthUnit.Metres); |
| 355 |
bearings[i] = legShots.get(i).getCompass(BearingUnit.Degrees); |
| 356 |
clino += legShots.get(i).getClino(GradientUnit.Degrees); |
| 357 |
|
| 358 |
if ( legShots.get(i).getComment().length() > 0 ) { |
| 359 |
if ( comments.length() > 0 ) { |
| 360 |
comments += "; " + legShots.get(i).getComment(); |
| 361 |
} |
| 362 |
else { |
| 363 |
comments = legShots.get(i).getComment(); |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
} |
| 368 |
|
| 369 |
double aveCompass = UtilityFunctions.averageCompassBearings(bearings); |
| 370 |
|
| 371 |
masterLeg.setLength( tape / legShots.size(), LengthUnit.Metres ); |
| 372 |
masterLeg.setCompass( aveCompass, BearingUnit.Degrees ); |
| 373 |
masterLeg.setClino( clino / legShots.size(), GradientUnit.Degrees ); |
| 374 |
masterLeg.setComment( comments ); |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
if ( activeSeries != lastSeriesNo ) { |
| 379 |
|
| 380 |
boolean gotSeries = false; |
| 381 |
for ( int j = 0; j < outerSeries.innerSeriesCount(); j++ ) { |
| 382 |
|
| 383 |
if ( outerSeries.getInnerSeries(j).getSeriesName().compareTo( "" + lastSeriesNo ) == 0 ) { |
| 384 |
|
| 385 |
series = outerSeries.getInnerSeries(j); |
| 386 |
gotSeries = true; |
| 387 |
|
| 388 |
j = outerSeries.innerSeriesCount(); |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
if ( gotSeries == false ) { |
| 393 |
|
| 394 |
series = new SurveySeries( "" + lastSeriesNo ); |
| 395 |
|
| 396 |
for ( int j = 0; j < trips.size(); j++ ) { |
| 397 |
if ( lastTripCode.compareTo( trips.get(j)[0] ) == 0 ) { |
| 398 |
|
| 399 |
series.setDeclination( Double.valueOf( trips.get(j)[2] ) ); |
| 400 |
|
| 401 |
String tripDateString = trips.get(j)[1]; |
| 402 |
Date tripDate = UtilityFunctions.stringToDate(tripDateString, "yyyy/MM/dd"); |
| 403 |
series.setSurveyDate( tripDate ); |
| 404 |
|
| 405 |
if ( trips.get(j).length == 4 ) { |
| 406 |
series.setComment(trips.get(j)[3]); |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
outerSeries.addSeries( series ); |
| 412 |
} |
| 413 |
|
| 414 |
activeSeries = lastSeriesNo; |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
int stnSplayCount = 0; |
| 419 |
String lastSplayFromStn = ""; |
| 420 |
for ( int i = 0; i < splayShots.size(); i++ ) { |
| 421 |
|
| 422 |
|
| 423 |
if ( ( i == 0 ) || ( lastSplayFromStn.equals( splayShots.get(i).getFromStn().getName() ) == false ) ) { |
| 424 |
|
| 425 |
stnSplayCount = 0; |
| 426 |
for ( int legIdx = 0; legIdx < series.legCount(); legIdx++ ) { |
| 427 |
SurveyLeg chkLeg = series.getLegRaw( legIdx ); |
| 428 |
if ( ( chkLeg.isSplay() ) |
| 429 |
&& ( chkLeg.getFromStn().getName().equals( splayShots.get(i).getFromStn().getName() ) ) ) { |
| 430 |
stnSplayCount++; |
| 431 |
} |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
stnSplayCount++; |
| 436 |
addSplayShot(series, splayShots.get(i), stnSplayCount); |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
if ( masterLeg.getLength(LengthUnit.Metres) >= 0 ) { |
| 441 |
series.addLeg( masterLeg ); |
| 442 |
} |
| 443 |
|
| 444 |
|
| 445 |
legShots = new ArrayList<SurveyLeg>(); |
| 446 |
splayShots = new ArrayList<SurveyLeg>(); |
| 447 |
|
| 448 |
|
| 449 |
lastShotStart = data.getFromStn(); |
| 450 |
|
| 451 |
|
| 452 |
newLeg = false; |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
if ( dataLine != null ) { |
| 457 |
|
| 458 |
if ( shot.getToStn().getId() == -1 ) { |
| 459 |
|
| 460 |
splayShots.add(shot); |
| 461 |
} |
| 462 |
else { |
| 463 |
|
| 464 |
legShots.add(shot); |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
lastSeriesNo = seriesNo; |
| 469 |
lastTripCode = trip; |
| 470 |
|
| 471 |
|
| 472 |
lastToStn = shot.getToStn().getId(); |
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
break; |
| 477 |
default: |
| 478 |
} |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
UtilityFunctions.processEquates(equates, surveyData); |
| 484 |
|
| 485 |
|
| 486 |
UtilityFunctions.logSurveyDebugData(surveyData, logger); |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
return surveyData; |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
private int[] splitSeriesFromStn( String dataIn ) { |
| 501 |
|
| 502 |
int[] result = new int[2]; |
| 503 |
|
| 504 |
int pos = dataIn.indexOf('.'); |
| 505 |
if ( pos > 0 ) { |
| 506 |
result[0] = Integer.valueOf( dataIn.substring( 0, pos ) ); |
| 507 |
result[1] = Integer.valueOf( dataIn.substring( pos + 1 ) ); |
| 508 |
} |
| 509 |
else { |
| 510 |
|
| 511 |
RuntimeException ex = new RuntimeException("Invalid dot separated series and station name : " + dataIn); |
| 512 |
throw ex; |
| 513 |
} |
| 514 |
|
| 515 |
return result; |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
private TopoDataLine parseDataLine( List<String> dataItems ) { |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
TopoDataLine result = new TopoDataLine(); |
| 542 |
|
| 543 |
|
| 544 |
if ( dataItems.size() > 4 ) { |
| 545 |
|
| 546 |
int tripIdx = -1; |
| 547 |
int commentIdx = -1; |
| 548 |
|
| 549 |
String lastItem = dataItems.get( dataItems.size() - 1 ); |
| 550 |
String lastButOneItem = dataItems.get( dataItems.size() - 2 ); |
| 551 |
|
| 552 |
|
| 553 |
if ( itemIsTrip( lastItem ) ) { |
| 554 |
|
| 555 |
tripIdx = dataItems.size() - 1; |
| 556 |
} |
| 557 |
else if ( itemIsTrip( lastButOneItem ) ) { |
| 558 |
|
| 559 |
tripIdx = dataItems.size() - 2; |
| 560 |
|
| 561 |
commentIdx = dataItems.size() - 1; |
| 562 |
} |
| 563 |
else { |
| 564 |
|
| 565 |
if ( dataItems.size() > 5 ) { |
| 566 |
|
| 567 |
commentIdx = dataItems.size() - 1; |
| 568 |
} |
| 569 |
else if ( dataItems.size() == 5 ) { |
| 570 |
|
| 571 |
if ( itemIsZeroValue( lastItem ) == false ) { |
| 572 |
|
| 573 |
commentIdx = dataItems.size() - 1; |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
|
| 579 |
result.setFromStn( dataItems.get(0) ); |
| 580 |
|
| 581 |
if ( ( tripIdx == 4 ) || ( commentIdx == 4 ) ) { |
| 582 |
|
| 583 |
result.setTape( Double.valueOf( dataItems.get(1) ) ); |
| 584 |
result.setCompass( Double.valueOf( dataItems.get(2) ) ); |
| 585 |
result.setClino( Double.valueOf( dataItems.get(3) ) ); |
| 586 |
|
| 587 |
if ( ( result.getTape() == 0.0 ) |
| 588 |
&& ( result.getCompass() == 0.0 ) |
| 589 |
&& ( result.getClino() == 0.0 ) ) { |
| 590 |
if ( commentIdx > 0 ) { |
| 591 |
result.setLineType( LINE_TYPE_COMMENT ); |
| 592 |
} |
| 593 |
else { |
| 594 |
|
| 595 |
result.setLineType( 0 ); |
| 596 |
} |
| 597 |
} |
| 598 |
else { |
| 599 |
result.setLineType( LINE_TYPE_SPLAY ); |
| 600 |
} |
| 601 |
} |
| 602 |
else if ( ( tripIdx == 5 ) || ( commentIdx == 5 ) || ( ( tripIdx == -1 ) && ( commentIdx == -1 ) ) ) { |
| 603 |
|
| 604 |
result.setToStn( dataItems.get(1) ); |
| 605 |
result.setTape( Double.valueOf( dataItems.get(2) ) ); |
| 606 |
result.setCompass( Double.valueOf( dataItems.get(3) ) ); |
| 607 |
result.setClino( Double.valueOf( dataItems.get(4) ) ); |
| 608 |
|
| 609 |
if ( ( result.getTape() == 0.0 ) |
| 610 |
&& ( result.getCompass() == 0.0 ) |
| 611 |
&& ( result.getClino() == 0.0 ) ) { |
| 612 |
result.setLineType( LINE_TYPE_EQUATE ); |
| 613 |
} |
| 614 |
else { |
| 615 |
result.setLineType( LINE_TYPE_LEG ); |
| 616 |
} |
| 617 |
} |
| 618 |
|
| 619 |
|
| 620 |
if ( tripIdx > 0 ) { |
| 621 |
result.setTrip( dataItems.get( tripIdx ) ); |
| 622 |
} |
| 623 |
if ( commentIdx > 0 ) { |
| 624 |
result.setComment( dataItems.get( commentIdx ) ); |
| 625 |
} |
| 626 |
|
| 627 |
} |
| 628 |
|
| 629 |
return result; |
| 630 |
} |
| 631 |
|
| 632 |
private boolean itemIsTrip( String dataItem ) { |
| 633 |
boolean isTrip = false; |
| 634 |
if ( ( dataItem.length() > 2 ) && ( dataItem.length() < 4 ) |
| 635 |
&& ( dataItem.charAt( 0 ) == '[' ) && ( dataItem.charAt( dataItem.length() - 1 ) == ']' ) ) { |
| 636 |
|
| 637 |
isTrip = true; |
| 638 |
} |
| 639 |
return isTrip; |
| 640 |
} |
| 641 |
|
| 642 |
private boolean itemIsZeroValue( String dataItem ) { |
| 643 |
boolean isZero = false; |
| 644 |
|
| 645 |
|
| 646 |
if ( dataItem.length() > 2 ) { |
| 647 |
if ( ( dataItem.charAt(0) == '0' ) && ( dataItem.charAt(1) == '.' ) && ( dataItem.charAt(2) == '0' ) ) { |
| 648 |
|
| 649 |
isZero = true; |
| 650 |
|
| 651 |
for (int i = 3; i < dataItem.length(); i++) { |
| 652 |
if ( dataItem.charAt(i) != '0' ) { |
| 653 |
|
| 654 |
isZero = false; |
| 655 |
i = dataItem.length(); |
| 656 |
} |
| 657 |
} |
| 658 |
} |
| 659 |
} |
| 660 |
else { |
| 661 |
|
| 662 |
|
| 663 |
isZero = true; |
| 664 |
|
| 665 |
for (int i = 0; i < dataItem.length(); i++) { |
| 666 |
if ( dataItem.charAt(i) != '0' ) { |
| 667 |
|
| 668 |
isZero = false; |
| 669 |
i = dataItem.length(); |
| 670 |
} |
| 671 |
} |
| 672 |
} |
| 673 |
|
| 674 |
return isZero; |
| 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 |
private void addSplayShot( SurveySeries series, SurveyLeg shot, int splayCount ){ |
| 705 |
|
| 706 |
int increment = splayCount - 1; |
| 707 |
int stnLetterCode = 97; |
| 708 |
String stnSuffix = ""; |
| 709 |
if ( splayCount < 27 ) { |
| 710 |
stnSuffix = new Character( (char)(stnLetterCode + increment) ).toString(); |
| 711 |
} |
| 712 |
else { |
| 713 |
int primaryCount = (increment - 26) / 26; |
| 714 |
int secondaryCount = (increment % 26); |
| 715 |
stnSuffix = new Character( (char)(stnLetterCode + primaryCount) ).toString(); |
| 716 |
stnSuffix += new Character( (char)(stnLetterCode + secondaryCount) ).toString(); |
| 717 |
} |
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
SurveyLeg splayShot = shot.clone(); |
| 722 |
String toStn = shot.getFromStn().getName() + stnSuffix; |
| 723 |
splayShot.setToStn( UtilityFunctions.createStationFromNameForSeries( toStn, series ) ); |
| 724 |
splayShot.setLength( shot.getLength(LengthUnit.Metres), LengthUnit.Metres ); |
| 725 |
splayShot.setCompass( shot.getCompass(BearingUnit.Degrees), BearingUnit.Degrees ); |
| 726 |
splayShot.setClino( shot.getClino(GradientUnit.Degrees), GradientUnit.Degrees ); |
| 727 |
splayShot.setSplay( true ); |
| 728 |
series.addLeg( splayShot ); |
| 729 |
} |
| 730 |
|
| 731 |
} |