I am now working with coordinate transformations between different CRSs, e.g. latlong to UTM.
After comparisons, I found out that the coordinate capture plugin in QGIS is quite accurate for the results.
Is there a way I can use the methods QGIS uses to do transformation in my own project?
I have checked that QGIS is using the proj4 library to do the transformation. I have implemented the proj4 transformation, but got slightly different results.
pj_svy21 = pj_init_plus("+proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +no_defs")
pj_latlong = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
double test1 = 37621.665;
double test2 = 12056.915;
projResult = pj_transform(pj_svy21, pj_latlong, 1, 1, &test1, &test2, NULL);
My result (latlong):
1.1253115030392806 103.9197679941208889
QGIS results:
1.35650722603 103.690059679 (check on map more accurate)
Can anyone help me on this?
Need to include iostream and proj_api.h:
int main ()
{
projPJ pj_svy21, pj_latlong
pj_svy21 = pj_init_plus("+proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +no_defs")
pj_latlong = pj_init_plus("+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs")
double test1 = 12056.915;
double test2 = 37621.665;
projResult = pj_transform(pj_svy21, pj_latlong, 1, 0, &test1, &test2, NULL );
std::cout << "latlon: " << test1 * RAD_TO_DEG << ' ' << test2 * RAD_TO_DEG << std::endl;
return 0;
}