Ejemplo n.º 1
0
 public void CompositeFactoryParameterLessMethod_ShouldOnlyReturnLeafsItIsConfiguredToKnowAbout() {
     var composite = compositeFactoryConfiguredWithLeafFactoryOnlyCreatingDotSpatialImplementationAsDefault.CreateCrsTransformationAverage();
     var children = composite.TransformationAdapterChildren;
     Assert.AreEqual(1, children.Count);
     Assert.AreEqual(
         typeof(CrsTransformationAdapterDotSpatial).FullName,
         children[0].GetType().FullName
     );
 }
Ejemplo n.º 2
0
        public void Composite_ShouldReturnLeafsInTheExpectedOrderAccordingToTheSetupMethod()
        {
            IList <ICrsTransformationAdapter> leafs1 = crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage().TransformationAdapterChildren;
            IList <ICrsTransformationAdapter> leafs2 = crsTransformationAdapterCompositeFactoryWithLeafsInReversedOrder.CreateCrsTransformationAverage().TransformationAdapterChildren;

            // Note that the list of leafs above should be in reversed order
            Assert.AreEqual(3, leafs1.Count);
            Assert.AreEqual(leafs1.Count, leafs2.Count);
            // There are three items in each list but since the elements
            // should be the same but in reversed order,
            // the below assertion is that item 0 should be item 2 in the other list
            Assert.AreEqual(leafs1[0].AdapteeType, leafs2[2].AdapteeType);
            Assert.AreEqual(leafs1[1].AdapteeType, leafs2[1].AdapteeType);
            Assert.AreEqual(leafs1[2].AdapteeType, leafs2[0].AdapteeType);
        }
 public void TestCompositeAverage()
 {
     VerifyExpectedEnumWhenNotRepresentingThirdPartLibrary(
         crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage(),
         CrsTransformationAdapteeType.COMPOSITE_AVERAGE
         );
 }
    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);
    }
Ejemplo n.º 5
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_ShouldReturnAverageResult_WhenUsingAverageCompositeAdapter()
        {
            CrsTransformationAdapterComposite averageCompositeAdapter = crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage(allLeafAdapters);
            CrsCoordinate resultCoordinate = averageCompositeAdapter.TransformToCoordinate(inputCoordinateSweref99, EpsgNumber.WORLD__WGS_84__4326);

            Assert.IsNotNull(resultCoordinate);

            Assert.AreEqual(
                expectedAverageLatitude,
                resultCoordinate.YNorthingLatitude,
                SMALL_DELTA_VALUE_FOR_COMPARISONS
                );
            Assert.AreEqual(
                expectedAverageLongitude,
                resultCoordinate.XEastingLongitude,
                SMALL_DELTA_VALUE_FOR_COMPARISONS
                );

            AssertCompositeResultHasLeafSubResults(
                averageCompositeAdapter,
                allLeafAdapters.Count // expectedNumberOfLeafResults
                );
        }
Ejemplo n.º 7
0
 public void CreateCrsTransformationAverage_ShouldBeCreatedWithManyImplementations_WhenInstantiatingWithoutParameters() {
     CrsTransformationAdapterComposite crsTransformationAverage = crsTransformationAdapterCompositeFactory.CreateCrsTransformationAverage();
     AssertCompositeNotNullAndAggregatesManyImplementations(crsTransformationAverage);
 }