[Gdal-dev] Using mgrs.h in NITF

carlj88 mail at carl-johansson.com
Fri Jan 9 17:47:15 EST 2009


You're right, thank you!

Again, I have exhausted every other possibility and got stuck after building
the sources for mgrs etc.

In the dt_cc/redhat_linux (I run ubuntu) directory I successfully build the
sources. I then try to create a small program from within that folder like
this:

#include <stdio.h>
#include "mgrs.h"

int main() {
        printf("MGRS Converter Tests Mark I\n");

        double lat;
        double lon;
        long prec;
        char *mgrsstr;
        long status;

        lon = -75.0;
        lat = 35.0;

       status = Convert_Geodetic_To_MGRS(lat, lon, prec, mgrsstr);

        return 0;
}

And compile with

gcc -L. -I../mgrs main.c

Which renders the following exception

/tmp/ccu04U0m.o: In function `main':
main.c:(.text+0x52): undefined reference to `Convert_Geodetic_To_MGRS'
collect2: ld returned 1 exit status

I'm still learning C/C++ but from what I read it is missing some library. It
doesn't complain about missing mgrs.h.

Most greatful, threre isn't really any one else


Frank Warmerdam wrote:
> 
> carlj88 wrote:
>> I want to convert geodetic coordinates to MGRS using the code from
>> frmts/nitf/mgrs.c in my QT-application. How do I access these functions
>> from
>> my c++ code? Tried to use 'include "mgrs.h"' but then I don't know how to
>> reference to the function.
>> 
>> I would be most greatful since the web has about nothing to offer on this
>> issue.
>> 
>> Carl Johansson
> 
> Carl,
> 
> First, the MGRS support code in gdal/frmts/nitf is intended primariliy for
> use with the NITF driver internals, not for public use.  You *can* use
> it publically, but it isn't supported and might be fragile.
> 
> The function you would apparently want to call is
> Convert_Geodetic_To_MGRS()
> but it seems this function does not exist in mgrs.c.  I'm not sure if I
> removed
> it to simplfy things - since I didn't need it, or what.
> 
> Well, on reflection, I guess you should go back to the original geotrans
> source to get the MGRS conversion code.  If you can't find the GeoTrans
> source via a google search let me know know and I'll provide a stashed
> copy
> I must have somewhere.
> 
> Best regards,
> -- 
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 

-- 
View this message in context: http://n2.nabble.com/Using-mgrs.h-in-NITF-tp2127339p2135714.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.



More information about the gdal-dev mailing list