
Hi all, and welcome to my first CodePlex post!
I've got a little project on my mind at the moment, and its just for interest sake... My general idea is to convert a plot of cartesian points (x,y) to lat/long.
My cartesian points are arranged on an equidistant grid, measuring 1000,1000 with an origin of (0,0) at the top left.
The origin that I would like to measure from is (500,500) i.e. the centre of the map (where the lat/long is known).
The scale of the grid is 1 = 1.2 or 1 pixel = 1.2km.
Question Time:

1. Is this possible through functions within the DotSpatial framework?
2. I've been able to calculate the distance but bearing from the origin point is proving futile
3. Given the fact that I know the vertical distance, and the horizontal distance between points, do I need to calculate the bearing and distance for the position to be acccurate?
I was hoping to find a BearingTo or From function in the framework, but haven't been able to.
Any thoughts, comments or constructive criticism are welcomed!
Sean


Dec 14, 2011 at 3:57 AM
Edited Dec 14, 2011 at 3:58 AM

I think that you can calculate the azimuth using this function..
public double GetAzimuth(Coordinate origin, Coordinate target)
{
/// geographic coordinates
if (_proj.Transform.Proj4Name == "longlat" )
{
double dlon = toRad(target.X  origin.X);
double dlat = toRad(target.Y  origin.Y);
double y=Math.Sin(dlon) * Cos_deg(target.Y);
double x=Cos_deg(origin.Y) *Sin_deg(target.Y)  Sin_deg(origin.Y) * Cos_deg(target.Y)*Math.Cos(dlon);
return toRad((toDeg(Math.Atan2(y, x)) + 360.0) % 360.0);
}else{
double dx = target.X  origin.X;
double dy = target.Y  origin.Y;
if (dx == 0 && dy > 0) return 0;
if (dx == 0 && dy < 0) return (Math.PI);
if (dx > 0 && dy == 0) return (Math.PI / 2);
if (dx < 0 && dy == 0) return (3 * Math.PI / 2);
if (dx > 0 && dy > 0) return (Math.Atan(dx / dy));
if (dx > 0 && dy < 0) return (Math.PI + Math.Atan(dx / dy));
if (dx < 0 && dy < 0) return ((Math.PI) + Math.Atan(dx / dy));
if (dx < 0 && dy > 0) return ((2 * Math.PI) + Math.Atan(dx / dy));
return 0;
}
}

