Ejemplo n.º 1
0
        private static GeometryCollection DoTest(Type expectedType)
        {
            string name    = expectedType.Name;
            string file    = string.Format("{0}s", name.ToLowerInvariant());
            string resname = string.Format("NetTopologySuite.Tests.NUnit.TestData.{0}.xml", file);
            string xml     = new StreamReader(EmbeddedResourceManager.GetResourceStream(resname)).ReadToEnd();

            var gr = new GMLReader();

            GeometryCollection gc = null;

            // different target frameworks have different overload sets...
            foreach (var readMethod in GetReadMethods())
            {
                gc = (GeometryCollection)readMethod(gr, xml);
                Assert.IsTrue(gc.NumGeometries == 25);
                for (int i = 0; i < 25; i++)
                {
                    var g = gc.GetGeometryN(i);
                    Assert.IsNotNull(g);
                    Assert.IsInstanceOf(expectedType, g);
                }
            }

            return(gc);
        }
Ejemplo n.º 2
0
        private static void ReadAndTest(string file)
        {
            Console.WriteLine(file);
            string gml;

            using (var fl = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Samples.Tests.Various." + file))
            {
                gml = new StreamReader(fl).ReadToEnd();
            }

            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(gml);
            string gmlNode = xmlDoc.DocumentElement.FirstChild.NextSibling.FirstChild.LastChild.InnerXml;

            Console.WriteLine(gmlNode);

            var gmlReader = new NetTopologySuite.IO.GML2.GMLReader();
            var geom      = gmlReader.Read(gmlNode);

            Assert.IsNotNull(geom);
            Assert.IsFalse(geom.IsEmpty);

            Console.WriteLine(geom.ToString());
            Console.WriteLine(new string('=', 60));
        }
 public void TestPerformanceAfrica()
 {
     using (var file = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.africa.wkt"))
     {
         //    runTest(TestFiles.DATA_DIR + "world.wkt");
         PerformanceTest(file);
     }
 }
        public void TestAll()
        {
            string name   = "NetTopologySuite.Tests.NUnit.TestData.europe.wkt";
            var    stream = EmbeddedResourceManager.GetResourceStream(name);

            CheckInteriorPointFile(stream, name);
            name   = "NetTopologySuite.Tests.NUnit.TestData.africa.wkt";
            stream = EmbeddedResourceManager.GetResourceStream(name);
            CheckInteriorPointFile(stream, name);
        }
        public void TestEurope()
        {
#if !PCL
            var filePath = EmbeddedResourceManager.SaveEmbeddedResourceToTempFile(
                "NetTopologySuite.Tests.NUnit.TestData.europe.wkt");

            RunTest(filePath,
                    CascadedPolygonUnionTester.MinSimilarityMeaure);

            EmbeddedResourceManager.CleanUpTempFile(filePath);
#else
            var europe = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.europe.wkt");
            RunTest(europe, CascadedPolygonUnionTester.MinSimilarityMeaure);
#endif
        }
Ejemplo n.º 6
0
        private GeometryCollection LoadData()
        {
            List <Geometry> data = null;

            try
            {
                data = readWKTFile(EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.world.wkt"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return(Factory.CreateGeometryCollection(data.ToArray()));
        }
        public void Test()
        {
            Trace.WriteLine("Loading data...");
            var data = GeometryUtils.ReadWKTFile(EmbeddedResourceManager.GetResourceStream(
                                                     "NetTopologySuite.Tests.NUnit.TestData.world.wkt"));

            const int maxTimes = 5;

            for (int i = 1; i <= maxTimes; i++)
            {
                Trace.WriteLine(string.Format("Iteration {0} of {1} started", i, maxTimes));
                RunDissolverWorld(data);
                RunBruteForceWorld(data);
                Trace.WriteLine(string.Format("Iteration {0} of {1} terminated", i, maxTimes));
                Trace.WriteLine(Environment.NewLine);
            }

            Trace.WriteLine("Test terminated");
        }
        public void TestNewResultsIdenticalToOldResults()
        {
            // at 0.02, Simplify deletes about 50% of world.wkt points
            const double DistanceTolerance = 0.02;

            int pointsRemoved   = 0;
            int totalPointCount = 0;

            // track how long the new takes compared to the old
            long oldTicks = 0;
            long newTicks = 0;

            using (var file = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.world.wkt"))
            {
                foreach (LineString line in IOUtil.ReadWKTFile(new StreamReader(file)).SelectMany(LinearComponentExtracter.GetLines))
                {
                    var coordinates = line.Coordinates;

                    var sw         = Stopwatch.StartNew();
                    var oldResults = OldVWLineSimplifier.Simplify(coordinates, DistanceTolerance);
                    sw.Stop();

                    oldTicks += sw.ElapsedTicks;

                    sw.Restart();
                    var newResults = VWLineSimplifier.Simplify(coordinates, DistanceTolerance);
                    sw.Stop();

                    newTicks += sw.ElapsedTicks;

                    CollectionAssert.AreEqual(oldResults, newResults);

                    pointsRemoved   += coordinates.Length - newResults.Length;
                    totalPointCount += coordinates.Length;
                }
            }

            TestContext.WriteLine("Total: Removed {0} of {1} points (reduction: {2:P0}).", pointsRemoved, totalPointCount, pointsRemoved / (double)totalPointCount);
            TestContext.WriteLine("Old: {0:N3} seconds.  New: {1:N3} seconds (reduction: {2:P0}).", oldTicks / (double)Stopwatch.Frequency, newTicks / (double)Stopwatch.Frequency, (oldTicks - newTicks) / (double)oldTicks);
        }
Ejemplo n.º 9
0
 public void TestBase64TextFiles()
 {
     // taken from: https://raw.githubusercontent.com/SharpMap/SharpMap/5289522c26e77584eaa95428c1bd2202ff18a340/UnitTests/TestData/Base%2064.txt
     TestBase64TextFile(EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.Base 64.txt"));
 }
Ejemplo n.º 10
0
        public void TestEurope()
        {
            var europe = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.europe.wkt");

            RunTest(europe, CascadedPolygonUnionTester.MinSimilarityMeaure);
        }
Ejemplo n.º 11
0
        public void TestAfrica()
        {
            var africa = EmbeddedResourceManager.GetResourceStream("NetTopologySuite.Tests.NUnit.TestData.africa.wkt");

            RunTest(africa, CascadedPolygonUnionTester.MinSimilarityMeaure);
        }
Ejemplo n.º 12
0
        ////[TestCase("africa.wkt")]
        public void TestAll(string name)
        {
            var stream = EmbeddedResourceManager.GetResourceStream($"NetTopologySuite.Tests.NUnit.TestData.{name}");

            CheckInteriorPointFile(stream, name);
        }