コード例 #1
0
        internal static com.epl.geometry.QuadTreeImpl BuildQuadTree(com.epl.geometry.MultiPointImpl multipointImpl, com.epl.geometry.Envelope2D extentOfInterest)
        {
            com.epl.geometry.QuadTreeImpl quad_tree_impl = new com.epl.geometry.QuadTreeImpl(extentOfInterest, 8);
            com.epl.geometry.Point2D      pt             = new com.epl.geometry.Point2D();
            bool resized_extent = false;

            com.epl.geometry.Envelope2D boundingbox = new com.epl.geometry.Envelope2D();
            for (int i = 0; i < multipointImpl.GetPointCount(); i++)
            {
                multipointImpl.GetXY(i, pt);
                if (!extentOfInterest.Contains(pt))
                {
                    continue;
                }
                boundingbox.SetCoords(pt);
                int element_handle = quad_tree_impl.Insert(i, boundingbox);
                if (element_handle == -1)
                {
                    if (resized_extent)
                    {
                        throw com.epl.geometry.GeometryException.GeometryInternalError();
                    }
                    // resize extent
                    resized_extent = true;
                    com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
                    multipointImpl.CalculateEnvelope2D(extent, false);
                    quad_tree_impl.Reset(extent, 8);
                    i = -1;
                    // resets the for-loop
                    continue;
                }
            }
            return(quad_tree_impl);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }