1

Im creating a plugin for VBS2. In the program I can output a grid in either LAT LONG,UTM or MGRS. I need to be able to convert to BNG. I have managed to create a TKinter application in python that works using Proj.4 but now need to create it in C++ as a DLL.

The LatLong im using (51.20650N 1.81906W) is a known point, the BNG conversion is approx SU 127 452.

#include <proj_api.h>




double x = 51.20650; //atof(GetStrArgument(input, 0)); 
double y = 1.81906;  //atof(GetStrArgument(input, 1));  

char *pj_latlongc = "+proj=longlat +datum=WGS84";
char *pj_UTMc = "+proj=utm +zone=29 +ellps=WGS84";
char *osc = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000    +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs";

projPJ pj_OS = pj_init_plus(osc);
projPJ pj_UTM = pj_init_plus(pj_UTMc);
projPJ pj_latlong = pj_init_plus(pj_latlongc);

x *= DEG_TO_RAD;
y *= DEG_TO_RAD;

int p = pj_transform(pj_latlong, pj_OS, 1, 1, &x, &y, NULL);

Unfortunately the result is completely wrong and doesn't make sense.Could someone help on this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.