public void CreateFromCrsCode_ShouldThrowException_WhenCrsCodeIsNull() { ArgumentException exception = Assert.Throws<ArgumentNullException>( () => { CrsIdentifierFactory.CreateFromCrsCode(null); } , "CRS code must not be null" ); }
public void CrsIdentifierFactory_ShouldThrowException_WhenCrsCodeIsEpsgWithNegativeNumber() { ArgumentException exception = Assert.Throws<ArgumentException>( () => { CrsIdentifierFactory.CreateFromCrsCode(GetCrsCodeIncludingUppercasedEpsgPrefix(-123)); // should fail } , "EPSG must not be negative" ); AssertExceptionMessageWhenArgumentWasNullOrEmptyString(exception, "non-positive"); }
public void CrsIdentifierFactory_ShouldThrowException_WhenCrsCodeInputIsOnlyWhitespace() { ArgumentException exception = Assert.Throws<ArgumentException>( () => { CrsIdentifierFactory.CreateFromCrsCode(" "); // should fail } , "Must not be empty string" ); AssertExceptionMessageWhenArgumentWasNullOrEmptyString(exception, "non-empty"); }
public void method2() { int epsgNumber = 4326; string crsCode = "EPSG:" + epsgNumber; CrsIdentifier crsIdentifier; // namespace Programmerare.CrsTransformations.Identifier crsIdentifier = CrsIdentifierFactory.CreateFromEpsgNumber(epsgNumber); // Alternative: crsIdentifier = CrsIdentifierFactory.CreateFromCrsCode(crsCode); double latitude = 59.330231; double longitude = 18.059196; CrsCoordinate crsCoordinate; // namespace Programmerare.CrsTransformations.Coordinate // All the below methods are alternatives for creating the same coordinate // with the above latitude/longitude and coordinate reference system. // No class or object is used for the methods below because of the following static import: // using static Programmerare.CrsTransformations.Coordinate.CrsCoordinateFactory; crsCoordinate = LatLon(latitude, longitude, epsgNumber); crsCoordinate = LatLon(latitude, longitude, crsCode); crsCoordinate = LatLon(latitude, longitude, crsIdentifier); crsCoordinate = LonLat(longitude, latitude, epsgNumber); crsCoordinate = LonLat(longitude, latitude, crsCode); crsCoordinate = LonLat(longitude, latitude, crsIdentifier); crsCoordinate = YX(latitude, longitude, epsgNumber); crsCoordinate = YX(latitude, longitude, crsCode); crsCoordinate = YX(latitude, longitude, crsIdentifier); crsCoordinate = XY(longitude, latitude, epsgNumber); crsCoordinate = XY(longitude, latitude, crsCode); crsCoordinate = XY(longitude, latitude, crsIdentifier); crsCoordinate = NorthingEasting(latitude, longitude, epsgNumber); crsCoordinate = NorthingEasting(latitude, longitude, crsCode); crsCoordinate = NorthingEasting(latitude, longitude, crsIdentifier); crsCoordinate = EastingNorthing(longitude, latitude, epsgNumber); crsCoordinate = EastingNorthing(longitude, latitude, crsCode); crsCoordinate = EastingNorthing(longitude, latitude, crsIdentifier); crsCoordinate = CreateFromYNorthingLatitudeAndXEastingLongitude(latitude, longitude, epsgNumber); crsCoordinate = CreateFromYNorthingLatitudeAndXEastingLongitude(latitude, longitude, crsCode); crsCoordinate = CreateFromYNorthingLatitudeAndXEastingLongitude(latitude, longitude, crsIdentifier); crsCoordinate = CreateFromXEastingLongitudeAndYNorthingLatitude(longitude, latitude, epsgNumber); crsCoordinate = CreateFromXEastingLongitudeAndYNorthingLatitude(longitude, latitude, crsCode); crsCoordinate = CreateFromXEastingLongitudeAndYNorthingLatitude(longitude, latitude, crsIdentifier); CrsIdentifier targetCrs = CrsIdentifierFactory.CreateFromEpsgNumber(3006); CrsTransformationResult crsTransformationResult = crsTransformationAdapter.Transform(crsCoordinate, targetCrs); // see more example code further down in this webpage }
private void crsIdentifierCode() { // public factory methods: crsIdentifier = CrsIdentifierFactory.CreateFromEpsgNumber(4326); crsIdentifier = CrsIdentifierFactory.CreateFromCrsCode("EPSG:4326"); // public properties: crsCode = crsIdentifier.CrsCode; epsgNumber = crsIdentifier.EpsgNumber; isEpsgCode = crsIdentifier.IsEpsgCode; }
public void CrsIdentifierFactory_ShouldThrowException_WhenCrsCodeInputIsNull() { ArgumentException exception = Assert.Throws<ArgumentNullException>( () => { CrsIdentifierFactory.CreateFromCrsCode(null); // should fail } , "Must not be null" ); // F# code invoked above may throw exception like this: // nullArg "crsCode" // Resulting message: "Value cannot be null. Parameter name: crsCode" AssertExceptionMessageWhenArgumentWasNullOrEmptyString(exception, "cannot be null"); }
public void CrsIdentifier_ShouldReturnEpsgNumberAndUppercasedEpsgPrefixedWhitespaceTrimmedCrsCodeAndBeConsideredAsEpsg_WhenCreatedFromLowecasedEpsgCodeWithSurroundingWhitespace() { int inputEpsgNumber = 4326; string inputCrsCode = " epsg:" + inputEpsgNumber + " "; CrsIdentifier crsIdentifier = CrsIdentifierFactory.CreateFromCrsCode(inputCrsCode); // the input should become trimmed and return string with uppercased "EPSG:" prefix Assert.AreEqual( GetCrsCodeIncludingUppercasedEpsgPrefix(inputEpsgNumber), crsIdentifier.CrsCode ); Assert.AreEqual(true, crsIdentifier.IsEpsgCode); Assert.AreEqual(inputEpsgNumber, crsIdentifier.EpsgNumber); }
public void crsIdentifier_shouldNotBeEqual_whenDifferentNonEpsgCrsCode() { Assert.AreNotEqual( CrsIdentifierFactory.CreateFromCrsCode("abc"), CrsIdentifierFactory.CreateFromCrsCode("abd") ); }
public void CrsIdentifier_ShouldNotBeEqual_WhenDifferentCrsCode() { Assert.AreNotEqual( CrsIdentifierFactory.CreateFromCrsCode("EPSG:987"), CrsIdentifierFactory.CreateFromCrsCode("EPSG:986") ); }
public void CrsIdentifier_ShouldReturnWhitespaceTrimmedCrsCodeAndNotBeConsideredAsEpsg_WhenCreatedFromNonEpsgString() { CrsIdentifier crsIdentifier = CrsIdentifierFactory.CreateFromCrsCode(" abc "); Assert.AreEqual("abc", crsIdentifier.CrsCode); Assert.AreEqual(false, crsIdentifier.IsEpsgCode); }
public void CrsIdentifiers_ShouldBeEqual_WhenCreatedFromEpsgNumberAndCorrespondingCrsCode() { CrsIdentifier fromEpsgNumber = CrsIdentifierFactory.CreateFromEpsgNumber(3006); CrsIdentifier fromCrsCode = CrsIdentifierFactory.CreateFromCrsCode(" epsg:3006 "); Assert.AreEqual(fromEpsgNumber, fromCrsCode); Assert.AreEqual(fromEpsgNumber.GetHashCode(), fromCrsCode.GetHashCode()); }