[code]
local distans=0
function CalcDist(firstPointLatitude1,firstPointLongitude1,secondPointLatitude1,secondPointLongitude1)
earthRadius = 6367000
firstPointLatitude = (firstPointLatitude1 * math.pi ) / 180
firstPointLongitude = (firstPointLongitude1 * math.pi ) / 180
secondPointLatitude = (secondPointLatitude1 * math.pi ) / 180
secondPointLongitude = (secondPointLongitude1 * math.pi ) / 180
calcLongitude = secondPointLongitude - firstPointLongitude
calcLatitude = secondPointLatitude - firstPointLatitude
stepOne = math.pow(math.sin(calcLatitude/2), 2) + math.cos(firstPointLatitude) * math.cos(secondPointLatitude) * math.pow(math.sin(calcLongitude/2), 2)
stepTwo = 2 * math.asin(math.min(1,math.sqrt(stepOne)))
calculatedDistance = earthRadius * stepTwo
distans= calculatedDistance
end
local citys = xml:loadFile( “town.xml”, system.TemporaryDirectory)
for i=1,#citys.child do
byer[i] = citys.child[i]
end
for i=1,#byer do
adress=byer[i].child[4].value
local latitude, longitude = myMap:getAddressLocation( adress )
currentLocation = myMap:getUserLocation()
currentLatitude = currentLocation.latitude
currentLongitude = currentLocation.longitude
CalcDist(currentLatitude,currentLongitude,latitude,longitude)
if (distans < 10000) then
data[i]={}
data[i].dist=distans
end
end [/code]
This is the code that I am struggling with, if I write if (distans \< 10000) then
then I get a value in distant, but if I write if (distans \< 1000) then then it does not work.
Somebody got a clue??
maholm
[import]uid: 5717 topic_id: 21475 reply_id: 321475[/import]
