示例#1
0
/* Test the method 'partialWithin'*/
TEST(Boundary, test_method_partialWithin) {
	Boundary *bound = new Boundary(1,2,3,6);
	EXPECT_TRUE(bound->partialWithin(Boundary(1,2,1,2)));
	EXPECT_FALSE(bound->partialWithin(Boundary(10,17,13,16)));
	EXPECT_TRUE(bound->partialWithin(Boundary(1,2,3,6)));	
	EXPECT_TRUE(bound->partialWithin(Boundary(4,2,5,7),1));
}
bool
PCPolyContainer::insert(const std::string& id, Polygon* poly,
                        int layer, bool ignorePruning) {
    // check whether the polygon lies within the wished area
    //  - if such an area was given
    if (myDoPrune && !ignorePruning) {
        Boundary b = poly->getShape().getBoxBoundary();
        if (!b.partialWithin(myPruningBoundary)) {
            delete poly;
            return false;
        }
    }
    // check whether the polygon was named to be a removed one
    if (find(myRemoveByNames.begin(), myRemoveByNames.end(), id) != myRemoveByNames.end()) {
        delete poly;
        return false;
    }
    //
    PolyCont::iterator i = myPolyCont.find(id);
    if (i != myPolyCont.end()) {
        WRITE_ERROR("Polygon '" + id + "' could not be added.");
        delete poly;
        return false;
    }
    myPolyCont[id] = poly;
    myPolyLayerMap[poly] = layer;
    return true;
}
示例#3
0
bool
PCPolyContainer::add(SUMOPolygon* poly, bool ignorePruning) {
    // check whether the polygon lies within the wished area
    //  - if such an area was given
    if (myDoPrune && !ignorePruning) {
        Boundary b = poly->getShape().getBoxBoundary();
        if (!b.partialWithin(myPruningBoundary)) {
            delete poly;
            return false;
        }
    }
    // check whether the polygon was named to be a removed one
    if (find(myRemoveByNames.begin(), myRemoveByNames.end(), poly->getID()) != myRemoveByNames.end()) {
        delete poly;
        return false;
    }
    return ShapeContainer::add(poly);
}