Example #1
0
/**
 * Creates the parent level for the given child level. First, orders the items
 * by the x-values of the midpoints, and groups them into vertical slices.
 * For each slice, orders the items by the y-values of the midpoints, and
 * group them into runs of size M (the node capacity). For each run, creates
 * a new (parent) node.
 */
vector<Boundable*>*
STRtree::createParentBoundables(vector<Boundable*> *childBoundables, int newLevel)
{
	Assert::isTrue(!childBoundables->empty());
	int minLeafCount=(int) ceil((double)childBoundables->size()/(double)getNodeCapacity());

	vector<Boundable*> *sortedChildBoundables=sortBoundables(childBoundables);
	vector<vector<Boundable*>*>* verticalSlicesV = verticalSlices(sortedChildBoundables,(int)ceil(sqrt((double)minLeafCount)));
	delete sortedChildBoundables;
	vector<Boundable*> *ret;
	ret = createParentBoundablesFromVerticalSlices(verticalSlicesV, newLevel);
	for (unsigned int i=0; i<verticalSlicesV->size(); i++)
	{
		vector<Boundable *>*inner = (*verticalSlicesV)[i];
		//for (unsigned int j=0; j<inner->size(); j++)
		//{
			// some of these might be provided,
			// some of these might be created
			//delete (*inner)[j];
		//}
		delete inner;
	}
	delete verticalSlicesV;
	return ret;
}
Example #2
0
/*private*/
std::auto_ptr<BoundableList>
STRtree::createParentBoundables(BoundableList* childBoundables, int newLevel)
{
	assert(!childBoundables->empty());
	int minLeafCount=(int) ceil((double)childBoundables->size()/(double)getNodeCapacity());

	std::auto_ptr<BoundableList> sortedChildBoundables ( sortBoundables(childBoundables) );

	std::auto_ptr< vector<BoundableList*> > verticalSlicesV (
			verticalSlices(sortedChildBoundables.get(), (int)ceil(sqrt((double)minLeafCount)))
			);

	std::auto_ptr<BoundableList> ret (
		createParentBoundablesFromVerticalSlices(verticalSlicesV.get(), newLevel)
	);
	for (size_t i=0, vssize=verticalSlicesV->size(); i<vssize; ++i)
	{
		BoundableList* inner = (*verticalSlicesV)[i];
		delete inner;
	}

	return ret;
}