コード例 #1
0
void
NIVissimDistrictConnection::dict_BuildDistrictNodes(NBDistrictCont& dc,
        NBNodeCont& nc) {
    for (std::map<int, std::vector<int> >::iterator k = myDistrictsConnections.begin(); k != myDistrictsConnections.end(); k++) {
        // get the connections
        const std::vector<int>& connections = (*k).second;
        // retrieve the current district
        std::string dsid = toString<int>((*k).first);
        NBDistrict* district = new NBDistrict(dsid);
        dc.insert(district);
        // compute the middle of the district
        PositionVector pos;
        for (std::vector<int>::const_iterator j = connections.begin(); j != connections.end(); j++) {
            NIVissimDistrictConnection* c = dictionary(*j);
            pos.push_back(c->geomPosition());
        }
        Position distCenter = pos.getPolygonCenter();
        if (connections.size() == 1) { // !!! ok, ok, maybe not the best way just to add an offset
            distCenter.add(10, 10);
        }
        district->setCenter(distCenter);
        // build the node
        std::string id = "District" + district->getID();
        NBNode* districtNode =
            new NBNode(id, district->getPosition(), district);
        if (!nc.insert(districtNode)) {
            throw 1;
        }
    }
}
コード例 #2
0
NBNode*
NIImporter_VISUM::buildDistrictNode(const std::string& id, NBNode* dest,
                                    bool isSource) {
    // get the district
    NBDistrict* dist = myNetBuilder.getDistrictCont().retrieve(id);
    if (dist == 0) {
        return 0;
    }
    // build the id
    std::string nid;
    nid = id + "-" + dest->getID();
    if (!isSource) {
        nid = "-" + nid;
    }
    // insert the node
    if (!myNetBuilder.getNodeCont().insert(nid, dist->getPosition())) {
        WRITE_ERROR("Could not build connector node '" + nid + "'.");
    }
    // return the node
    return myNetBuilder.getNodeCont().retrieve(nid);
}