Ejemplo n.º 1
0
        private static void Collect(SpatialIndexNode node, long minMargin, IObserver <uint> observer)
        {
            var nodesToSearch = new Stack <SpatialIndexNode>();

            while (node.Envelope != null)
            {
                if (node.Children != null)
                {
                    if (node.IsLeaf)
                    {
                        foreach (var child in node.Children)
                        {
                            if (child.Envelope.Margin >= minMargin)
                            {
                                observer.OnNext(child.Data);
                            }
                            else
                            {
                                foreach (var n in node.Children)
                                {
                                    nodesToSearch.Push(n);
                                }
                            }
                        }
                    }
                }
                node = nodesToSearch.TryPop();
            }
        }
Ejemplo n.º 2
0
        private void writeFDB_FC_Index_nodes(DualTreeNode dnode, List <SpatialIndexNode> nodes, int NID, int PID)
        {
            SpatialIndexNode node = new SpatialIndexNode();
            Polygon          p    = new Polygon();
            Ring             ring = new Ring();

            ring.AddPoint(new Point(dnode.Bounds.minx, dnode.Bounds.miny));
            //ring.AddPoint(new Point(node.Bounds.maxx,node.Bounds.miny));
            ring.AddPoint(new Point(dnode.Bounds.maxx, dnode.Bounds.maxy));
            //ring.AddPoint(new Point(node.Bounds.minx,node.Bounds.maxy));
            //ring.AddPoint(new Point(node.Bounds.minx,node.Bounds.miny));
            p.AddRing(ring);
            node.Rectangle = p;

            node.NID  = NID;
            node.PID  = PID;
            node.Page = dnode.page;
            node.IDs  = dnode.ShapeIds;
            nodes.Add(node);

            foreach (DualTreeNode subNode in dnode.SubNodes)
            {
                writeFDB_FC_Index_nodes(subNode, nodes, _NID++, NID);
            }
        }
Ejemplo n.º 3
0
        private SpatialIndexNode Read_SpatialIndex_Node(BinaryReader reader)
        {
            var result = new SpatialIndexNode();

            result.Version            = ReadVersion(reader, 1, 0x1411D9930);
            result.PopulationBitfield = reader.ReadUInt64();
            result.FirstChildIndex    = reader.ReadUInt32();

            return(result);
        }
Ejemplo n.º 4
0
        private static SpatialIndexNode VisitTree(RTree <uint> .RTreeNode rNode)
        {
            var children = new SpatialIndexNode[rNode.Children.Count];

            for (int i = 0; i < rNode.Children.Count; i++)
            {
                children[i] = VisitTree(rNode.Children[i]);
            }

            return(new SpatialIndexNode(rNode.Data, rNode.Envelope, children)
            {
                IsLeaf = rNode.IsLeaf
            });
        }
Ejemplo n.º 5
0
        private static bool ReadNode(BinaryReader reader, out SpatialIndexNode root)
        {
            var data = reader.ReadUInt32();

            if (data == Marker)
            {
                root = default(SpatialIndexNode);
                return(true);
            }

            var packedValues = reader.ReadByte();

            bool isPointEnvelop = (packedValues & 1) > 0;
            bool isLeaf         = (packedValues >> 1) > 0;

            IEnvelop envelop = isPointEnvelop ?
                               (IEnvelop) new PointEnvelop(reader.ReadInt32(), reader.ReadInt32()) :
                               new Envelop(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());

            List <SpatialIndexNode> children = null;

            while (true)
            {
                SpatialIndexNode child;
                if (ReadNode(reader, out child))
                {
                    break;
                }
                if (children == null)
                {
                    children = new List <SpatialIndexNode>(64);
                }
                children.Add(child);
            }

            root        = new SpatialIndexNode(data, envelop, children != null && children.Count > 0 ? children.ToArray() : null);
            root.IsLeaf = isLeaf;
            return(false);
        }
Ejemplo n.º 6
0
 /// <summary> Creates <see cref="SpatialIndex"/>. </summary>
 public SpatialIndex(SpatialIndexNode root)
 {
     _root = root;
 }