Are there any plans to provide True North on Android? I don’t want to rely on my app to get the declination from a website since I would like my app to be able to function without any internet access, to be “self-contained”, without need to access external resources. Without this it seems that the only option is to make a lookup table - which is really more work than I desire to undertake. Is the absence of True North on Android a limitation of Android phones or simply a limitation of Corona?
The compass is going to use Magnetic North. It’s the way compasses work. What API calls are you using to get directions now?
Rob
According to the documentation (https://docs.coronalabs.com/api/event/heading/index.html), event.geographic is available for IOS, but not Android. event.magnetic will provide the degrees that I am offset from magnetic north. event.geographic provides degrees offset from geographic/true north. What I need is true/geographic north and Corona won’t give me that if I am on an Android. I was simply wanting to know if there are plans to have event.geographic available on Android.
Engineering doesn’t have a lot of history on this limitation and they don’t have time to research it right now. Your best bet is to add a feature request for it at http://feedback.coronalabs.com and get people to vote it up.
There are quite a few feature requests around location services and once we are past this huge taskload Engineering is facing, I’ll try to push for more time on location services.
Rob
Thanks for the response. This turned out to be a good learning experience for me. I found a C routine (http://www.societyofrobots.com/robotforum/index.php?topic=11855.0) and I was able to convert it to LUA. The routine returns an approximate declination given a latitude and longitude. The declination can then be as an offset to get true/geographic north from magnetic north.
[lua]
– This function returns the declination of a given latitude and longitude in
– the ranges of latitudes -60 to 60 and longitudes -180 to 180. Before calling this function,
– it is important to test if the latitude is within the -60 to 60 range.
local function declination (lat, lon)
– This is a 13 X 37 array. Each element in the array is the declination for a given
– latitude and longitude. It is a 12 X 36 grid that encompasses the area from latitudes -60
– to 60 and longitudes -180 to 180 in 10 degree increments. The first element is the array is
– 46 - the declination for latitude: -60 and longitude: -180. The last element in the array
– is 3 - the declination for latitude: 60 and longitude 180.
– (lat:-60) 37 (lat:-60)
– (long:-180) ------------------------------------------ (long:180) |
– | | |
– | | 13
– | | |
– | | |
– (lat: 60) ------------------------------------------ (lat:60)
– (long:-180) (long:180)
– It is important to note that the array is arranged “upside down” from the way a person
– would normally visualize the earth.
local lonmin
local dec_tbl = {46,45,44,42,41,40,38,36,33,28,23,16,10,4,-1,-5,-9,-14,-19,-26,-33,-40,-48,-55,-61,
-66,-71,-74,-75,-72,-61,-25,22,40,45,47,46,30,30,30,30,29,29,29,29,27,24,18,11,3,
-3,-9,-12,-15,-17,-21,-26,-32,-39,-45,-51,-55,-57,-56,-53,-44,-31,-14,0,13,21,26,
29,30,21,22,22,22,22,22,22,22,21,18,13,5,-3,-11,-17,-20,-21,-22,-23,-25,-29,-35,
-40,-44,-45,-44,-40,-32,-22,-12,-3,3,9,14,18,20,21,16,17,17,17,17,17,16,16,16,13,
8,0,-9,-16,-21,-24,-25,-25,-23,-20,-21,-24,-28,-31,-31,-29,-24,-17,-9,-3,0,4,7,
10,13,15,16,12,13,13,13,13,13,12,12,11,9,3,-4,-12,-19,-23,-24,-24,-22,-17,-12,-9,
-10,-13,-17,-18,-16,-13,-8,-3,0,1,3,6,8,10,12,12,10,10,10,10,10,10,10,9,9,6,0,-6,
-14,-20,-22,-22,-19,-15,-10,-6,-2,-2,-4,-7,-8,-8,-7,-4,0,1,1,2,4,6,8,10,10,9,9,9,
9,9,9,8,8,7,4,-1,-8,-15,-19,-20,-18,-14,-9,-5,-2,0,1,0,-2,-3,-4,-3,-2,0,0,0,1,3,5,
7,8,9,8,8,8,9,9,9,8,8,6,2,-3,-9,-15,-18,-17,-14,-10,-6,-2,0,1,2,2,0,-1,-1,-2,-1,0,
0,0,0,1,3,5,7,8,8,9,9,10,10,10,10,8,5,0,-5,-11,-15,-16,-15,-12,-8,-4,-1,0,2,3,2,1,0,
0,0,0,0,-1,-2,-2,-1,0,3,6,8,6,9,10,11,12,12,11,9,5,0,-7,-12,-15,-15,-13,-10,-7,-3,
0,1,2,3,3,3,2,1,0,0,-1,-3,-4,-5,-5,-2,0,3,6,5,8,11,13,15,15,14,11,5,-1,-9,-14,-17,
-16,-14,-11,-7,-3,0,1,3,4,5,5,5,4,3,1,-1,-4,-7,-8,-8,-6,-2,1,5,4,8,12,15,17,18,16,
12,5,-3,-12,-18,-20,-19,-16,-13,-8,-4,-1,1,4,6,8,9,9,9,7,3,-1,-6,-10,-12,-11,-9,-5,
0,4,3,9,14,17,20,21,19,14,4,-8,-19,-25,-26,-25,-21,-17,-12,-7,-2,1,5,9,13,15,16,16,
13,7,0,-7,-12,-15,-14,-11,-6,-1,3}
– The declination values are retrieved from the four corners of the grid “tile”
– that contain the the given latitude and longitude. For example: for lat: -25,
– long 45, the declination values are retrieved from the four corners of that “tile”
– (-20,40), (-20,50), (-30,40), and (-30,50). Bilinear interpolation is then used
– to provide an approximate declination with those 4 declination values.
if (lon == 180) then lonmin = 170
else lonmin = math.floor(lon/10)*10
end
local latmin = math.floor(lat/10)*10
local latmin_index= (60+latmin)/10
– In C the first element of an array is zero, whereas in Lua, the first element is 1
local lonmin_index= ((180+lonmin)/10) + 1
– The indexing of the array was modified so that the latitude and longitude indices
– could be used in a one dimensional array
local decSW = dec_tbl[(latmin_index * 37) + lonmin_index]
local decSE = dec_tbl[(latmin_index * 37) + lonmin_index+1]
local decNE = dec_tbl[(latmin_index+1) * 37 + lonmin_index+1]
local decNW = dec_tbl[(latmin_index+1) * 37 + lonmin_index]
– approximate declination within the grid using bilinear interpolation */
local decmin = (lon - lonmin) / 10 * (decSE - decSW) + decSW;
local decmax = (lon - lonmin) / 10 * (decNE - decNW) + decNW;
local dec = (lat - latmin) / 10 * (decmax - decmin) + decmin;
return dec
end
[/lua]
The compass is going to use Magnetic North. It’s the way compasses work. What API calls are you using to get directions now?
Rob
According to the documentation (https://docs.coronalabs.com/api/event/heading/index.html), event.geographic is available for IOS, but not Android. event.magnetic will provide the degrees that I am offset from magnetic north. event.geographic provides degrees offset from geographic/true north. What I need is true/geographic north and Corona won’t give me that if I am on an Android. I was simply wanting to know if there are plans to have event.geographic available on Android.
Engineering doesn’t have a lot of history on this limitation and they don’t have time to research it right now. Your best bet is to add a feature request for it at http://feedback.coronalabs.com and get people to vote it up.
There are quite a few feature requests around location services and once we are past this huge taskload Engineering is facing, I’ll try to push for more time on location services.
Rob
Thanks for the response. This turned out to be a good learning experience for me. I found a C routine (http://www.societyofrobots.com/robotforum/index.php?topic=11855.0) and I was able to convert it to LUA. The routine returns an approximate declination given a latitude and longitude. The declination can then be as an offset to get true/geographic north from magnetic north.
[lua]
– This function returns the declination of a given latitude and longitude in
– the ranges of latitudes -60 to 60 and longitudes -180 to 180. Before calling this function,
– it is important to test if the latitude is within the -60 to 60 range.
local function declination (lat, lon)
– This is a 13 X 37 array. Each element in the array is the declination for a given
– latitude and longitude. It is a 12 X 36 grid that encompasses the area from latitudes -60
– to 60 and longitudes -180 to 180 in 10 degree increments. The first element is the array is
– 46 - the declination for latitude: -60 and longitude: -180. The last element in the array
– is 3 - the declination for latitude: 60 and longitude 180.
– (lat:-60) 37 (lat:-60)
– (long:-180) ------------------------------------------ (long:180) |
– | | |
– | | 13
– | | |
– | | |
– (lat: 60) ------------------------------------------ (lat:60)
– (long:-180) (long:180)
– It is important to note that the array is arranged “upside down” from the way a person
– would normally visualize the earth.
local lonmin
local dec_tbl = {46,45,44,42,41,40,38,36,33,28,23,16,10,4,-1,-5,-9,-14,-19,-26,-33,-40,-48,-55,-61,
-66,-71,-74,-75,-72,-61,-25,22,40,45,47,46,30,30,30,30,29,29,29,29,27,24,18,11,3,
-3,-9,-12,-15,-17,-21,-26,-32,-39,-45,-51,-55,-57,-56,-53,-44,-31,-14,0,13,21,26,
29,30,21,22,22,22,22,22,22,22,21,18,13,5,-3,-11,-17,-20,-21,-22,-23,-25,-29,-35,
-40,-44,-45,-44,-40,-32,-22,-12,-3,3,9,14,18,20,21,16,17,17,17,17,17,16,16,16,13,
8,0,-9,-16,-21,-24,-25,-25,-23,-20,-21,-24,-28,-31,-31,-29,-24,-17,-9,-3,0,4,7,
10,13,15,16,12,13,13,13,13,13,12,12,11,9,3,-4,-12,-19,-23,-24,-24,-22,-17,-12,-9,
-10,-13,-17,-18,-16,-13,-8,-3,0,1,3,6,8,10,12,12,10,10,10,10,10,10,10,9,9,6,0,-6,
-14,-20,-22,-22,-19,-15,-10,-6,-2,-2,-4,-7,-8,-8,-7,-4,0,1,1,2,4,6,8,10,10,9,9,9,
9,9,9,8,8,7,4,-1,-8,-15,-19,-20,-18,-14,-9,-5,-2,0,1,0,-2,-3,-4,-3,-2,0,0,0,1,3,5,
7,8,9,8,8,8,9,9,9,8,8,6,2,-3,-9,-15,-18,-17,-14,-10,-6,-2,0,1,2,2,0,-1,-1,-2,-1,0,
0,0,0,1,3,5,7,8,8,9,9,10,10,10,10,8,5,0,-5,-11,-15,-16,-15,-12,-8,-4,-1,0,2,3,2,1,0,
0,0,0,0,-1,-2,-2,-1,0,3,6,8,6,9,10,11,12,12,11,9,5,0,-7,-12,-15,-15,-13,-10,-7,-3,
0,1,2,3,3,3,2,1,0,0,-1,-3,-4,-5,-5,-2,0,3,6,5,8,11,13,15,15,14,11,5,-1,-9,-14,-17,
-16,-14,-11,-7,-3,0,1,3,4,5,5,5,4,3,1,-1,-4,-7,-8,-8,-6,-2,1,5,4,8,12,15,17,18,16,
12,5,-3,-12,-18,-20,-19,-16,-13,-8,-4,-1,1,4,6,8,9,9,9,7,3,-1,-6,-10,-12,-11,-9,-5,
0,4,3,9,14,17,20,21,19,14,4,-8,-19,-25,-26,-25,-21,-17,-12,-7,-2,1,5,9,13,15,16,16,
13,7,0,-7,-12,-15,-14,-11,-6,-1,3}
– The declination values are retrieved from the four corners of the grid “tile”
– that contain the the given latitude and longitude. For example: for lat: -25,
– long 45, the declination values are retrieved from the four corners of that “tile”
– (-20,40), (-20,50), (-30,40), and (-30,50). Bilinear interpolation is then used
– to provide an approximate declination with those 4 declination values.
if (lon == 180) then lonmin = 170
else lonmin = math.floor(lon/10)*10
end
local latmin = math.floor(lat/10)*10
local latmin_index= (60+latmin)/10
– In C the first element of an array is zero, whereas in Lua, the first element is 1
local lonmin_index= ((180+lonmin)/10) + 1
– The indexing of the array was modified so that the latitude and longitude indices
– could be used in a one dimensional array
local decSW = dec_tbl[(latmin_index * 37) + lonmin_index]
local decSE = dec_tbl[(latmin_index * 37) + lonmin_index+1]
local decNE = dec_tbl[(latmin_index+1) * 37 + lonmin_index+1]
local decNW = dec_tbl[(latmin_index+1) * 37 + lonmin_index]
– approximate declination within the grid using bilinear interpolation */
local decmin = (lon - lonmin) / 10 * (decSE - decSW) + decSW;
local decmax = (lon - lonmin) / 10 * (decNE - decNW) + decNW;
local dec = (lat - latmin) / 10 * (decmax - decmin) + decmin;
return dec
end
[/lua]