public void getValue_CoordinateInsideRaster_value() { var parser = new AsciiGridParser(ExistingFile); var parserCellSize = parser.CellSize; Assert.Equal(1, parser.GetValue(new Coordinate(0, 0))); }
private double GetRandomEsriAsciiValue(string file, int requests) { var pixels = new Coordinate[requests]; var asc = new AsciiGridParser(file); var width = asc.NumberOfColumns; var height = asc.NumberOfRows; Parallel.For((long)0, requests, index => { pixels[index] = new Coordinate(_rnd.Next(width), _rnd.Next(height)); }); // Close the file and reopen after messurement has started var watch = System.Diagnostics.Stopwatch.StartNew(); asc = new AsciiGridParser(file); Parallel.ForEach(pixels, pixel => { var coord = new Coordinate(pixel.Y, pixel.X); var value = asc.GetValue(coord); // Console.WriteLine(value); }); return(watch.Elapsed.Milliseconds); }
public void GetDataEqual_value() { var parser = new AsciiGridParser(ExistingFile); const string data = "1 -9999 3\n" + "4 5 6"; Assert.Equal(data, parser.GetData()); }
public void GetMetadata_MetadataEqual_value() { var parser = new AsciiGridParser(ExistingFile); const string metadata = "ncols 3\n" + "nrows 2\n" + "xllcorner 0\n" + "yllcorner 0\n" + "cellsize 10\n" + "nodata_value -9999"; Assert.Equal(metadata, parser.GetMetadata()); }
public void AsciiGridParser_valid() { var parser = new AsciiGridParser(ExistingFile); Assert.NotNull(parser); Assert.Equal(3, parser.NumberOfColumns); Assert.Equal(2, parser.NumberOfRows); Assert.Equal(0, parser.XLowerLeftCorner); Assert.Equal(0, parser.YLowerLeftCorner); Assert.Equal(10, parser.CellSize); Assert.Equal(-9999, parser.NoDataValue); var data = new double[, ] { { 1, -9999, 3 }, { 4, 5, 6 } }; Assert.Equal(data, parser.Data); }
public void GetValueFromGps_GpsOutsideRaster_NoDataValue() { var parser = new AsciiGridParser(ExistingFile); Assert.Equal(parser.NoDataValue, parser.GetValueFromGps(new Gps(31.0, 0.0))); }
public void GetValueFromGps_GpsInsideRaster_value() { var parser = new AsciiGridParser(ExistingFile); Assert.Equal(1, parser.GetValueFromGps(new Gps(0.0, 0.0))); }
public void getValue_CoordinateOutsideRaster_NoDataValue() { var parser = new AsciiGridParser(ExistingFile); Assert.Equal(parser.NoDataValue, parser.GetValue(new Coordinate(3, 0))); }