+ // TODO: Check forcing metres? Is there a nicer way?
+ }
+ }
+ }
+
+ /**
+ * Fix any holes found in the specified edge
+ * @param inTerrainTrack terrain track
+ * @param inCornerIndex index of corner to start from
+ * @param inInc increment along edge
+ */
+ private void fixEdge(Track inTerrainTrack, int inCornerIndex, int inInc)
+ {
+ int prevIndexWithAlt = -1;
+ int sIndex = inCornerIndex;
+ if (inTerrainTrack.getPoint(sIndex).hasAltitude()) {prevIndexWithAlt = 0;}
+ for (int i=1; i<_gridSize; i++)
+ {
+ sIndex += inInc;
+ if (inTerrainTrack.getPoint(sIndex).hasAltitude())
+ {
+ if (prevIndexWithAlt >= 0 && prevIndexWithAlt < (i-1))
+ {
+ final int gapLen = i - prevIndexWithAlt;
+ final int cellIndex1 = inCornerIndex + prevIndexWithAlt * inInc;
+ final double alt1 = inTerrainTrack.getPoint(cellIndex1).getAltitude().getMetricValue();
+ final int cellIndex2 = inCornerIndex + i * inInc;
+ final double alt2 = inTerrainTrack.getPoint(cellIndex2).getAltitude().getMetricValue();
+ //System.out.println("Altitude along edge goes from " + alt1 + " (at " + prevIndexWithAlt + ") to " +
+ // alt2 + " (at " + i + ")");
+ for (int j = 1; j < gapLen; j++)
+ {
+ final double alt = alt1 + (alt2-alt1) * j / gapLen;
+ //System.out.println("Fill in " + (prevIndexWithAlt + j) + "(" + (inCornerIndex + (prevIndexWithAlt + j) * inInc) + ") with alt " + (int) alt);
+ final DataPoint p = inTerrainTrack.getPoint(inCornerIndex + (prevIndexWithAlt + j) * inInc);
+ p.setFieldValue(Field.ALTITUDE, "" + (int) alt, false);
+ // TODO: Check forcing metres?
+ }
+ }
+ prevIndexWithAlt = i;