ajtruckle
Posts: 4
Joined: Thu Dec 04, 2008 1:04 am

Lat/Long to OSGB_36

Thu Dec 04, 2008 1:07 am

Hi

I am trying this out as an activex using visual c++ MFC dialogue app. I have looked at the sample and I have a little problem. This is what I have so far:

Code: Select all

	COleException ex;
	ILicense license;

	if(!license.CreateDispatch(_T("GpsToolsXP.License"), &ex))
	{
		ex.ReportError();
		return false;
	}

	COleVariant key;

	key.SetString(_T("---------------"), VT_BSTR);

	TRY
	{
		license.SetLicenseKey(key);
	}
	CATCH_ALL(e)
	{
		e->ReportError();
		return false;
	}
	END_CATCH_ALL

	IPosition	pos;

	// OSGB_36 (3)
	COleVariant	vDatum;
	vDatum.intVal = 3;
	pos.SetDatum(vDatum);

	COleVariant	vD, vM, vS,vH;
	vD.dblVal = 52;
	vM.dblVal = 14;
	vS.dblVal = 2.71;
	vH.SetString(_T("N"), VT_BSTR);

	pos.SetLongitudeDMS(vD,vM,vS,vH);

	_variant_t vEast;
	vEast = pos.GetEasting();
	CString a;
	a.Format(_T("%f"), vEast.dblVal);
	AfxMessageBox(a);
The last bit of code is giving me problems because when I compile I get these messages:

1>JPG_ExifDlg.obj : error LNK2001: unresolved external symbol "void __stdcall _com_issue_error(long)" (?_com_issue_error@@YGXJ@Z)
1>C:\My Programs\VS2005\JPG_Exif\Debug\JPG_Exif.exe : fatal error LNK1120: 1 unresolved externals


I am sorry if this is a basic question. The program has great help files so I should be able to work it out. I think it is initializing. The lat/long is coming from GPS data. All I need to do is convert to OSGB_36 easting and northing.

If I can resolve this then I can look at purchasing the library.

Thank you.

Andrew

ajtruckle
Posts: 4
Joined: Thu Dec 04, 2008 1:04 am

RE: Lat/Long to OSGB_36

Thu Dec 04, 2008 1:24 am

I thought I made a mistake, since the value I was using was a latitude and not logitude, and I forgot to use that Grid method, so I altered it:

Code: Select all

	IPosition	pos;

	// WGS_84  (1)
	// OSGB_36 (3)
	COleVariant	vDatum;
	vDatum.intVal = 3;
	pos.SetDatum(vDatum);

	COleVariant	vD, vM, vS,vH;
	vD.dblVal = 52;
	vM.dblVal = 14;
	vS.dblVal = 2.71;
	vH.SetString(_T("N"), VT_BSTR);

	pos.SetLatitudeDMS(vD,vM,vS,vH);

	COleVariant vGrid;
	vGrid.intVal = 3;
	pos.SetGrid(vGrid);

	VARIANT v;
	v = pos.GetNorthing();
	CString a;
	a.Format(_T("%lf"), v.dblVal);
	AfxMessageBox(a);
It compiles, but the value I get is a huge negative value. So thanks for detailing where I am going wrong.

Andrew

ajtruckle
Posts: 4
Joined: Thu Dec 04, 2008 1:04 am

RE: Lat/Long to OSGB_36

Thu Dec 04, 2008 12:01 pm

Code: Select all

		// WGS_84  (1)
		// OSGB_36 (3)
		COleVariant	vDatum;
		vDatum.intVal = 3;
		pos.SetDatum(vDatum);

		COleVariant vAlt, vFrm;
		vAlt.intVal = 54;
		vFrm.intVal = 0;
		pos.SetAltitude(vAlt, vFrm);


		COleVariant	vD, vM, vS,vH;
		vD.dblVal = 52;
		vM.dblVal = 14;
		vS.dblVal = 2.71;
		vH.SetString(_T("N"), VT_BSTR);

		pos.SetLatitudeDMS(vD,vM,vS,vH);

		vD.dblVal = 0;
		vM.dblVal = 51;
		vS.dblVal = 42.7;
		vH.SetString(_T("W"), VT_BSTR);

		pos.SetLongitudeDMS(vD,vM,vS,vH);

		COleVariant vGrid;
		vGrid.intVal = 3;
		pos.SetGrid(vGrid);

		VARIANT ve, vn;
		vn = pos.GetNorthing());
		ve = pos.GetEasting();
		CString a;
		a.Format(_T("e %lf\nn %lf"), ve.dblVal, vn.dblVal);
		AfxMessageBox(a);
Now tried the above. I would have thought it was correct but my resulting values don't seem to be initializes and I get no catch errors.

ajtruckle
Posts: 4
Joined: Thu Dec 04, 2008 1:04 am

RE: Lat/Long to OSGB_36

Thu Dec 04, 2008 12:48 pm

Ok, sorry for me being a bit dense! I forgot the CreateDispatch call:

Code: Select all

		if(!iPosition.CreateDispatch(_T("GpsToolsXP.Position"), &ex))
		{
			ex.ReportError();
			return false;
		}
Now things are beginning to work. However, when I tried getting some coordinates via this URL:

http://www.nearby.org.uk/coord.cgi?f=conv

for the LAT/LONG stated in myearlier code, it returned:

430032,259634

whereas my code in my application returns:

477822.868316,206157.603937

Ideas?

Andrew

Return to “GpsTools”