| 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.util.ArrayList; |
| 22 |
import java.util.Date; |
| 23 |
import java.util.List; |
| 24 |
|
| 25 |
import footleg.cavesurvey.converter.Logger; |
| 26 |
import footleg.cavesurvey.converter.CaveConverter.BearingUnit; |
| 27 |
import footleg.cavesurvey.converter.CaveConverter.GradientUnit; |
| 28 |
import footleg.cavesurvey.converter.CaveConverter.LengthUnit; |
| 29 |
import footleg.cavesurvey.data.model.CaveSurvey; |
| 30 |
import footleg.cavesurvey.data.model.SurveyLeg; |
| 31 |
import footleg.cavesurvey.data.model.SurveySeries; |
| 32 |
import footleg.cavesurvey.data.model.SurveyStation; |
| 33 |
import footleg.cavesurvey.data.model.SurveyStation.FixType; |
| 34 |
import footleg.cavesurvey.tools.UtilityFunctions; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public class DxfParser { |
| 44 |
private Date seriesDate; |
| 45 |
private Logger logger; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public DxfParser( Logger logger ) { |
| 52 |
super(); |
| 53 |
this.logger = logger; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public CaveSurvey parseFile( List<String> surveyFileData, int parseMode ) { |
| 69 |
int legCount = 0; |
| 70 |
int iPolylineCount = 0; |
| 71 |
int iVertexCount = 0; |
| 72 |
int iPlainlineCount = 0; |
| 73 |
|
| 74 |
|
| 75 |
CaveSurvey surveyData = new CaveSurvey(logger); |
| 76 |
SurveySeries outerSeries = null; |
| 77 |
|
| 78 |
|
| 79 |
List<List<double[]>> allChains = new ArrayList<List<double[]>>(); |
| 80 |
List<String[]> allChainLabels = new ArrayList<String[]>(); |
| 81 |
List<double[]> arSurveyChain = new ArrayList<double[]>(); |
| 82 |
List<double[]> arLines = new ArrayList<double[]>(); |
| 83 |
List<double[]> arLabelPoints = new ArrayList<double[]>(); |
| 84 |
List<String> arLabels = new ArrayList<String>(); |
| 85 |
boolean mappedLabelsFound = false; |
| 86 |
|
| 87 |
|
| 88 |
final int stateParsingHeader = 0; |
| 89 |
final int stateFindPolyline = 1; |
| 90 |
final int stateFindVertex = 2; |
| 91 |
|
| 92 |
final int parseModeSurveyLegs = 0; |
| 93 |
final int parseModeSurfaceContours = 1; |
| 94 |
final int parseModeSpotHeights = 2; |
| 95 |
|
| 96 |
|
| 97 |
int state = stateParsingHeader; |
| 98 |
|
| 99 |
|
| 100 |
int iPointCount = 0; |
| 101 |
String sLineName = ""; |
| 102 |
double dEastValue = 0; |
| 103 |
double dNorthValue = 0; |
| 104 |
double dElevValue = 0; |
| 105 |
double dLastEastValue = 0; |
| 106 |
double dLastNorthValue = 0; |
| 107 |
double dLastElevValue = 0; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
int iNorthEdge = 999999999; |
| 112 |
int iSouthEdge = -999999999; |
| 113 |
int iEastEdge = 999999999; |
| 114 |
int iWestEdge = -999999999; |
| 115 |
int iMinElev = -999999999; |
| 116 |
|
| 117 |
|
| 118 |
logger.logMessage("Generating survey data from lines and polylines in DXF data file"); |
| 119 |
outerSeries = new SurveySeries( "SurveyFromDXF" ); |
| 120 |
|
| 121 |
|
| 122 |
for ( int i=0; i < surveyFileData.size(); i++ ) { |
| 123 |
String dataLine = surveyFileData.get(i); |
| 124 |
|
| 125 |
|
| 126 |
switch( state ) { |
| 127 |
case stateParsingHeader : |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
if ( dataLine.trim().compareToIgnoreCase("ENTITIES") == 0 ) { |
| 132 |
|
| 133 |
state = stateFindPolyline; |
| 134 |
} |
| 135 |
break; |
| 136 |
case stateFindPolyline: |
| 137 |
if ( dataLine.trim().compareToIgnoreCase("POLYLINE") == 0 ) { |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
int iSkipLoop = 1; |
| 145 |
do { |
| 146 |
dataLine = surveyFileData.get(++i); |
| 147 |
} |
| 148 |
while ( ( dataLine.trim().compareToIgnoreCase("AcDbEntity") != 0 ) |
| 149 |
|| ( iSkipLoop > 15 ) ); |
| 150 |
|
| 151 |
if ( dataLine.trim().compareToIgnoreCase("AcDbEntity") == 0 ) { |
| 152 |
|
| 153 |
dataLine = surveyFileData.get(++i); |
| 154 |
|
| 155 |
dataLine = surveyFileData.get(++i); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
iPolylineCount += 1; |
| 160 |
|
| 161 |
sLineName = dataLine.replace(" ", "_"); |
| 162 |
if ( parseMode == parseModeSurfaceContours ) { |
| 163 |
sLineName = sLineName + iPolylineCount; |
| 164 |
} |
| 165 |
|
| 166 |
state = stateFindVertex; |
| 167 |
|
| 168 |
iPointCount = 0; |
| 169 |
|
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
else if ( dataLine.trim().compareToIgnoreCase("LINE") == 0 ) { |
| 176 |
|
| 177 |
iPlainlineCount++; |
| 178 |
|
| 179 |
int iSkipLoop = 0; |
| 180 |
do { |
| 181 |
dataLine = surveyFileData.get(++i); |
| 182 |
iSkipLoop++; |
| 183 |
} |
| 184 |
while ( (dataLine.trim().compareToIgnoreCase("AcDbEntity") != 0 && dataLine.trim().compareToIgnoreCase("CentreLine") != 0 ) |
| 185 |
&& ( iSkipLoop < 4 ) ); |
| 186 |
|
| 187 |
boolean allowAnyLineName = false; |
| 188 |
if ( iSkipLoop == 4 ) { |
| 189 |
allowAnyLineName = true; |
| 190 |
} |
| 191 |
|
| 192 |
if ( dataLine.trim().compareToIgnoreCase("AcDbEntity") == 0 |
| 193 |
|| dataLine.trim().compareToIgnoreCase("CentreLine") == 0 |
| 194 |
|| allowAnyLineName == true ) { |
| 195 |
if ( dataLine.trim().compareToIgnoreCase("CentreLine") != 0 && allowAnyLineName == false ) { |
| 196 |
|
| 197 |
iSkipLoop = 1; |
| 198 |
do { |
| 199 |
dataLine = surveyFileData.get(++i); |
| 200 |
} |
| 201 |
while ( ( dataLine.trim().compareToIgnoreCase("AcDbLine") != 0 ) |
| 202 |
|| ( iSkipLoop > 15 ) ); |
| 203 |
} |
| 204 |
|
| 205 |
if ( dataLine.trim().compareToIgnoreCase("AcDbLine") == 0 |
| 206 |
|| ( dataLine.trim().compareToIgnoreCase("CentreLine") == 0 ) |
| 207 |
|| allowAnyLineName ) { |
| 208 |
|
| 209 |
|
| 210 |
dataLine = surveyFileData.get(++i); |
| 211 |
if ( dataLine.trim().compareToIgnoreCase("10") == 0 ) { |
| 212 |
|
| 213 |
dataLine = surveyFileData.get(++i); |
| 214 |
dEastValue = roundedDataValue(dataLine); |
| 215 |
|
| 216 |
|
| 217 |
dataLine = surveyFileData.get(++i); |
| 218 |
if ( dataLine.trim().compareToIgnoreCase("20") == 0 ) { |
| 219 |
|
| 220 |
dataLine = surveyFileData.get(++i); |
| 221 |
dNorthValue = roundedDataValue(dataLine); |
| 222 |
|
| 223 |
|
| 224 |
dataLine = surveyFileData.get(++i); |
| 225 |
if ( dataLine.trim().compareToIgnoreCase("30") == 0 ) { |
| 226 |
|
| 227 |
dataLine = surveyFileData.get(++i); |
| 228 |
dElevValue = roundedDataValue(dataLine); |
| 229 |
|
| 230 |
|
| 231 |
dataLine = surveyFileData.get(++i); |
| 232 |
if ( dataLine.trim().compareToIgnoreCase("11") == 0 ) { |
| 233 |
|
| 234 |
dataLine = surveyFileData.get(++i); |
| 235 |
dLastEastValue = roundedDataValue(dataLine); |
| 236 |
|
| 237 |
|
| 238 |
dataLine = surveyFileData.get(++i); |
| 239 |
if ( dataLine.trim().compareToIgnoreCase("21") == 0 ) { |
| 240 |
|
| 241 |
dataLine = surveyFileData.get(++i); |
| 242 |
dLastNorthValue = roundedDataValue(dataLine); |
| 243 |
|
| 244 |
|
| 245 |
dataLine = surveyFileData.get(++i); |
| 246 |
if ( dataLine.trim().compareToIgnoreCase("31") == 0 ) { |
| 247 |
|
| 248 |
dataLine = surveyFileData.get(++i); |
| 249 |
dLastElevValue = roundedDataValue(dataLine); |
| 250 |
|
| 251 |
if ( ( dEastValue >= iWestEdge ) |
| 252 |
&& ( dEastValue <= iEastEdge ) |
| 253 |
&& ( dNorthValue <= iNorthEdge ) |
| 254 |
&& ( dNorthValue >= iSouthEdge ) |
| 255 |
&& ( dElevValue >= iMinElev ) |
| 256 |
&& ( dLastEastValue >= iWestEdge ) |
| 257 |
&& ( dLastEastValue <= iEastEdge ) |
| 258 |
&& ( dLastNorthValue <= iNorthEdge ) |
| 259 |
&& ( dLastNorthValue >= iSouthEdge ) |
| 260 |
&& ( dLastElevValue >= iMinElev )) { |
| 261 |
|
| 262 |
iPointCount += 1; |
| 263 |
|
| 264 |
if ( parseMode == parseModeSurveyLegs ) { |
| 265 |
|
| 266 |
double[] point = new double[6]; |
| 267 |
point[0] = dEastValue; |
| 268 |
point[1] = dNorthValue; |
| 269 |
point[2] = dElevValue; |
| 270 |
point[3] = dLastEastValue; |
| 271 |
point[4] = dLastNorthValue; |
| 272 |
point[5] = dLastElevValue; |
| 273 |
arLines.add(point); |
| 274 |
} |
| 275 |
} |
| 276 |
else { |
| 277 |
|
| 278 |
dEastValue = dNorthValue; |
| 279 |
} |
| 280 |
} |
| 281 |
} |
| 282 |
} |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
} |
| 287 |
} |
| 288 |
} |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
else if ( dataLine.trim().compareToIgnoreCase("TEXT") == 0 ) { |
| 293 |
|
| 294 |
iPlainlineCount++; |
| 295 |
|
| 296 |
dataLine = surveyFileData.get(++i); |
| 297 |
dataLine = surveyFileData.get(++i); |
| 298 |
if (dataLine.trim().compareToIgnoreCase("Labels") == 0 ) { |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
dataLine = surveyFileData.get(++i); |
| 304 |
if ( dataLine.trim().compareToIgnoreCase("10") == 0 ) { |
| 305 |
|
| 306 |
dataLine = surveyFileData.get(++i); |
| 307 |
dEastValue = roundedDataValue(dataLine); |
| 308 |
|
| 309 |
|
| 310 |
dataLine = surveyFileData.get(++i); |
| 311 |
if ( dataLine.trim().compareToIgnoreCase("20") == 0 ) { |
| 312 |
|
| 313 |
dataLine = surveyFileData.get(++i); |
| 314 |
dNorthValue = roundedDataValue(dataLine); |
| 315 |
|
| 316 |
|
| 317 |
dataLine = surveyFileData.get(++i); |
| 318 |
if ( dataLine.trim().compareToIgnoreCase("30") == 0 ) { |
| 319 |
|
| 320 |
dataLine = surveyFileData.get(++i); |
| 321 |
dElevValue = roundedDataValue(dataLine); |
| 322 |
|
| 323 |
for (int iskip = 0; iskip < 3; iskip++) { |
| 324 |
dataLine = surveyFileData.get(++i); |
| 325 |
} |
| 326 |
|
| 327 |
String possibleStnName = surveyFileData.get(++i); |
| 328 |
|
| 329 |
dataLine = surveyFileData.get(++i); |
| 330 |
|
| 331 |
|
| 332 |
dataLine = surveyFileData.get(++i); |
| 333 |
if ( dataLine.trim().compareToIgnoreCase("POINT") == 0 ) { |
| 334 |
|
| 335 |
dataLine = surveyFileData.get(++i); |
| 336 |
|
| 337 |
|
| 338 |
dataLine = surveyFileData.get(++i); |
| 339 |
if ( dataLine.trim().compareToIgnoreCase("Stations") == 0 ) { |
| 340 |
|
| 341 |
|
| 342 |
dataLine = surveyFileData.get(++i); |
| 343 |
if ( dataLine.trim().compareToIgnoreCase("10") == 0 ) { |
| 344 |
|
| 345 |
dataLine = surveyFileData.get(++i); |
| 346 |
dLastEastValue = roundedDataValue(dataLine); |
| 347 |
|
| 348 |
|
| 349 |
dataLine = surveyFileData.get(++i); |
| 350 |
if ( dataLine.trim().compareToIgnoreCase("20") == 0 ) { |
| 351 |
|
| 352 |
dataLine = surveyFileData.get(++i); |
| 353 |
dLastNorthValue = roundedDataValue(dataLine); |
| 354 |
|
| 355 |
|
| 356 |
dataLine = surveyFileData.get(++i); |
| 357 |
if ( dataLine.trim().compareToIgnoreCase("30") == 0 ) { |
| 358 |
|
| 359 |
dataLine = surveyFileData.get(++i); |
| 360 |
dLastElevValue = roundedDataValue(dataLine); |
| 361 |
|
| 362 |
if ( ( dEastValue >= iWestEdge ) |
| 363 |
&& ( dEastValue <= iEastEdge ) |
| 364 |
&& ( dNorthValue <= iNorthEdge ) |
| 365 |
&& ( dNorthValue >= iSouthEdge ) |
| 366 |
&& ( dElevValue >= iMinElev ) |
| 367 |
&& ( dLastEastValue >= iWestEdge ) |
| 368 |
&& ( dLastEastValue <= iEastEdge ) |
| 369 |
&& ( dLastNorthValue <= iNorthEdge ) |
| 370 |
&& ( dLastNorthValue >= iSouthEdge ) |
| 371 |
&& ( dLastElevValue >= iMinElev )) { |
| 372 |
|
| 373 |
if ( ( dEastValue == dLastEastValue ) |
| 374 |
&& ( dNorthValue == dLastNorthValue ) |
| 375 |
&& ( dElevValue == dLastElevValue )) { |
| 376 |
|
| 377 |
|
| 378 |
if ( parseMode == parseModeSurveyLegs ) { |
| 379 |
|
| 380 |
double[] point = new double[3]; |
| 381 |
point[0] = dEastValue; |
| 382 |
point[1] = dNorthValue; |
| 383 |
point[2] = dElevValue; |
| 384 |
arLabels.add( possibleStnName ); |
| 385 |
arLabelPoints.add( point ); |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
else { |
| 390 |
|
| 391 |
dEastValue = dNorthValue; |
| 392 |
} |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
} |
| 397 |
} |
| 398 |
} |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
} |
| 403 |
break; |
| 404 |
case stateFindVertex: |
| 405 |
|
| 406 |
|
| 407 |
if ( dataLine.trim().compareToIgnoreCase("VERTEX") == 0 ) { |
| 408 |
|
| 409 |
boolean bValidRecord = false; |
| 410 |
|
| 411 |
iVertexCount += 1; |
| 412 |
|
| 413 |
int iSkipLoop = 1; |
| 414 |
do { |
| 415 |
dataLine = surveyFileData.get(++i); |
| 416 |
} |
| 417 |
while ( ( dataLine.trim().compareToIgnoreCase("AcDbEntity") != 0 ) |
| 418 |
|| ( iSkipLoop > 15 ) ); |
| 419 |
if ( dataLine.trim().compareToIgnoreCase("AcDbEntity") == 0 ) { |
| 420 |
|
| 421 |
iSkipLoop = 1; |
| 422 |
do { |
| 423 |
dataLine = surveyFileData.get(++i); |
| 424 |
} |
| 425 |
while ( ( dataLine.trim().compareToIgnoreCase("AcDbVertex") != 0 ) |
| 426 |
|| ( iSkipLoop > 15 ) ); |
| 427 |
if ( dataLine.trim().compareToIgnoreCase("AcDbVertex") == 0 ) { |
| 428 |
|
| 429 |
iSkipLoop = 1; |
| 430 |
do { |
| 431 |
dataLine = surveyFileData.get(++i); |
| 432 |
} |
| 433 |
while ( ( dataLine.trim().compareToIgnoreCase("AcDb3dPolylineVertex") != 0 ) |
| 434 |
|| ( iSkipLoop > 15 ) ); |
| 435 |
if ( dataLine.trim().compareToIgnoreCase("AcDb3dPolylineVertex") == 0 ) { |
| 436 |
|
| 437 |
|
| 438 |
dataLine = surveyFileData.get(++i); |
| 439 |
if ( dataLine.trim().compareToIgnoreCase("10") == 0 ) { |
| 440 |
|
| 441 |
dataLine = surveyFileData.get(++i); |
| 442 |
dEastValue = roundedDataValue(dataLine); |
| 443 |
|
| 444 |
|
| 445 |
dataLine = surveyFileData.get(++i); |
| 446 |
if ( dataLine.trim().compareToIgnoreCase("20") == 0 ) { |
| 447 |
|
| 448 |
dataLine = surveyFileData.get(++i); |
| 449 |
dNorthValue = roundedDataValue(dataLine); |
| 450 |
|
| 451 |
|
| 452 |
dataLine = surveyFileData.get(++i); |
| 453 |
if ( dataLine.trim().compareToIgnoreCase("30") == 0 ) { |
| 454 |
|
| 455 |
dataLine = surveyFileData.get(++i); |
| 456 |
dElevValue = roundedDataValue(dataLine); |
| 457 |
|
| 458 |
if ( ( dEastValue >= iWestEdge ) |
| 459 |
&& ( dEastValue <= iEastEdge ) |
| 460 |
&& ( dNorthValue <= iNorthEdge ) |
| 461 |
&& ( dNorthValue >= iSouthEdge ) |
| 462 |
&& ( dElevValue >= iMinElev ) ) { |
| 463 |
|
| 464 |
iPointCount += 1; |
| 465 |
|
| 466 |
if ( parseMode == parseModeSurveyLegs ) { |
| 467 |
|
| 468 |
double[] point = new double[3]; |
| 469 |
point[0] = dEastValue; |
| 470 |
point[1] = dNorthValue; |
| 471 |
point[2] = dElevValue; |
| 472 |
arSurveyChain.add(point); |
| 473 |
} |
| 474 |
else { |
| 475 |
|
| 476 |
String sStnName = "S" + iPolylineCount + "P" + iPointCount; |
| 477 |
|
| 478 |
String sPointPosition = ""; |
| 479 |
if ( iPointCount == 1 ) { |
| 480 |
|
| 481 |
sPointPosition = "*fix " + sStnName + " " + |
| 482 |
dEastValue + " " + |
| 483 |
dNorthValue + " " + |
| 484 |
dElevValue; |
| 485 |
if ( parseMode == parseModeSurfaceContours ) { |
| 486 |
|
| 487 |
logger.logMessage("*begin " + sLineName); |
| 488 |
} |
| 489 |
else { |
| 490 |
|
| 491 |
sPointPosition = " " + (dEastValue - dLastEastValue) + " " + |
| 492 |
(dNorthValue - dLastNorthValue) + " " + |
| 493 |
(dElevValue - dLastElevValue); |
| 494 |
} |
| 495 |
} |
| 496 |
if ( parseMode == parseModeSpotHeights ) { |
| 497 |
logger.logMessage( String.valueOf(Math.round(dEastValue) - iEastEdge) ); |
| 498 |
logger.logMessage( String.valueOf( (iNorthEdge - iSouthEdge) - ( Math.round(dNorthValue) - iSouthEdge) ) ); |
| 499 |
logger.logMessage( String.valueOf(dElevValue) ); |
| 500 |
} |
| 501 |
else { |
| 502 |
|
| 503 |
logger.logMessage(sPointPosition); |
| 504 |
logger.logMessage(sStnName); |
| 505 |
} |
| 506 |
} |
| 507 |
|
| 508 |
dLastEastValue = dEastValue; |
| 509 |
dLastNorthValue = dNorthValue; |
| 510 |
dLastElevValue = dElevValue; |
| 511 |
} |
| 512 |
else { |
| 513 |
|
| 514 |
dEastValue = dNorthValue; |
| 515 |
} |
| 516 |
bValidRecord = true; |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
} |
| 521 |
} |
| 522 |
} |
| 523 |
|
| 524 |
if ( bValidRecord == false ) { |
| 525 |
|
| 526 |
logger.logMessage("Bad Line"); |
| 527 |
|
| 528 |
state = stateFindPolyline; |
| 529 |
} |
| 530 |
} |
| 531 |
|
| 532 |
else if ( dataLine.trim().compareToIgnoreCase("SEQEND") == 0 ) { |
| 533 |
|
| 534 |
|
| 535 |
if ( parseMode == parseModeSurveyLegs ) { |
| 536 |
|
| 537 |
String sUniqueName = sLineName; |
| 538 |
int k = 1; |
| 539 |
boolean bUnique = false; |
| 540 |
while ( bUnique == false ) { |
| 541 |
|
| 542 |
bUnique = true; |
| 543 |
for ( int j = 0; j < outerSeries.innerSeriesCount(); j++ ) { |
| 544 |
|
| 545 |
if ( outerSeries.getInnerSeries(j).getSeriesName().compareTo( sUniqueName ) == 0 ) { |
| 546 |
|
| 547 |
sUniqueName = sLineName + k; |
| 548 |
k++; |
| 549 |
bUnique = false; |
| 550 |
|
| 551 |
j = outerSeries.innerSeriesCount(); |
| 552 |
} |
| 553 |
} |
| 554 |
} |
| 555 |
|
| 556 |
|
| 557 |
if ( arLabelPoints.size() == 0 ) { |
| 558 |
arLabels.add( 0, sUniqueName ); |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
String[] stnLabels = mapLabelsToChainPoints(arSurveyChain, arLabelPoints, arLabels); |
| 563 |
|
| 564 |
|
| 565 |
outerSeries.addSeries( makeSeriesFromPolyline( arSurveyChain, sUniqueName, stnLabels ) ); |
| 566 |
legCount += (arSurveyChain.size() - 1); |
| 567 |
|
| 568 |
|
| 569 |
allChains.add(arSurveyChain); |
| 570 |
allChainLabels.add(stnLabels); |
| 571 |
|
| 572 |
if ( stnLabels[0] != null ) { |
| 573 |
mappedLabelsFound = true; |
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
arSurveyChain = new ArrayList<double[]>(); |
| 578 |
|
| 579 |
} |
| 580 |
else if ( parseMode == parseModeSurfaceContours ) { |
| 581 |
|
| 582 |
if ( iPointCount > 0 ) { |
| 583 |
logger.logMessage("*end " + sLineName); |
| 584 |
} |
| 585 |
} |
| 586 |
|
| 587 |
state = stateFindPolyline; |
| 588 |
} |
| 589 |
break; |
| 590 |
default: |
| 591 |
} |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
int newlines = 0; |
| 596 |
while ( arLines.size() > 0 ) { |
| 597 |
|
| 598 |
double[] line = arLines.remove(0); |
| 599 |
|
| 600 |
arSurveyChain = new ArrayList<double[]>(); |
| 601 |
|
| 602 |
double[] firstPoint = new double[3]; |
| 603 |
firstPoint[0] = line[0]; |
| 604 |
firstPoint[1] = line[1]; |
| 605 |
firstPoint[2] = line[2]; |
| 606 |
arSurveyChain.add(firstPoint); |
| 607 |
double[] lastPoint = new double[3]; |
| 608 |
lastPoint[0] = line[3]; |
| 609 |
lastPoint[1] = line[4]; |
| 610 |
lastPoint[2] = line[5]; |
| 611 |
arSurveyChain.add(lastPoint); |
| 612 |
|
| 613 |
|
| 614 |
boolean added = true; |
| 615 |
while ( added == true ) { |
| 616 |
added = false; |
| 617 |
for ( int linesIdx = 0; linesIdx < arLines.size(); linesIdx++ ) { |
| 618 |
boolean match = false; |
| 619 |
line = arLines.get(linesIdx); |
| 620 |
if ( firstPoint[0] == line[0] |
| 621 |
&& firstPoint[1] == line[1] |
| 622 |
&& firstPoint[2] == line[2] ) { |
| 623 |
|
| 624 |
firstPoint = new double[3]; |
| 625 |
firstPoint[0] = line[3]; |
| 626 |
firstPoint[1] = line[4]; |
| 627 |
firstPoint[2] = line[5]; |
| 628 |
arSurveyChain.add(0, firstPoint); |
| 629 |
match = true; |
| 630 |
} |
| 631 |
else if ( firstPoint[0] == line[3] |
| 632 |
&& firstPoint[1] == line[4] |
| 633 |
&& firstPoint[2] == line[5] ) { |
| 634 |
|
| 635 |
firstPoint = new double[3]; |
| 636 |
firstPoint[0] = line[0]; |
| 637 |
firstPoint[1] = line[1]; |
| 638 |
firstPoint[2] = line[2]; |
| 639 |
arSurveyChain.add(0, firstPoint); |
| 640 |
match = true; |
| 641 |
} |
| 642 |
else if ( lastPoint[0] == line[0] |
| 643 |
&& lastPoint[1] == line[1] |
| 644 |
&& lastPoint[2] == line[2] ) { |
| 645 |
|
| 646 |
lastPoint = new double[3]; |
| 647 |
lastPoint[0] = line[3]; |
| 648 |
lastPoint[1] = line[4]; |
| 649 |
lastPoint[2] = line[5]; |
| 650 |
arSurveyChain.add(lastPoint); |
| 651 |
match = true; |
| 652 |
} |
| 653 |
else if ( lastPoint[0] == line[3] |
| 654 |
&& lastPoint[1] == line[4] |
| 655 |
&& lastPoint[2] == line[5] ) { |
| 656 |
|
| 657 |
lastPoint = new double[3]; |
| 658 |
lastPoint[0] = line[0]; |
| 659 |
lastPoint[1] = line[1]; |
| 660 |
lastPoint[2] = line[2]; |
| 661 |
arSurveyChain.add(lastPoint); |
| 662 |
match = true; |
| 663 |
} |
| 664 |
if ( match == true ) { |
| 665 |
|
| 666 |
arLines.remove(linesIdx); |
| 667 |
linesIdx--; |
| 668 |
added = true; |
| 669 |
} |
| 670 |
} |
| 671 |
} |
| 672 |
|
| 673 |
|
| 674 |
String[] stnLabels = mapLabelsToChainPoints(arSurveyChain, arLabelPoints, arLabels); |
| 675 |
if ( arLabels.size() > 0 ) { |
| 676 |
mappedLabelsFound = true; |
| 677 |
} |
| 678 |
|
| 679 |
|
| 680 |
newlines++; |
| 681 |
String sSeriesName = "SeriesFromLines" + newlines; |
| 682 |
SurveySeries newSeries = makeSeriesFromPolyline( arSurveyChain, sSeriesName, stnLabels ); |
| 683 |
|
| 684 |
if ( newSeries.legCount() > 0 ) { |
| 685 |
allChains.add(arSurveyChain); |
| 686 |
allChainLabels.add(stnLabels); |
| 687 |
outerSeries.addSeries( newSeries ); |
| 688 |
legCount += (arSurveyChain.size() - 1); |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
if ( mappedLabelsFound ) { |
| 693 |
|
| 694 |
SurveySeries rebuiltOuterSeries = new SurveySeries("SurveyFromDXFExportedFrom3D"); |
| 695 |
for ( int seriesIdx = 0; seriesIdx < outerSeries.innerSeriesCount(); seriesIdx++ ) { |
| 696 |
|
| 697 |
List<double[]> srcChain = allChains.get(seriesIdx); |
| 698 |
|
| 699 |
SurveySeries inputSeries = outerSeries.getInnerSeries( seriesIdx ); |
| 700 |
for ( int legIdx = 0; legIdx < inputSeries.legCount(); legIdx++ ) { |
| 701 |
SurveyLeg inputLeg = inputSeries.getLegRaw( legIdx ); |
| 702 |
|
| 703 |
|
| 704 |
String fromStnName = inputLeg.getFromStn().getName(); |
| 705 |
|
| 706 |
int matchingFromSeries = findMatchingSeriesForStnName( rebuiltOuterSeries, fromStnName ); |
| 707 |
if ( matchingFromSeries > -1 ) { |
| 708 |
String toStnName = inputLeg.getToStn().getName(); |
| 709 |
int matchingToSeries = findMatchingSeriesForStnName( rebuiltOuterSeries, toStnName ); |
| 710 |
int legNewSeries = matchingFromSeries; |
| 711 |
if ( matchingToSeries != matchingFromSeries ) { |
| 712 |
|
| 713 |
boolean stnNameSwapped = false; |
| 714 |
|
| 715 |
List<Integer> matchingToPoints = getListOfMatchingPoints( srcChain.get( legIdx + 1 ), arLabelPoints ); |
| 716 |
if ( matchingToPoints.size() > 1 ) { |
| 717 |
|
| 718 |
String fromStnPrefix = getNamePrefix( fromStnName ); |
| 719 |
if ( fromStnPrefix.length() > 0 ) { |
| 720 |
String toStnPrefix = getNamePrefix( toStnName ); |
| 721 |
if ( toStnPrefix.length() > 0 ) { |
| 722 |
for ( int matchingPointsIdx = 0; matchingPointsIdx < matchingToPoints.size(); matchingPointsIdx++ ) { |
| 723 |
String testLabel = arLabels.get( matchingToPoints.get(matchingPointsIdx) ); |
| 724 |
String testLabelPrefix = getNamePrefix( testLabel ); |
| 725 |
if ( testLabelPrefix.equals(fromStnPrefix) ) { |
| 726 |
|
| 727 |
inputLeg.getToStn().setName( testLabel ); |
| 728 |
|
| 729 |
SurveyStation linkStn1 = new SurveyStation(0); |
| 730 |
linkStn1.setName( getShortenedName( testLabel ) ); |
| 731 |
SurveyStation linkStn2 = new SurveyStation(0); |
| 732 |
linkStn2.setName( getShortenedName( toStnName ) ); |
| 733 |
|
| 734 |
rebuiltOuterSeries.addLink(rebuiltOuterSeries.getInnerSeries(matchingFromSeries).getSeriesName(),linkStn1, |
| 735 |
rebuiltOuterSeries.getInnerSeries(matchingToSeries).getSeriesName(), linkStn2); |
| 736 |
stnNameSwapped = true; |
| 737 |
break; |
| 738 |
} |
| 739 |
} |
| 740 |
} |
| 741 |
} |
| 742 |
} |
| 743 |
if ( stnNameSwapped == false ) { |
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
List<Integer> matchingFromPoints = getListOfMatchingPoints( srcChain.get( legIdx ), arLabelPoints ); |
| 749 |
if ( matchingFromPoints.size() > 1 ) { |
| 750 |
|
| 751 |
String fromStnPrefix = getNamePrefix( fromStnName ); |
| 752 |
if ( fromStnPrefix.length() > 0 ) { |
| 753 |
String toStnPrefix = getNamePrefix( toStnName ); |
| 754 |
if ( toStnPrefix.length() > 0 ) { |
| 755 |
for ( int matchingPointsIdx = 0; matchingPointsIdx < matchingFromPoints.size(); matchingPointsIdx++ ) { |
| 756 |
String testLabel = arLabels.get( matchingFromPoints.get(matchingPointsIdx) ); |
| 757 |
String testLabelPrefix = getNamePrefix( testLabel ); |
| 758 |
if ( testLabelPrefix.equals(toStnPrefix) ) { |
| 759 |
|
| 760 |
inputLeg.getFromStn().setName( testLabel ); |
| 761 |
|
| 762 |
SurveyStation linkStn1 = new SurveyStation(0); |
| 763 |
linkStn1.setName( getShortenedName( fromStnName ) ); |
| 764 |
SurveyStation linkStn2 = new SurveyStation(0); |
| 765 |
linkStn2.setName( getShortenedName( testLabel ) ); |
| 766 |
|
| 767 |
rebuiltOuterSeries.addLink(rebuiltOuterSeries.getInnerSeries(matchingFromSeries).getSeriesName(),linkStn1, |
| 768 |
rebuiltOuterSeries.getInnerSeries(matchingToSeries).getSeriesName(), linkStn2); |
| 769 |
legNewSeries = matchingToSeries; |
| 770 |
break; |
| 771 |
} |
| 772 |
} |
| 773 |
} |
| 774 |
} |
| 775 |
} |
| 776 |
|
| 777 |
} |
| 778 |
} |
| 779 |
|
| 780 |
|
| 781 |
String shortenedFromName = getShortenedName( inputLeg.getFromStn().getName() ); |
| 782 |
String shortenedToName = getShortenedName( inputLeg.getToStn().getName() ) ; |
| 783 |
inputLeg.getFromStn().setName( shortenedFromName ); |
| 784 |
inputLeg.getToStn().setName( shortenedToName ); |
| 785 |
|
| 786 |
|
| 787 |
rebuiltOuterSeries.getInnerSeries( legNewSeries ).addLeg( inputLeg ); |
| 788 |
} |
| 789 |
} |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
outerSeries = rebuiltOuterSeries; |
| 796 |
} |
| 797 |
else { |
| 798 |
|
| 799 |
for ( int seriesIdx = 0; seriesIdx < outerSeries.innerSeriesCount(); seriesIdx++ ) { |
| 800 |
|
| 801 |
List<double[]> srcChain = allChains.get(seriesIdx); |
| 802 |
String[] srcChainLabels = allChainLabels.get(seriesIdx); |
| 803 |
for ( int point1Idx = 0; point1Idx < srcChain.size(); point1Idx++ ) { |
| 804 |
|
| 805 |
double fixX = srcChain.get(point1Idx)[0]; |
| 806 |
double fixY = srcChain.get(point1Idx)[1]; |
| 807 |
double fixZ = srcChain.get(point1Idx)[2]; |
| 808 |
|
| 809 |
for ( int chainIdx = 0; chainIdx < allChains.size(); chainIdx++ ) { |
| 810 |
List<double[]> chain = allChains.get(chainIdx); |
| 811 |
String[] chainLabels = allChainLabels.get(chainIdx); |
| 812 |
for ( int pointIdx = 0; pointIdx < chain.size(); pointIdx++ ) { |
| 813 |
if ( ( fixX == chain.get(pointIdx)[0] ) |
| 814 |
&& ( fixY == chain.get(pointIdx)[1] ) |
| 815 |
&& ( fixZ == chain.get(pointIdx)[2] ) ) { |
| 816 |
|
| 817 |
boolean addEquate = true; |
| 818 |
if (chainIdx == seriesIdx ) { |
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
if ( pointIdx <= point1Idx) { |
| 823 |
addEquate = false; |
| 824 |
} |
| 825 |
} |
| 826 |
if ( addEquate == true ) { |
| 827 |
|
| 828 |
SurveyStation linkStn1 = new SurveyStation(point1Idx); |
| 829 |
if ( srcChainLabels[point1Idx] != null ) { |
| 830 |
linkStn1.setName( srcChainLabels[point1Idx] ); |
| 831 |
} |
| 832 |
SurveyStation linkStn2 = new SurveyStation(pointIdx); |
| 833 |
if ( chainLabels[pointIdx] != null ) { |
| 834 |
linkStn2.setName( chainLabels[pointIdx] ); |
| 835 |
} |
| 836 |
outerSeries.addLink(outerSeries.getInnerSeries(seriesIdx).getSeriesName(), linkStn1, |
| 837 |
outerSeries.getInnerSeries(chainIdx).getSeriesName(), linkStn2); |
| 838 |
} |
| 839 |
|
| 840 |
if ( seriesIdx > 0 ) { |
| 841 |
SurveyStation stn = outerSeries.getInnerSeries(seriesIdx).getLegRaw(0).getFromStn(); |
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
stn.clearFixedStn(); |
| 847 |
} |
| 848 |
} |
| 849 |
} |
| 850 |
} |
| 851 |
} |
| 852 |
} |
| 853 |
} |
| 854 |
|
| 855 |
|
| 856 |
surveyData.add( outerSeries ); |
| 857 |
|
| 858 |
|
| 859 |
UtilityFunctions.logSurveyDebugData(surveyData, logger); |
| 860 |
|
| 861 |
|
| 862 |
logger.logMessage("Processed " + legCount + " survey legs in " + |
| 863 |
outerSeries.innerSeriesCount() + " series."); |
| 864 |
logger.logMessage("Found:"); |
| 865 |
logger.logMessage("Polylines: " + iPolylineCount + " containing " + iVertexCount + " line segments."); |
| 866 |
logger.logMessage("Lines: " + iPlainlineCount); |
| 867 |
logger.logMessage("Total line segments: " + (iPlainlineCount + iVertexCount)); |
| 868 |
|
| 869 |
return surveyData; |
| 870 |
} |
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
private int findMatchingSeriesForStnName( SurveySeries series, String stnName ) { |
| 881 |
int matchingIdx = -1; |
| 882 |
|
| 883 |
|
| 884 |
String stnPrefix = getNamePrefix( stnName ); |
| 885 |
if ( stnPrefix.length() > 0 ) { |
| 886 |
for (int i = 0; i < series.innerSeriesCount(); i++ ) { |
| 887 |
String seriesName = series.getInnerSeries( i ).getSeriesName(); |
| 888 |
if ( stnPrefix.equalsIgnoreCase( seriesName ) ) { |
| 889 |
matchingIdx = i; |
| 890 |
break; |
| 891 |
} |
| 892 |
} |
| 893 |
|
| 894 |
|
| 895 |
if ( matchingIdx == -1 ) { |
| 896 |
SurveySeries newSeries = new SurveySeries( stnPrefix ); |
| 897 |
series.addSeries( newSeries ); |
| 898 |
matchingIdx = series.innerSeriesCount() - 1; |
| 899 |
} |
| 900 |
} |
| 901 |
|
| 902 |
return matchingIdx; |
| 903 |
} |
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
private String[] mapLabelsToChainPoints( List<double[]> arSurveyChain, List<double[]> arLabelPoints, |
| 915 |
List<String> stnLabels ) { |
| 916 |
|
| 917 |
|
| 918 |
String[] labels = new String[arSurveyChain.size()]; |
| 919 |
for ( int i = 0; i < arSurveyChain.size(); i++ ) { |
| 920 |
double[] chainPoint = arSurveyChain.get(i); |
| 921 |
for ( int j = 0; j < arLabelPoints.size(); j++ ) { |
| 922 |
|
| 923 |
if ( ( chainPoint[0] == arLabelPoints.get(j)[0] ) |
| 924 |
&& ( chainPoint[1] == arLabelPoints.get(j)[1] ) |
| 925 |
&& ( chainPoint[2] == arLabelPoints.get(j)[2] ) ) { |
| 926 |
labels[i] = stnLabels.get(j); |
| 927 |
break; |
| 928 |
} |
| 929 |
} |
| 930 |
} |
| 931 |
|
| 932 |
return labels; |
| 933 |
|
| 934 |
} |
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
private SurveySeries makeSeriesFromPolyline( List<double[]> arSurveyChain, String seriesName, String[] labels ) { |
| 943 |
|
| 944 |
SurveySeries series = new SurveySeries( seriesName ); |
| 945 |
|
| 946 |
|
| 947 |
series.setSurveyDate( seriesDate ); |
| 948 |
|
| 949 |
|
| 950 |
for ( int i = 1; i < arSurveyChain.size(); i++ ) { |
| 951 |
SurveyLeg leg = new SurveyLeg(); |
| 952 |
SurveyStation fromStn = new SurveyStation( i - 1 ); |
| 953 |
SurveyStation toStn = new SurveyStation( i ); |
| 954 |
double[] startPoint = arSurveyChain.get( i - 1 ); |
| 955 |
double[] endPoint = arSurveyChain.get(i); |
| 956 |
|
| 957 |
if ( i == 1 ) { |
| 958 |
|
| 959 |
fromStn.setFixed(FixType.OTHER, startPoint[0], startPoint[1], startPoint[2]); |
| 960 |
} |
| 961 |
|
| 962 |
|
| 963 |
double x = endPoint[0] - startPoint[0]; |
| 964 |
double y = endPoint[1] - startPoint[1]; |
| 965 |
double z = endPoint[2] - startPoint[2]; |
| 966 |
|
| 967 |
|
| 968 |
if ( x != 0 || y != 0 || z != 0 || arSurveyChain.size() == 2 ) { |
| 969 |
double hori = Math.pow( Math.pow( x, 2 ) + Math.pow( y, 2 ), 0.5 ); |
| 970 |
double tape = Math.pow( Math.pow( hori, 2 ) + Math.pow( z, 2 ), 0.5 ); |
| 971 |
double compass = bearing(x, y); |
| 972 |
double clino = bearing(z, hori); |
| 973 |
if ( clino > 90 ) { |
| 974 |
clino = clino - 360; |
| 975 |
} |
| 976 |
|
| 977 |
if (labels[i-1] != null) { |
| 978 |
fromStn.setName( labels[i-1] ); |
| 979 |
} |
| 980 |
if (labels[i] != null) { |
| 981 |
toStn.setName( labels[i] ); |
| 982 |
} |
| 983 |
|
| 984 |
leg.setFromStn( fromStn ); |
| 985 |
leg.setToStn( toStn ); |
| 986 |
leg.setLength( tape, LengthUnit.Metres ); |
| 987 |
leg.setCompass( compass, BearingUnit.Degrees ); |
| 988 |
leg.setClino( clino, GradientUnit.Degrees ); |
| 989 |
|
| 990 |
series.addLeg(leg); |
| 991 |
} |
| 992 |
} |
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
return series; |
| 997 |
} |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
private double bearing(double x, double y) { |
| 1005 |
double res = 0; |
| 1006 |
|
| 1007 |
if ( x == 0 ) { |
| 1008 |
if ( y < 0 ) { |
| 1009 |
res = 180; |
| 1010 |
} |
| 1011 |
else { |
| 1012 |
res = 0; |
| 1013 |
} |
| 1014 |
} |
| 1015 |
else if ( x < 0 ) { |
| 1016 |
if ( y == 0 ) { |
| 1017 |
res = 270; |
| 1018 |
} |
| 1019 |
else if ( y < 0 ) { |
| 1020 |
|
| 1021 |
res = 180 + (Math.atan(x / y) * 180 / Math.PI); |
| 1022 |
} |
| 1023 |
else { |
| 1024 |
|
| 1025 |
res = 360 + (Math.atan(x / y) * 180 / Math.PI); |
| 1026 |
} |
| 1027 |
} |
| 1028 |
else { |
| 1029 |
if ( y == 0 ) { |
| 1030 |
res = 90; |
| 1031 |
} |
| 1032 |
else if ( y < 0 ) { |
| 1033 |
|
| 1034 |
res = 180 + (Math.atan(x / y) * 180 / Math.PI); |
| 1035 |
} |
| 1036 |
else { |
| 1037 |
|
| 1038 |
res = (Math.atan(x / y) * 180 / Math.PI); |
| 1039 |
} |
| 1040 |
} |
| 1041 |
|
| 1042 |
return res; |
| 1043 |
} |
| 1044 |
|
| 1045 |
private double roundedDataValue( String dataLine ) { |
| 1046 |
double roundedVal = ( (double)Math.round( Double.valueOf(dataLine) * 10000 ) ) / 10000; |
| 1047 |
|
| 1048 |
return roundedVal; |
| 1049 |
} |
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
private void CleanSeries( SurveySeries series ) { |
| 1056 |
|
| 1057 |
List<String> stnNamePrefixes = new ArrayList<String>(); |
| 1058 |
List<Integer> stnNamePrefixCounts = new ArrayList<Integer>(); |
| 1059 |
|
| 1060 |
for ( int i = 0; i < series.legCount(); i++ ) { |
| 1061 |
SurveyLeg leg = series.getLegRaw( i ); |
| 1062 |
|
| 1063 |
String name = leg.getFromStn().getName(); |
| 1064 |
if ( name.contains(".") ) { |
| 1065 |
String prefix = name.substring( 0, name.lastIndexOf('.') ); |
| 1066 |
boolean found = false; |
| 1067 |
for ( int j = 0; j < stnNamePrefixes.size(); j++ ) { |
| 1068 |
if ( prefix.equals( stnNamePrefixes.get(j) ) ) { |
| 1069 |
found = true; |
| 1070 |
int count = stnNamePrefixCounts.get(j); |
| 1071 |
count++; |
| 1072 |
stnNamePrefixCounts.set(j, count); |
| 1073 |
break; |
| 1074 |
} |
| 1075 |
} |
| 1076 |
if ( found == false ) { |
| 1077 |
stnNamePrefixes.add( prefix ); |
| 1078 |
stnNamePrefixCounts.add(1); |
| 1079 |
} |
| 1080 |
} |
| 1081 |
|
| 1082 |
name = leg.getToStn().getName(); |
| 1083 |
if ( name.contains(".") ) { |
| 1084 |
String prefix = name.substring( 0, name.lastIndexOf('.') ); |
| 1085 |
boolean found = false; |
| 1086 |
for ( int j = 0; j < stnNamePrefixes.size(); j++ ) { |
| 1087 |
if ( prefix.equals( stnNamePrefixes.get(j) ) ) { |
| 1088 |
found = true; |
| 1089 |
int count = stnNamePrefixCounts.get(j); |
| 1090 |
count++; |
| 1091 |
stnNamePrefixCounts.set(j, count); |
| 1092 |
break; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
if ( found == false ) { |
| 1096 |
stnNamePrefixes.add( prefix ); |
| 1097 |
stnNamePrefixCounts.add(1); |
| 1098 |
} |
| 1099 |
} |
| 1100 |
} |
| 1101 |
|
| 1102 |
if ( stnNamePrefixes.size() > 0 ) { |
| 1103 |
|
| 1104 |
int mostCommonPrefixIdx = 0; |
| 1105 |
int highestOccurence = 0; |
| 1106 |
for ( int j = 0; j < stnNamePrefixCounts.size(); j++ ) { |
| 1107 |
if ( stnNamePrefixCounts.get(j) > highestOccurence ) { |
| 1108 |
mostCommonPrefixIdx = j; |
| 1109 |
highestOccurence = stnNamePrefixCounts.get(j); |
| 1110 |
} |
| 1111 |
} |
| 1112 |
|
| 1113 |
|
| 1114 |
series.setSeriesName( stnNamePrefixes.get( mostCommonPrefixIdx ) ); |
| 1115 |
} |
| 1116 |
|
| 1117 |
} |
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
private String getNamePrefix( String name ) { |
| 1125 |
int lastDotPos = name.lastIndexOf('.'); |
| 1126 |
String prefix = ""; |
| 1127 |
if ( lastDotPos > -1 ) { |
| 1128 |
prefix = name.substring( 0, lastDotPos ); |
| 1129 |
} |
| 1130 |
return prefix; |
| 1131 |
} |
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
private String getShortenedName( String name ) { |
| 1139 |
int lastDotPos = name.lastIndexOf('.'); |
| 1140 |
String shortName = name; |
| 1141 |
if ( lastDotPos > -1 ) { |
| 1142 |
shortName = name.substring( lastDotPos + 1 ); |
| 1143 |
} |
| 1144 |
return shortName; |
| 1145 |
} |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
private List<Integer> getListOfMatchingPoints(double[] matchingPoint, List<double[]> labelPoints) { |
| 1154 |
List<Integer> matchingPoints = new ArrayList<Integer>(); |
| 1155 |
for ( int allPointsIdx = 0; allPointsIdx < labelPoints.size(); allPointsIdx++ ) { |
| 1156 |
double[] testPoint = labelPoints.get( allPointsIdx ); |
| 1157 |
if ( ( matchingPoint[0] == testPoint[0]) |
| 1158 |
&& ( matchingPoint[1] == testPoint[1]) |
| 1159 |
&& ( matchingPoint[2] == testPoint[2]) ) { |
| 1160 |
|
| 1161 |
matchingPoints.add( allPointsIdx ); |
| 1162 |
} |
| 1163 |
} |
| 1164 |
return matchingPoints; |
| 1165 |
} |
| 1166 |
} |