示例#1
0
        public void TestBehaviourWhenNoCachingIsChosen()
        {
            cacheTestTransformationAdapterProjNet = new CrsTransformationAdapterProjNet(CrsCachingStrategy.NO_CACHING);
            Assert.IsFalse(
                cacheTestTransformationAdapterProjNet.IsEpsgCached(
                    cacheTestForOutputEpsgNumberNotExisting
                    )
                );
            Assert.IsFalse(
                cacheTestTransformationAdapterProjNet.IsEpsgCached(
                    EpsgNumber.SWEDEN__SWEREF99_TM__3006
                    )
                );

            // The transform method below may potentially trigger
            // the used epsg code (the second parameter) to become cached
            // (but that behaviour depends on the caching strategy)
            cacheTestTransformationAdapterProjNet.Transform(
                cacheTestInputCoordinateWgs84,
                cacheTestForOutputEpsgNumberNotExisting
                );
            // The above output CRS was a non-existing EPSG number
            // but below is an existing EPSG number used.
            cacheTestTransformationAdapterProjNet.Transform(
                cacheTestInputCoordinateWgs84,
                EpsgNumber.SWEDEN__SWEREF99_TM__3006
                );

            // Neither of the above are still not cached since caching is disabled
            Assert.IsFalse(
                cacheTestTransformationAdapterProjNet.IsEpsgCached(
                    cacheTestForOutputEpsgNumberNotExisting
                    )
                );
            Assert.IsFalse(
                cacheTestTransformationAdapterProjNet.IsEpsgCached(
                    EpsgNumber.SWEDEN__SWEREF99_TM__3006
                    )
                );
        }
示例#2
0
        private void VerifyExpectedCachingBehaviour(
            CrsCachingStrategy crsCachingStrategy
            )
        {
            cacheTestTransformationAdapterProjNet = new CrsTransformationAdapterProjNet(crsCachingStrategy);
            Assert.IsFalse(
                cacheTestTransformationAdapterProjNet.IsEpsgCached(
                    cacheTestForOutputEpsgNumberNotExisting
                    )
                );

            // The transform method below may potentially trigger
            // the used epsg code (the second parameter) to become cached
            // (but that behaviour depends on the caching strategy
            //  i.e. it must not be NO_CACHING)
            cacheTestTransformationAdapterProjNet.Transform(
                cacheTestInputCoordinateWgs84,
                cacheTestForOutputEpsgNumberNotExisting
                );

            // It should be true below.
            // Indeed the lookup is cached even though it is a non-existin
            // EPSG number (i.e. "null" is cached)
            // since you do likely not want to read the file
            // many times (if you have specified that you want caching)
            // just to get null again, so therefore the null value
            // is also cached as a kind of value in the semantic of the below method
            Assert.IsTrue(
                cacheTestTransformationAdapterProjNet.IsEpsgCached(
                    cacheTestForOutputEpsgNumberNotExisting
                    )
                );

            if (crsCachingStrategy == CrsCachingStrategy.CACHE_ALL_EPSG_CRS_CODES)
            {
                // The EPSG number below have not been directly used yet in this test method
                // (e.g. as the input coordinate or the output CRS for a transformation)
                // but since everything (according to the above if statement we are now within)
                // should have been cached it should be cached already anyway now
                Assert.IsTrue(
                    cacheTestTransformationAdapterProjNet.IsEpsgCached(
                        EpsgNumber.SWEDEN__SWEREF99_TM__3006
                        )
                    );
            }
            else if (crsCachingStrategy == CrsCachingStrategy.CACHE_EPSG_CRS_CODE_WHEN_FIRST_USED)
            {
                Assert.IsFalse(
                    cacheTestTransformationAdapterProjNet.IsEpsgCached(
                        EpsgNumber.SWEDEN__SWEREF99_TM__3006
                        )
                    );
                // but after a transformation below it should be cached

                cacheTestTransformationAdapterProjNet.Transform(
                    cacheTestInputCoordinateWgs84,
                    EpsgNumber.SWEDEN__SWEREF99_TM__3006
                    );

                Assert.IsTrue(
                    cacheTestTransformationAdapterProjNet.IsEpsgCached(
                        EpsgNumber.SWEDEN__SWEREF99_TM__3006
                        )
                    );
            }
        }