Пример #1
0
std::vector<SUMOReal>
PositionVector::distances(const PositionVector& s, bool perpendicular) const {
    std::vector<SUMOReal> ret;
    const_iterator i;
    for (i = begin(); i != end(); i++) {
        const SUMOReal dist = s.distance(*i, perpendicular);
        if (dist != GeomHelper::INVALID_OFFSET) {
            ret.push_back(dist);
        }
    }
    for (i = s.begin(); i != s.end(); i++) {
        const SUMOReal dist = distance(*i, perpendicular);
        if (dist != GeomHelper::INVALID_OFFSET) {
            ret.push_back(dist);
        }
    }
    return ret;
}
Пример #2
0
void
NIImporter_SUMO::addJunction(const SUMOSAXAttributes& attrs) {
    // get the id, report an error if not given or empty...
    bool ok = true;
    std::string id = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok);
    if (!ok) {
        return;
    }
    if (id[0] == ':') { // internal node
        return;
    }
    SumoXMLNodeType type = NODETYPE_UNKNOWN;
    std::string typeS = attrs.getStringReporting(SUMO_ATTR_TYPE, id.c_str(), ok);
    if (SUMOXMLDefinitions::NodeTypes.hasString(typeS)) {
        type = SUMOXMLDefinitions::NodeTypes.get(typeS);
        if (type == NODETYPE_DEAD_END_DEPRECATED) { // patch legacy type
            type = NODETYPE_DEAD_END;
        }
    } else {
        WRITE_WARNING("Unknown node type '" + typeS + "' for junction '" + id + "'.");
    }
    Position pos = readPosition(attrs, id, ok);
    NILoader::transformCoordinates(pos, true, myLocation);
    // the network may have been built with the option "plain.keep-edge-shape" this
    // makes accurate reconstruction of legacy networks impossible. We ought to warn about this
    std::string shapeS = attrs.getStringReporting(SUMO_ATTR_SHAPE, id.c_str(), ok, false);
    if (shapeS != "") {
        PositionVector shape = GeomConvHelper::parseShapeReporting(
                                   shapeS, attrs.getObjectType(), id.c_str(), ok, false);
        shape.push_back_noDoublePos(shape[0]); // need closed shape
        if (!shape.around(pos) && shape.distance(pos) > 1) { // MAGIC_THRESHOLD
            // WRITE_WARNING("Junction '" + id + "': distance between pos and shape is " + toString(shape.distance(pos)));
            mySuspectKeepShape = true;
        }
    }
    NBNode* node = new NBNode(id, pos, type);
    if (!myNodeCont.insert(node)) {
        WRITE_ERROR("Problems on adding junction '" + id + "'.");
        delete node;
        return;
    }
}
Пример #3
0
void
NIImporter_SUMO::addJunction(const SUMOSAXAttributes& attrs) {
    // get the id, report an error if not given or empty...
    bool ok = true;
    std::string id = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok);
    if (!ok) {
        return;
    }
    if (id[0] == ':') { // internal node
        return;
    }
    SumoXMLNodeType type = attrs.getNodeType(ok);
    if (ok) {
        if (type == NODETYPE_DEAD_END_DEPRECATED) { // patch legacy type
            type = NODETYPE_DEAD_END;
        }
    } else {
        WRITE_WARNING("Unknown node type for junction '" + id + "'.");
    }
    Position pos = readPosition(attrs, id, ok);
    NILoader::transformCoordinates(pos, true, myLocation);
    // the network may have non-default edge geometry.
    // accurate reconstruction of legacy networks is not possible. We ought to warn about this
    if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
        PositionVector shape = attrs.getShapeReporting(SUMO_ATTR_SHAPE, id.c_str(), ok, true);
        if (shape.size() > 0) {
            shape.push_back_noDoublePos(shape[0]); // need closed shape
            if (!shape.around(pos) && shape.distance(pos) > 1) { // MAGIC_THRESHOLD
                // WRITE_WARNING("Junction '" + id + "': distance between pos and shape is " + toString(shape.distance(pos)));
                mySuspectKeepShape = true;
            }
        }
    }
    NBNode* node = new NBNode(id, pos, type);
    if (!myNodeCont.insert(node)) {
        WRITE_ERROR("Problems on adding junction '" + id + "'.");
        delete node;
        return;
    }
}