Ejemplo n.º 1
0
        internal static com.epl.geometry.QuadTreeImpl BuildQuadTreeForPaths(com.epl.geometry.MultiPathImpl multipathImpl)
        {
            com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
            multipathImpl.QueryLooseEnvelope2D(extent);
            if (extent.IsEmpty())
            {
                return(null);
            }
            com.epl.geometry.QuadTreeImpl quad_tree_impl = new com.epl.geometry.QuadTreeImpl(extent, 8);
            int hint_index = -1;

            com.epl.geometry.Envelope2D boundingbox = new com.epl.geometry.Envelope2D();
            bool resized_extent = false;

            do
            {
                for (int ipath = 0, npaths = multipathImpl.GetPathCount(); ipath < npaths; ipath++)
                {
                    multipathImpl.QueryPathEnvelope2D(ipath, boundingbox);
                    hint_index = quad_tree_impl.Insert(ipath, boundingbox, hint_index);
                    if (hint_index == -1)
                    {
                        if (resized_extent)
                        {
                            throw com.epl.geometry.GeometryException.GeometryInternalError();
                        }
                        //This is usually happens because esri shape buffer contains geometry extent which is slightly different from the true extent.
                        //Recalculate extent
                        multipathImpl.CalculateEnvelope2D(extent, false);
                        resized_extent = true;
                        quad_tree_impl.Reset(extent, 8);
                        break;
                    }
                    else
                    {
                        //break the for loop
                        resized_extent = false;
                    }
                }
            }while (resized_extent);
            return(quad_tree_impl);
        }
Ejemplo n.º 2
0
        internal static com.epl.geometry.QuadTreeImpl BuildQuadTree(com.epl.geometry.MultiPathImpl multipathImpl, com.epl.geometry.Envelope2D extentOfInterest)
        {
            com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
            multipathImpl.QueryLooseEnvelope2D(extent);
            com.epl.geometry.QuadTreeImpl quad_tree_impl = new com.epl.geometry.QuadTreeImpl(extent, 8);
            int hint_index = -1;

            com.epl.geometry.Envelope2D          boundingbox = new com.epl.geometry.Envelope2D();
            com.epl.geometry.SegmentIteratorImpl seg_iter    = multipathImpl.QuerySegmentIterator();
            bool resized_extent = false;

            while (seg_iter.NextPath())
            {
                while (seg_iter.HasNextSegment())
                {
                    com.epl.geometry.Segment segment = seg_iter.NextSegment();
                    int index = seg_iter.GetStartPointIndex();
                    segment.QueryEnvelope2D(boundingbox);
                    if (boundingbox.IsIntersecting(extentOfInterest))
                    {
                        hint_index = quad_tree_impl.Insert(index, boundingbox, hint_index);
                        if (hint_index == -1)
                        {
                            if (resized_extent)
                            {
                                throw com.epl.geometry.GeometryException.GeometryInternalError();
                            }
                            // resize extent
                            multipathImpl.CalculateEnvelope2D(extent, false);
                            resized_extent = true;
                            quad_tree_impl.Reset(extent, 8);
                            seg_iter.ResetToFirstPath();
                            break;
                        }
                    }
                }
            }
            return(quad_tree_impl);
        }