/// <summary> /// Converts a point array from image coordinates to world coordinates based on the current <see cref="Zoom"/>, <see cref="Center"/>, /// map <see cref="Size"/>, and (optionally) the <see cref="MapTransform"/>. /// </summary> /// <param name="points">Point array in image coordinates. Note: if you wish to preserve the input values then /// you must clone the point array as it will be modified if a MapTransform is applied</param> /// <param name="careAboutMapTransform">Indicates whether <see cref="MapTransform"/> should be applied. </param> /// <returns>Point array in world coordinates</returns> public Coordinate[] ImageToWorld(PointF[] points, bool careAboutMapTransform = false) { if (careAboutMapTransform && !MapTransformRotation.Equals(0f)) { using (var transformInv = MapTransformInverted) transformInv.TransformPoints(points); } return(Transform.MapToWorld(points, Center, Zoom, MapHeight, PixelWidth, PixelHeight)); }
/// <summary> /// Converts an array of world coordinates to image coordinates based on the current <see cref="Zoom"/>, <see cref="Center"/>, /// map <see cref="Size"/>, and (optionally) the <see cref="MapTransform"/>. /// </summary> /// <param name="coordinates">Coordinate array in world coordinates</param> /// <param name="careAboutMapTransform">Indicates whether <see cref="MapTransform"/> should be applied. True for typical coordinate calcs, /// False when rendering to image as the Graphics object has already applied the MapTransform</param> /// <returns>PointF array in image coordinates</returns> public PointF[] WorldToImage(Coordinate[] coordinates, bool careAboutMapTransform = false) { // see WorldToImage discussion in Map.cs. This is a slightly shortened form using cached values. if (MapTransformRotation.Equals(0f)) { return(Transform.WorldToMap(coordinates, Left, Top, PixelWidth, PixelHeight)); } var matrix = WorldToMapTransform(careAboutMapTransform); return(Transform.WorldToMap(coordinates, matrix)); }