예제 #1
0
        /// <summary>
        /// Method to open an sbn index file
        /// </summary>
        /// <param name="sbnFilename">The sbn index filename></param>
        /// <returns>An sbn index query structure</returns>
        public static SbnQueryOnlyTree Open(string sbnFilename)
        {
            if (string.IsNullOrEmpty(sbnFilename))
            {
                throw new ArgumentNullException(sbnFilename);
            }

            if (!File.Exists(sbnFilename))
            {
                throw new FileNotFoundException("File not found", sbnFilename);
            }

            var sbxFilename = Path.ChangeExtension(sbnFilename, "sbx");

            if (!File.Exists(sbxFilename))
            {
                throw new FileNotFoundException("File not found", sbxFilename);
            }

            var res = new SbnQueryOnlyTree(sbnFilename, sbxFilename);

            var sbxHeader = new SbnHeader();

            sbxHeader.Read(new BinaryReader(res._sbxStream));

            if (res._sbnHeader.NumRecords != sbxHeader.NumRecords)
            {
                throw new SbnException("Sbn and Sbx do not serve the same number of features!");
            }

            return(res);
        }
예제 #2
0
            private SbnQueryOnlyNode(SbnQueryOnlyTree tree, int nid, byte[] splitBounds)
            {
                _tree = tree;
                Nid   = nid;
                _minX = splitBounds[0];
                _minY = splitBounds[1];
                _maxX = splitBounds[2];
                _maxY = splitBounds[3];

                _features = ReadBins(nid, _tree._sbnBinIndex);
                if (Level <= _tree.MaxCacheLevel)
                {
                    _tree._sbnBinIndex.CacheNode(this);
                }
            }
예제 #3
0
 internal static void CreateRoot(SbnQueryOnlyTree tree)
 {
     var root = new SbnQueryOnlyNode(tree, 1, new byte[] { 0, 0, 255, 255 });
 }