/// <summary> /// Transforms from world coordinate system (WCS) to image coordinates /// NOTE: This method DOES NOT take the MapTransform property into account (use <see cref="Map.WorldToImage(GeoAPI.Geometries.Coordinate,bool)"/> instead) /// </summary> /// <param name="p">Point in WCS</param> /// <param name="map">Map reference</param> /// <returns>Point in image coordinates</returns> private static Vector2 TransformToImage(Coordinate p, Map map) { //if (map.MapTransform != null && !map.MapTransform.IsIdentity) // map.MapTransform.TransformPoints(new System.Drawing.PointF[] { p }); if (p.IsEmpty()) return new Vector2(float.NaN); var height = (map.Zoom * map.Size.Height) / map.Size.Width; var left = map.Center.X - map.Zoom * 0.5; var top = map.Center.Y + height * 0.5 * map.PixelAspectRatio; var x = (float)((p.X - left) / map.PixelWidth); var y = (float)((top - p.Y) / map.PixelHeight); if (double.IsNaN(x) || double.IsNaN(y)) return new Vector2(float.NaN); return new Vector2(x, y); }