MCPcopy Create free account
hub / github.com/OSGeo/gdal / ProcessProximityLine

Method ProcessProximityLine

swig/java/apps/GDALProximity.java:414–524  ·  view source on GitHub ↗
(int[] scanlineArray,
            short[] nearXArray, short[] nearYArray, boolean Forward,
            int iLine, int XSize, float MaxDist, float[] proximityArray,
            int TargetValues[])

Source from the content-addressed store, hash-verified

412 }
413
414 public static void ProcessProximityLine(int[] scanlineArray,
415 short[] nearXArray, short[] nearYArray, boolean Forward,
416 int iLine, int XSize, float MaxDist, float[] proximityArray,
417 int TargetValues[]) {
418
419 int iStart, iEnd, iStep, iPixel;
420
421 if (Forward) {
422 iStart = 0;
423 iEnd = XSize;
424 iStep = 1;
425 } else {
426 iStart = XSize - 1;
427 iEnd = -1;
428 iStep = -1;
429 }
430
431 for (iPixel = iStart; iPixel != iEnd; iPixel += iStep) {
432
433 /*
434 * Is the current pixel a target pixel?
435 */
436
437 boolean isATarget = false;
438
439 if( TargetValues.length == 0) {
440 isATarget = scanlineArray[iPixel] != 0.0F;
441 } else {
442 for( int i = 0; i < TargetValues.length; i++) {
443 if( scanlineArray[iPixel] == TargetValues[i] ) {
444 isATarget = true;
445 break;
446 }
447 }
448 }
449
450 if (isATarget) {
451 proximityArray[iPixel] = 0.0F;
452 nearXArray[iPixel] = (short) iPixel;
453 nearYArray[iPixel] = (short) iLine;
454 continue;
455 }
456
457 float NearDistSq = (float) Math.max((double) MaxDist, (double) XSize);
458
459 NearDistSq = NearDistSq * NearDistSq * 2.0F;
460
461 float DistSq = 0.0F;
462
463 /*
464 * Are we near(er) to to the closest target to the above (below)
465 * pixel?
466 */
467
468 if (nearXArray[iPixel] != -1) {
469 DistSq = (nearXArray[iPixel] - iPixel) * (nearXArray[iPixel] - iPixel)
470 + (nearYArray[iPixel] - iLine) * (nearYArray[iPixel] - iLine);
471 if (DistSq < NearDistSq) {

Callers 1

RunMethod · 0.95

Calls 2

sqrtMethod · 0.80
maxMethod · 0.45

Tested by

no test coverage detected