private static IEnumerable<TestDataSweden> GetCsvDataFromFileWithSomeCoordinatesForSweden() { using(StreamReader sr = File.OpenText(testFileWithSomeCoordinatesForSweden)) { string line; while( (line = sr.ReadLine()) != null ) { // the first line of the file (which will be ignored in this iteration): //Description;4326Y;4326X;3021Y;3021X;3006Y;3006X;Url with some information about the location at the row if( line.StartsWith("Description;") // the line above || line.StartsWith("#") // "comment rows" to be ignored starts with a "#" ) continue; // example of a later line in the file i.e. one of those lines to become used: // Stockholm Centralstation;59.330231;18.059196;6580994;1628294;6580822;674032;https://kartor.eniro.se/m/03Yxp var arr = line.Split(";"); var t = new TestDataSweden(); t.description = arr[0]; t.wgs84Lat = double.Parse(arr[1]); t.wgs84Lon = double.Parse(arr[2]); t.rt90north = double.Parse(arr[3]); t.rt90east = double.Parse(arr[4]); t.sweref99north = double.Parse(arr[5]); t.sweref99east = double.Parse(arr[6]); t.url = arr[7]; yield return t; } } }
public void VerifyTransformationsCorrespondToCsvFileCoordinates( TestDataSweden t ) { string description = t.description; double wgs84Lat = t.wgs84Lat; double wgs84Lon = t.wgs84Lon; double rt90north = t.rt90north; double rt90east = t.rt90east; double sweref99north = t.sweref99north; double sweref99east = t.sweref99east; string url = t.url; // example row from the csv file: // Stockholm Centralstation;59.330231;18.059196;6580994;1628294;6580822;674032;https://kartor.eniro.se/m/03Yxp // These used coordinates (i.e. those in the csv file) were manually retrieved from the Eniro // site at the URL's for each row, and by clicking the coordinate feature // which shows the coordinates in the three systems WGS84, RT90, SWREF99 foreach (ICrsTransformationAdapter crsTransformationAdapter in crsTransformationAdapterImplementations) { TransformToCoordinate_ShouldReturnEqualCoordinates_WhenTransformingBetweenTwoKnownCoordinatesToAndFromEachOther( crsTransformationAdapter, epsgNumberForWgs84, epsgNumberForRT90, wgs84Lat, wgs84Lon, rt90north, rt90east, description ); TransformToCoordinate_ShouldReturnEqualCoordinates_WhenTransformingBetweenTwoKnownCoordinatesToAndFromEachOther( crsTransformationAdapter, epsgNumberForWgs84, epsgNumberForSweref99TM, wgs84Lat, wgs84Lon, sweref99north, sweref99east, description ); TransformToCoordinate_ShouldReturnEqualCoordinates_WhenTransformingBetweenTwoKnownCoordinatesToAndFromEachOther( crsTransformationAdapter, epsgNumberForRT90, epsgNumberForSweref99TM, rt90north, rt90east, sweref99north, sweref99east, description ); } }
public void VerifyTransformationsBackAndForthFromWgs84ToSwedishProjections( TestDataSweden t ) { CrsCoordinate inputCoordinateWGS84 = CrsCoordinateFactory.CreateFromXEastingLongitudeAndYNorthingLatitude( t.wgs84Lon, t.wgs84Lat, epsgNumberForWgs84 ); foreach (ICrsTransformationAdapter crsTransformationAdapter in crsTransformationAdapterImplementations) { foreach (int epsgNumber in epsgNumbersForSwedishProjectionsUsingMeterAsUnit) { TransformToCoordinate_ShouldReturnTheOriginalCoordinate_WhenTransformingBackAgainFromTheResult( crsTransformationAdapter, inputCoordinateWGS84, epsgNumber ); } } }
public void TransformToCoordinate_ShouldReturnTheSameCoordinate_WhenTransformingWithDifferentImplementations( TestDataSweden t ) { CrsCoordinate inputCoordinateWGS84 = CrsCoordinateFactory.CreateFromXEastingLongitudeAndYNorthingLatitude( t.wgs84Lon, t.wgs84Lat, epsgNumberForWgs84 ); for (int i = 0; i < crsTransformationAdapterImplementations.Count-1; i++) { for (int j = i+1; j < crsTransformationAdapterImplementations.Count; j++) { foreach (int epsgNumber in epsgNumbersForSwedishProjectionsUsingMeterAsUnit) { TransformToCoordinate_ShouldReturnTheSameCoordinate_WhenTransformingWithTwoDifferentImplementations( crsTransformationAdapterImplementations[i], crsTransformationAdapterImplementations[j], inputCoordinateWGS84, epsgNumber ); } } } }