I have the following data (array with longitude values)
I want to generate an equivalent array containing letters, increasing throught the alphabet if a longitude value is not identical to the previous value. Thus (because longitudes [1] and [2] are identical):
I have the following code (somewhat simplified):
The while block at
should only process number [2], however if I leave out the kludge above the while loop just goes on ad infinitum until a time-out occurs. With the kludge I get:
The WHILE loop appears to be still running when the condition is no longer being met; what am I doing wrong here?
Code:
$Longitude[0] = -6.25195;
$Longitude[1] = -6.25192;
$Longitude[2] = -6.25192;
$Longitude[3] = -6.25177;
$Longitude[4] = -6.25241;
...
I want to generate an equivalent array containing letters, increasing throught the alphabet if a longitude value is not identical to the previous value. Thus (because longitudes [1] and [2] are identical):
Code:
$Letter[0] = 'A';
$Letter[1] = 'B';
$Letter[2] = 'B';
$Letter[3] = 'C';
$Letter[4] = 'D';
...
I have the following code (somewhat simplified):
Code:
$LastLongitude=0;
$NextLetter=-1;
$Looper = 0;
$CountHere = 1;
$i=0;
While ($i < $photoCount)
{
if ($Longitude[$i] <> $LastLongitude) //next location
{
$Counter=1;
$CountHere=1;
$NextLetter=$NextLetter+1;
$LastLongitude=$Longitude[$i];
$Volgnummer[$i]=$Counter . "/" . $CountHere;
$Letter[$i]=substr('ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ',$NextLetter,1);
$i=$i+1;
}
else // another photo at this location
{
$CountHere=0;
$j=$i;
while ($Longitude[$j] == $LastLongitude) //how many more here?
{
$LastLatitude=$Latitude[$j];
$LastLongitude=$Longitude[$j];
$CountHere=$CountHere + 1;
$j=$j + 1;
if ($j==3) // temporary kludge!!!!
{
echo $j . ': ' .$Longitude[$j] . ' x '. $LastLongitude;
exit;
}
}
for ($j=$i; $j<$i+$CountHere; $J++)
{
$Letter[$j]=substr('ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ',$NextLetter,1);
$Volgnummer[$j]=$j . "/" . $CountHere;
$i=$i+1;
}
}
}
The while block at
Code:
while ($Longitude[$j] == $LastLongitude) //how many more here?
Code:
echo $j . ': ' .$Longitude[$j] . ' x '. $LastLongitude;
3: -6.25177 x -6.25192
The WHILE loop appears to be still running when the condition is no longer being met; what am I doing wrong here?