Ejemplo n.º 1
0
        internal static com.epl.geometry.QuadTreeImpl BuildQuadTree(com.epl.geometry.MultiPointImpl multipointImpl)
        {
            com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D();
            multipointImpl.QueryLooseEnvelope2D(extent);
            com.epl.geometry.QuadTreeImpl quad_tree_impl = new com.epl.geometry.QuadTreeImpl(extent, 8);
            com.epl.geometry.Point2D      pt             = new com.epl.geometry.Point2D();
            com.epl.geometry.Envelope2D   boundingbox    = new com.epl.geometry.Envelope2D();
            bool resized_extent = false;

            for (int i = 0; i < multipointImpl.GetPointCount(); i++)
            {
                multipointImpl.GetXY(i, pt);
                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
                    multipointImpl.CalculateEnvelope2D(extent, false);
                    resized_extent = true;
                    quad_tree_impl.Reset(extent, 8);
                    i = -1;
                    // resets the for-loop
                    continue;
                }
            }
            return(quad_tree_impl);
        }