In C++ you can try the Proj4 library. It has a very complete set of projection transformation routines. It’s used by many softwares and is open source.
If you need to read and write GIS data as well, I would recommend the Gdal library (which uses the Proj4 library for projection handling).
Unfortunatelly, I’am not awhere of any Lua bindings for both, but it should be very straightforward to create a single routine for conversion in C and bind that routine to Lua.
If you are going to use those libraries, just keep in mind that WGS84 is a datum (which is both a description of the Earth ellipsoid in use and the origin of the coordinate system) and UTM is a projection.
To specify a point in the world you need both a datum and a projection. So you can transform from Lat Long + WGS84 into UTM (which also needs a zone that depends on where you are on the Earth) + WGS84.
If you where in Rio de Janeiro, for example , you would probably want to convert from Lat Long + WGS 84 to UTM (zone 23) + SAD69 (a stadard datum used in South america).
Hope that helps.
Regards,
Carlos Augusto.
Enviado do Email do Windows
De: Geoff Leyland
Enviado: 26 de julho de 2013 03:09
Para: Lua mailing list
Assunto: Re: Lua, WGS84 and UTM
On 26/07/2013, at 2:16 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
>> Before I go ahead and do it myself, does anyone know of freely available Lua code to convert between WGS84 (Latitude and Longitude) to UTM (Universal Transverse Mercator)?
>
> Is there authoritative C or C++ code for that? In this case you can either
> bind it to Lua or just convert manually.
There are certainly plenty of examples in other languages (For example [1]. I've already got WGS84 to NZTM in Lua, but that's of limited interest to the rest of the world). So it's not a big deal to translate to Lua. Since it's a very standard kind of thing, I figured I'd ask to try to keep the number of implementations down.
[1] https://github.com/Turbo87/utm/blob/master/utm/conversion.py