public static Coordinate GPSFromPercentilePosition(this Map This, Point pos) { double percX = pos.X; double percY = pos.Y; Point A = new Point(This.NWLong, This.NWLat); Point B = new Point(This.NELong, This.NELat); Point C = new Point(This.SELong, This.SELat); Point D = new Point(This.SWLong, This.SWLat); Line AB = new Line(A, new Vector(A, B)); Line DC = new Line(D, new Vector(D, C)); Line AD = new Line(A, new Vector(A, D)); Line BC = new Line(B, new Vector(B, C)); Point X0 = AB.MoveOnLineFromBaseForUnits(percX); Point X1 = DC.MoveOnLineFromBaseForUnits(percX); Point Y0 = AD.MoveOnLineFromBaseForUnits(percY); Point Y1 = BC.MoveOnLineFromBaseForUnits(percY); Line X0X1 = new Line(X0, new Vector(X0, X1)); Line Y0Y1 = new Line(Y0, new Vector(Y0, Y1)); Point? p = Line.Intersection(X0X1, Y0Y1); if (p != null) { Coordinate gps = new Coordinate(); gps.Longitude = p.Value.X; gps.Latitude = p.Value.Y; gps.Altitude = double.NaN; return gps; } else { throw new ArithmeticException("Lines do not cross. Mapdata are corrupted"); } }