public void TestCompositeMedian()
 {
     VerifyExpectedEnumWhenNotRepresentingThirdPartLibrary(
         crsTransformationAdapterCompositeFactory.CreateCrsTransformationMedian(),
         CrsTransformationAdapteeType.COMPOSITE_MEDIAN
         );
 }
    public void SetUp() {
        weightFactory = CrsTransformationAdapterWeightFactory.Create();

        crsTransformationAdapterCompositeFactory = CrsTransformationAdapterCompositeFactory.Create();

        crsTransformationAdapterLeafImplementations = new List<ICrsTransformationAdapter>{
            new CrsTransformationAdapterDotSpatial(),
            new CrsTransformationAdapterProjNet(),
            new CrsTransformationAdapterMightyLittleGeodesy()
        };

        crsTransformationAdapterCompositeImplementations = new List<ICrsTransformationAdapter>{
            crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage(),
            crsTransformationAdapterCompositeFactory.CreateCrsTransformationMedian(),
            crsTransformationAdapterCompositeFactory.CreateCrsTransformationFirstSuccess(),
            crsTransformationAdapterCompositeFactory.CreateCrsTransformationWeightedAverage(new List<CrsTransformationAdapterWeight>{
                weightFactory.CreateFromInstance(new CrsTransformationAdapterDotSpatial(), 51.0),
                weightFactory.CreateFromInstance(new CrsTransformationAdapterProjNet(), 52.0),
                weightFactory.CreateFromInstance(new CrsTransformationAdapterMightyLittleGeodesy(), 53.0)
            })
        };
        crsTransformationAdapterImplementations = new List<ICrsTransformationAdapter>();
        crsTransformationAdapterImplementations.AddRange(crsTransformationAdapterLeafImplementations);
        crsTransformationAdapterImplementations.AddRange(crsTransformationAdapterCompositeImplementations);
    }
Пример #3
0
        public void CompositeAdaptersForMedianAndAverage_ShouldBeEqual_WhenLeafsUseTheSameTypeAndConfigurationRegardlessOfTheOrder()
        {
            // Median
            var median1 = crsTransformationAdapterCompositeFactory.CreateCrsTransformationMedian();
            // the leafs created in reversed order:
            var median2 = crsTransformationAdapterCompositeFactoryWithLeafsInReversedOrder.CreateCrsTransformationMedian();

            Assert.AreEqual(
                median1,
                median2
                );
            Assert.AreEqual(
                median1.GetHashCode(),
                median2.GetHashCode()
                );

            // Average
            var average1 = crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage();
            // the leafs created in reversed order:
            var average2 = crsTransformationAdapterCompositeFactoryWithLeafsInReversedOrder.CreateCrsTransformationAverage();

            Assert.AreEqual(
                average1,
                average2
                );
            Assert.AreEqual(
                average1.GetHashCode(),
                average2.GetHashCode()
                );
        }
Пример #4
0
        public void SetUp()
        {
            weightFactory = CrsTransformationAdapterWeightFactory.Create();

            // Leaf adapters:
            dotSpatial          = new CrsTransformationAdapterDotSpatial();
            mightyLittleGeodesy = new CrsTransformationAdapterMightyLittleGeodesy();
            // currently there are no configurations possibilities for the above two leafs
            // but for the below leaf it is possible to create instances with
            // different configurations
            projNet = new CrsTransformationAdapterProjNet();
            ProjNetWithDifferentConfiguration = new CrsTransformationAdapterProjNet(new SridReader("somepath.csv"));

            // Composite adapters:
            crsTransformationAdapterCompositeFactory = CrsTransformationAdapterCompositeFactory.Create(
                new List <ICrsTransformationAdapter> {
                dotSpatial, mightyLittleGeodesy, projNet
            }
                );
            // Note that below list parameter is the same as the above but with the list items in reversed order
            crsTransformationAdapterCompositeFactoryWithLeafsInReversedOrder = CrsTransformationAdapterCompositeFactory.Create(
                new List <ICrsTransformationAdapter> {
                projNet, mightyLittleGeodesy, dotSpatial
            }
                );
            crsTransformationAdapterCompositeFactoryWithOneLeafDifferentlyConfigured = CrsTransformationAdapterCompositeFactory.Create(
                new List <ICrsTransformationAdapter> {
                dotSpatial, mightyLittleGeodesy, ProjNetWithDifferentConfiguration
            }
                );

            average         = crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage();
            median          = crsTransformationAdapterCompositeFactory.CreateCrsTransformationMedian();
            firstSuccess    = crsTransformationAdapterCompositeFactory.CreateCrsTransformationFirstSuccess();
            weightedAverage = crsTransformationAdapterCompositeFactory.CreateCrsTransformationWeightedAverage(new List <CrsTransformationAdapterWeight> {
                weightFactory.CreateFromInstance(dotSpatial, 1.0),
                weightFactory.CreateFromInstance(projNet, 2.0),
                weightFactory.CreateFromInstance(mightyLittleGeodesy, 3.0)
            });
        }
        public void TransformToCoordinate_ShouldReturnMedianResult_WhenUsingMedianCompositeAdapter()
        {
            CrsTransformationAdapterComposite medianCompositeAdapter = crsTransformationAdapterCompositeFactory.CreateCrsTransformationMedian(allLeafAdapters);
            CrsCoordinate resultCoordinate = medianCompositeAdapter.TransformToCoordinate(inputCoordinateSweref99, EpsgNumber.WORLD__WGS_84__4326);

            Assert.IsNotNull(resultCoordinate);

            Assert.AreEqual(
                expectedMedianLatitude,
                resultCoordinate.YNorthingLatitude,
                SMALL_DELTA_VALUE_FOR_COMPARISONS
                );
            Assert.AreEqual(
                expectedMedianLongitude,
                resultCoordinate.XEastingLongitude,
                SMALL_DELTA_VALUE_FOR_COMPARISONS
                );

            AssertCompositeResultHasLeafSubResults(
                medianCompositeAdapter,
                allLeafAdapters.Count // expectedNumberOfLeafResults
                );
        }
Пример #6
0
 public void CreateCrsTransformationMedian_ShouldBeCreatedWithManyImplementations_WhenInstantiatingWithoutParameters() {
     CrsTransformationAdapterComposite crsTransformationMedian = crsTransformationAdapterCompositeFactory.CreateCrsTransformationMedian();
     AssertCompositeNotNullAndAggregatesManyImplementations(crsTransformationMedian);
 }