コード例 #1
0
ファイル: NodeBase.cpp プロジェクト: asapnet/geos
/*public*/
bool
NodeBase::remove(const Envelope* itemEnv, void* item)
{
	// use envelope to restrict nodes scanned
	if (! isSearchMatch(itemEnv)) return false;

	bool found = false;
	for (int i = 0; i < 4; i++) {
		if (subnode[i] != NULL) {
			found = subnode[i]->remove(itemEnv, item);
			if (found) {
				// trim subtree if empty
				if (subnode[i]->isPrunable())
				subnode[i] = NULL;
				break;
			}
		}
	}
	// if item was found lower down, don't need to search for it here
	if (found) return found;

	// otherwise, try and remove the item from the list of items
	// in this node
	vector<void*>::iterator foundIter = 
		find(items->begin(), items->end(), item);
	if ( foundIter != items->end() ) {
		items->erase(foundIter);
		return true;
	} else {
		return false;
	}
}
コード例 #2
0
ファイル: NodeBase.cpp プロジェクト: GunioRobot/geos
vector<void*>*
NodeBase::addAllItemsFromOverlapping(Interval *interval,vector<void*> *resultItems)
{
	if (!isSearchMatch(interval))
		return items;
	resultItems->insert(resultItems->end(),items->begin(),items->end());
	for (int i=0;i<2;i++) {
		if (subnode[i]!=NULL) {
			subnode[i]->addAllItemsFromOverlapping(interval,resultItems);
		}
	}
	return items;
}
コード例 #3
0
ファイル: NodeBase.cpp プロジェクト: AvlWx2014/basemap
/*public*/
void
NodeBase::visit(const Envelope* searchEnv, ItemVisitor& visitor)
{
	if (! isSearchMatch(*searchEnv)) return;

	// this node may have items as well as subnodes (since items may not
	// be wholely contained in any single subnode
	visitItems(searchEnv, visitor);

	for (int i = 0; i < 4; i++) {
		if (subnode[i] != NULL) {
			subnode[i]->visit(searchEnv, visitor);
		}
	}
}
コード例 #4
0
ファイル: NodeBase.cpp プロジェクト: asapnet/geos
void
NodeBase::addAllItemsFromOverlapping(const Envelope *searchEnv, vector<void*> *resultItems)
{
	if (!isSearchMatch(searchEnv))
		return;

	//<<TODO:ASSERT?>> Can we assert that this node cannot have both items
	//and subnodes? [Jon Aquino]
	resultItems->insert(resultItems->end(),items->begin(),items->end());
	for(int i=0;i<4;i++) {
		if (subnode[i]!=NULL) {
			subnode[i]->addAllItemsFromOverlapping(searchEnv,resultItems);
		}
	}
}
コード例 #5
0
ファイル: NodeBase.cpp プロジェクト: libgeos/libgeos
/*public*/
void
NodeBase::visit(const Envelope* searchEnv, ItemVisitor& visitor)
{
    if(! isSearchMatch(*searchEnv)) {
        return;
    }

    // this node may have items as well as subnodes (since items may not
    // be wholly contained in any single subnode
    visitItems(searchEnv, visitor);

    for(const auto& subnode : subnodes) {
        if(subnode != nullptr) {
            subnode->visit(searchEnv, visitor);
        }
    }
}
コード例 #6
0
ファイル: NodeBase.cpp プロジェクト: libgeos/libgeos
void
NodeBase::addAllItemsFromOverlapping(const Envelope& searchEnv,
                                     vector<void*>& resultItems) const
{
    if(!isSearchMatch(searchEnv)) {
        return;
    }

    // this node may have items as well as subnodes (since items may not
    // be wholly contained in any single subnode
    resultItems.insert(resultItems.end(), items.begin(), items.end());

    for(const auto& subnode : subnodes) {
        if(subnode != nullptr) {
            subnode->addAllItemsFromOverlapping(searchEnv,
                                                resultItems);
        }
    }
}
コード例 #7
0
ファイル: NodeBase.cpp プロジェクト: AvlWx2014/basemap
void
NodeBase::addAllItemsFromOverlapping(const Envelope& searchEnv,
                                     vector<void*>& resultItems) const
{
	if (!isSearchMatch(searchEnv))
		return;

	// this node may have items as well as subnodes (since items may not
	// be wholely contained in any single subnode
	resultItems.insert(resultItems.end(), items.begin(), items.end());

	for(int i=0; i<4; ++i)
	{
		if ( subnode[i] )
		{
			subnode[i]->addAllItemsFromOverlapping(searchEnv,
			                                       resultItems);
		}
	}
}
コード例 #8
0
ファイル: NodeBase.cpp プロジェクト: libgeos/libgeos
/*public*/
bool
NodeBase::remove(const Envelope* itemEnv, void* item)
{
    // use envelope to restrict nodes scanned
    if(! isSearchMatch(*itemEnv)) {
        return false;
    }

    bool found = false;
    for(auto& subnode : subnodes) {
        if(subnode != nullptr) {
            found = subnode->remove(itemEnv, item);
            if(found) {
                // trim subtree if empty
                if(subnode->isPrunable()) {
                    delete subnode;
                    subnode = nullptr;
                }
                break;
            }
        }
    }
    // if item was found lower down, don't need to search for it here
    if(found) {
        return found;
    }

    // otherwise, try and remove the item from the list of items
    // in this node
    auto foundIter = find(items.begin(), items.end(), item);
    if(foundIter != items.end()) {
        items.erase(foundIter);
        return true;
    }
    else {
        return false;
    }
}