private static Coordinate[] Reproject(this Coordinate[] coordinates, ProjectionInfo source, ProjectionInfo target) { if (target.Transform == null) { return(coordinates); } var xy = new double[coordinates.Length * 2]; var z = new double[coordinates.Length]; var j = 0; for (var i = 0; i < coordinates.Length; i++) { Coordinate c = coordinates[i]; xy[j] = c.X; xy[j + 1] = c.Y; j = j + 2; z[i] = double.IsNaN(c.Z) ? 0 : c.Z; } DotSpatialReproject.ReprojectPoints(xy, z, source, target, 0, coordinates.Length); var result = new List <Coordinate>(coordinates.Length); j = 0; for (var i = 0; i < coordinates.Length; i++) { result.Add(new Coordinate(xy[j++], xy[j++])); } return(result.ToArray()); }
/// <summary> /// Reprojects a <see cref="Extent"/>. /// </summary> /// <param name="extent">The object to be reprojected.</param> /// <param name="source">The coordinate system corresponding to <paramref name="extent"/>.</param> /// <param name="target">The target coordinate system.</param> /// <returns>The reprojected <see cref="Extent"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input argument is <c>null</c>.</exception> public static Extent Reproject(this Extent extent, ProjectionInfo source, ProjectionInfo target) { if (extent == null) { throw new ArgumentNullException(nameof(extent)); } if (source == null) { throw new ArgumentNullException(nameof(source)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } if (target.Transform == null) { return(extent); } double[] xy = ToSequence(extent); DotSpatialReproject.ReprojectPoints(xy, null, source, target, 0, xy.Length / 2); return(ToExtent(xy)); }
private IEnumerable <Tuple <Point, Point> > GetValidPoints(int y, int offsetY, int x1, int x2, WorldFile sourceReference, Size sourceTileSize) { int len = x2 - x1; var xy = new double[len * 2]; var i = 0; for (int x = x1; x < x2; x++) { Coordinate c = mapArgs.PixelToProj(new Point(x, y)); xy[i] = c.X; xy[i + 1] = c.Y; i = i + 2; } DotSpatialReproject.ReprojectPoints(xy, null, target, source, 0, len); i = 0; y -= offsetY; for (var x = 0; x < len; x++) { var coord = new Coordinate(xy[i++], xy[i++]); Point sourcePixelLocation = sourceReference.ToScreenCoordinates(coord); if (IsSourcePointInsideArea(sourceTileSize, sourcePixelLocation)) { yield return(Tuple.Create(sourcePixelLocation, new Point(x, y))); } } }