MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
I'm trying to display a GPS position on a shape map of the British Isles. I have no doubt I am doing something naive but I don't what it is. Here is my code in C# double pX = 0, pY = 0; double dN = 52, dE = 0; mapMain.ProjToPixel(dN, dE, ref pX, ref pY); mapMain.
Converting GPS to screen coordinates
Posted by: cjcstand ()
Date: January 18, 2011 07:38AM

I'm trying to display a GPS position on a shape map of the British Isles. I have no doubt I am doing something naive but I don't what it is. Here is my code in C#

double pX = 0, pY = 0;
double dN = 52, dE = 0;
mapMain.ProjToPixel(dN, dE, ref pX, ref pY);
mapMain.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList);
mapMain.DrawPoint(pX, pY, 2, (uint)Color.FromArgb(0, 0, 0, 255).ToArgb());

Whatever values are created or put in for pX or pY the point gets drawn in the same (wrong) place.

Can anyone tell me where I am going wrong?

Options: ReplyQuote
Re: Converting GPS to screen coordinates
Posted by: sindizzy ()
Date: January 21, 2011 12:47PM

I don't project when i use similar functions. For example;

'create a new drawing layer on map
hndDr = mapMain.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)
'draw a red circle for the center
mapMain.DrawCircle(LonX, LatY, 3, System.Convert.ToUInt32(RGB(255, 0, 0)), True)

AGP

Options: ReplyQuote
Re: Converting GPS to screen coordinates
Posted by: cjcstand ()
Date: January 21, 2011 01:19PM

Thanks, yes I finally figured it out by projecting the pixel coords back to map coordinates, at which point I realised that the ESRI map I had was using Eastings and Northings (which are six figure numbers). So I then added a conversion using the Ordnance Survey DLL to convert my GPS lat and long to Northings and Eastings. The DrawCircle routine accepted these and drew things in the right place

Thanks for your reply!

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: