コード例 #1
0
 ISpatialIndex <uint> ISpatialIndexFactory <uint> .Load(string fileName)
 {
     try
     {
         var tree = SbnTree.Load(Path.ChangeExtension(fileName, "sbn"));
         return(new SbnTreeWrapper(tree));
     }
     catch (FileNotFoundException)
     {
         return(null);
     }
 }
コード例 #2
0
ファイル: SbnTest.cs プロジェクト: FObermaier/SharpSbn
        public void TestToText(string sbnFile)
        {
            if (!File.Exists(sbnFile))
            {
                throw new IgnoreException("File '" + sbnFile + "' not found!");
            }

            SbnTree sbn = null;

            Assert.DoesNotThrow(() => sbn = SbnTree.Load(sbnFile));
            Assert.DoesNotThrow(() => SbnTree.SbnToText(sbnFile, new StreamWriter(File.OpenWrite(Path.ChangeExtension(sbnFile, ".sbn.txt")))));
            Assert.IsNotNull(sbn);
            Assert.IsTrue(sbn.VerifyNodes());

            var sbnTestFile = Path.ChangeExtension(sbnFile, null) + "_test.sbn";

            Assert.DoesNotThrow(() => sbn.Save(sbnTestFile));
            Assert.DoesNotThrow(() => SbnTree.SbnToText(sbnTestFile, new StreamWriter(File.OpenWrite(Path.ChangeExtension(sbnTestFile, ".sbn.txt")))));
        }
コード例 #3
0
ファイル: SbnTest.cs プロジェクト: FObermaier/SharpSbn
        public void Test(string sbnFile)
        {
            if (!File.Exists(sbnFile))
            {
                throw new IgnoreException("File '" + sbnFile + "' not found!");
            }

            SbnTree sbn = null;

            Assert.DoesNotThrow(() => sbn = SbnTree.Load(sbnFile));
            Assert.IsNotNull(sbn);
            Assert.IsTrue(sbn.VerifyNodes());

            var sbnTestFile = Path.ChangeExtension(sbnFile, null) + "_test.sbn";

            Assert.DoesNotThrow(() => sbn.Save(sbnTestFile));

            var fiO = new FileInfo(sbnFile);
            var fiT = new FileInfo(sbnTestFile);

            Assert.AreEqual(fiO.Length, fiT.Length);
        }
コード例 #4
0
ファイル: SbnTest.cs プロジェクト: FObermaier/SharpSbn
        public void TestQueryTime(string sbnFile)
        {
            if (!File.Exists(sbnFile))
            {
                throw new IgnoreException("File '" + sbnFile + "' not found!");
            }

            var     sw  = new Stopwatch();
            SbnTree sbn = null;

            sw.Start();
            Assert.DoesNotThrow(() => sbn = SbnTree.Load(sbnFile));
            sw.Stop();
            Console.WriteLine("SbnTree read in {0:N0} ticks", sw.ElapsedTicks);

            var fullExtent = sbn.Extent;

            for (var i = 0; i < 10; i++)
            {
                sw.Restart();
                var fids = new List <uint>(sbn.QueryFids(fullExtent));
                sw.Stop();
                Console.WriteLine("Querying full in {0:N0} ticks ({1} ids)", sw.ElapsedTicks, fids.Count);
            }

            var partialExtent = ToSbn(new Envelope(
                                          fullExtent.MinX + 0.4 * fullExtent.Width,
                                          fullExtent.MaxX - 0.4 * fullExtent.Width,
                                          fullExtent.MinY + 0.3 * fullExtent.Height,
                                          fullExtent.MaxY - 0.3 * fullExtent.Height));

            for (var i = 0; i < 10; i++)
            {
                sw.Restart();
                var fids = new List <uint>(sbn.QueryFids(partialExtent));
                sw.Stop();
                Console.WriteLine("Querying part in {0:N0} ticks ({1} ids)", sw.ElapsedTicks, fids.Count);
            }
        }