Post by mackrackit on Jul 27, 2008 7:39:04 GMT -5
When I run the code below I get the following error:
Runtime Error in program 'UTMLAT': x6frac = tf / (720 * Nfpow)
Can't represent the product as a Float
This program with a few modifications works fine in LB and CASLSoft.
Is there an issuse with large numbers and decimal points?
Runtime Error in program 'UTMLAT': x6frac = tf / (720 * Nfpow)
Can't represent the product as a Float
This program with a few modifications works fine in LB and CASLSoft.
Is there an issuse with large numbers and decimal points?
'UTM to LATLAON
x = 3619626
y = 205353
z = 12
sma = 6378137
smb = 6356752.314
UTMScaleFactor = 0.9996
pi = 3.14159265358979
x = x - 500000
x = x / UTMScaleFactor
y = y / UTMScaleFactor
cMeridian = (-183 + (z * 6))/ 180 *pi
N = (sma - smb) / (sma + smb)
alpha = ((sma +smb)/ 2)*(1 + (mathPOW(N, 2)/4)+(mathPOW(N, 4)/64))
yi = y / alpha
beta = (3*N/2)+(-27* mathPOW(N, 3) /32)+(269* mathPOW(N, 5)/512)
gamma = (21* mathPOW(N, 2) /16)+(-55 * mathPOW(N, 4) /32)
delta = (151* mathPOW(N, 3) /96)+(-417* mathPOW(N, 5) /128)
epsilon = (1097* mathPOW(N, 4) /512)
phif = yi+(beta* sin(2*yi))+(gamma* sin(4*yi0))+(delta* sin(6*yi))+(epsilon* sin(8*yi))
ep2 = (mathPOW(sma, 2) - mathPOW(smb, 2)) / mathPOW(smb, 2)
cf = COS(phif)
nuf2 = ep2* mathPOW(cf, 2)
Nf = mathPOW(sma, 2)/(smb* sqr(1+nuf2))
Nfpow = (Nf)
tf = tan(phif)
tf2 = tf * tf
tf4 = tf2 * tf2
x1frac = 1.0 / (Nfpow * cf)
Nfpow = Nfpow *Nf
x2frac = tf / (2.0 * Nfpow)
Nfpow = Nfpow *Nf
x3frac = 1.0 / (6.0 * Nfpow * cf)
Nfpow = Nfpow *Nf
x4frac = tf / (24.0 * Nfpow)
Nfpow = Nfpow *Nf
x5frac = 1.0 / (120.0 * Nfpow * cf)
Nfpow = Nfpow *Nf
x6frac = tf / (720 * Nfpow)
Nfpow = Nfpow *Nf
x7frac = 1.0 / (5040.0 * Nfpow * cf)
Nfpow = Nfpow *Nf
x8frac = tf / (40320.0 * Nfpow)
x2poly = -1.0 - nuf2
x3poly = -1.0 - 2 * tf2 - nuf2
x4poly = 5.0 + 3.0 * tf2 + 6.0 * nuf2 - 6.0 * tf2 * nuf2- 3.0 * (nuf2 *nuf2) - 9.0 * tf2 * (nuf2 * nuf2)
x5poly = 5.0 + 28.0 * tf2 + 24.0 * tf4 + 6.0 * nuf2 + 8.0 * tf2 * nuf2
x6poly = -61.0 - 90.0 * tf2 - 45.0 * tf4 - 107.0 * nuf2+ 162.0 * tf2 * nuf2
x7poly = -61.0 - 662.0 * tf2 - 1320.0 * tf4 - 720.0 * (tf4 * tf2)
x8poly = 1385.0 + 3633.0 * tf2 + 4095.0 * tf4 + 1575 * (tf4 * tf2)
'#Calculate latitude
latitude =((phif))' + x2frac * x2poly * (x * x)+ x4frac * x4poly *mathPOW(x, 4)+ 'x6frac * x6poly *mathPOW(x, 6)+ x8frac * x8poly *mathPOW(x, 8))
'#Calculate longitude
longitude =((cMeridian))' + x1frac * x+ x3frac * x3poly *mathPOW(x, 3)+ x5frac * 'x5poly *mathPOW(x, 5)+ x7frac * x7poly *mathPOW(x, 7))
latitude = latitude / pi *180
longitude = longitude / pi *180
print latitude
print longitude
Function mathPOW(b,p)
if p < 0 then
x = b
for i = 1 to ABS(p)-1
b = b * x
next i
mathPOW = 1/b
else
x = b
for i = 1 to ABS(p)-1
b = b * x
next i
mathPOW = b
end if
End Function