void GNEDetectorE2::moveGeometry(const Position& offset) { // Calculate new position using old position Position newPosition = myMove.originalViewPosition; newPosition.add(offset); // filtern position using snap to active grid newPosition = myViewNet->snapToActiveGrid(newPosition); double offsetLane = getLaneParents().front()->getGeometry().shape.nearest_offset_to_point2D(newPosition, false) - getLaneParents().front()->getGeometry().shape.nearest_offset_to_point2D(myMove.originalViewPosition, false); // move geometry depending of number of lanes if (getLaneParents().size() == 1) { // calculate new position over lane double newPositionOverLane = parse<double>(myMove.firstOriginalLanePosition) + offsetLane; // obtain lane length double laneLenght = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength() * getLane()->getLengthGeometryFactor(); if (newPositionOverLane < 0) { myPositionOverLane = 0; } else if (newPositionOverLane + myLength > laneLenght) { myPositionOverLane = laneLenght - myLength; } else { myPositionOverLane = newPositionOverLane; } } else { // calculate new start and end positions double newStartPosition = parse<double>(myMove.firstOriginalLanePosition) + offsetLane; double newEndPosition = parse<double>(myMove.secondOriginalPosition) + offsetLane; // change start and end position of E2 detector ONLY if both extremes aren't overpassed if ((newStartPosition >= 0) && (newStartPosition <= getLaneParents().front()->getLaneShapeLength()) && (newEndPosition >= 0) && (newEndPosition <= getLaneParents().back()->getLaneShapeLength())) { myPositionOverLane = newStartPosition; myEndPositionOverLane = newEndPosition; } } // Update geometry updateGeometry(); }
void GNEStop::updateGeometry(bool updateGrid) { // first check if object has to be removed from grid (SUMOTree) if (updateGrid) { myViewNet->getNet()->removeGLObjectFromGrid(this); } // Clear all containers myGeometry.clearGeometry(); //only update Stops over lanes, because other uses the geometry of stopping place parent if (getLaneParents().size() > 0) { // Cut shape using as delimitators fixed start position and fixed end position myGeometry.shape = getLaneParents().front()->getShape().getSubpart(getStartGeometryPositionOverLane(), getEndGeometryPositionOverLane()); // Get calculate lenghts and rotations myGeometry.calculateShapeRotationsAndLengths(); } else if (getAdditionalParents().size() > 0) { // copy geometry of additional myGeometry.shape = getAdditionalParents().at(0)->getAdditionalGeometry().shape; myGeometry.shapeLengths = getAdditionalParents().at(0)->getAdditionalGeometry().shapeLengths; myGeometry.shapeRotations = getAdditionalParents().at(0)->getAdditionalGeometry().shapeRotations; } // last step is to check if object has to be added into grid (SUMOTree) again if (updateGrid) { myViewNet->getNet()->addGLObjectIntoGrid(this); } }
void GNEDetectorE1::updateGeometry() { // Clear all containers myGeometry.clearGeometry(); // obtain position over lane myGeometry.shape.push_back(getPositionInView()); // Obtain first position Position f = myGeometry.shape[0] - Position(1, 0); // Obtain next position Position s = myGeometry.shape[0] + Position(1, 0); // Save rotation (angle) of the vector constructed by points f and s myGeometry.shapeRotations.push_back(getLaneParents().front()->getGeometry().shape.rotationDegreeAtOffset(getGeometryPositionOverLane()) * -1); // Set block icon position myBlockIcon.position = myGeometry.shape.getLineCenter(); // Set offset of the block icon myBlockIcon.offset = Position(-1, 0); // Set block icon rotation, and using their rotation for logo myBlockIcon.setRotation(getLaneParents().front()); }
void GNEPOI::updateGeometry() { if (getLaneParents().size() > 0) { // obtain fixed position over lane double fixedPositionOverLane = myPosOverLane > getLaneParents().at(0)->getLaneShapeLength() ? getLaneParents().at(0)->getLaneShapeLength() : myPosOverLane < 0 ? 0 : myPosOverLane; // set new position regarding to lane set(getLaneParents().at(0)->getGeometry().shape.positionAtOffset(fixedPositionOverLane * getLaneParents().at(0)->getLengthGeometryFactor(), -myPosLat)); } }
Position GNECalibrator::getPositionInView() const { PositionVector shape = (getLaneParents().size() > 0) ? getLaneParents().front()->getGeometry().shape : getEdgeParents().front()->getLanes().at(0)->getGeometry().shape; if (myPositionOverLane < 0) { return shape.front(); } else if (myPositionOverLane > shape.length()) { return shape.back(); } else { return shape.positionAtOffset(myPositionOverLane); } }
void GNEPOI::writeShape(OutputDevice& device) { if (getLaneParents().size() > 0) { // obtain fixed position over lane double fixedPositionOverLane = myPosOverLane > getLaneParents().at(0)->getGeometry().shape.length() ? getLaneParents().at(0)->getGeometry().shape.length() : myPosOverLane < 0 ? 0 : myPosOverLane; // write POILane using POI::writeXML writeXML(device, false, 0, getLaneParents().at(0)->getID(), fixedPositionOverLane, myPosLat); } else { writeXML(device, myGeo); } }
std::string GNECalibrator::getParentName() const { // get parent name depending of we have a edge or a lane if (getLaneParents().size() > 0) { return getLaneParents().front()->getMicrosimID(); } else if (getEdgeParents().size() > 0) { return getEdgeParents().front()->getLanes().at(0)->getMicrosimID(); } else { throw ProcessError("Both myEdge and myLane aren't defined"); } }
std::string GNEStop::getParentName() const { if (getDemandElementParents().size() > 0) { return getDemandElementParents().front()->getID(); } else if (getAdditionalParents().size() > 0) { return getAdditionalParents().front()->getID(); } else if (getLaneParents().size() > 0) { return getLaneParents().front()->getID(); } else { throw ProcessError("Invalid parent"); } }
double GNEStop::getEndGeometryPositionOverLane() const { if (parametersSet & STOP_END_SET) { double fixedPos = startPos; const double len = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(); if (fixedPos < 0) { fixedPos += len; } return fixedPos * getLaneParents().front()->getLengthGeometryFactor(); } else { return 0; } }
void GNEDetectorE1::moveGeometry(const Position& offset) { // Calculate new position using old position Position newPosition = myMove.originalViewPosition; newPosition.add(offset); // filtern position using snap to active grid newPosition = myViewNet->snapToActiveGrid(newPosition); const bool storeNegative = myPositionOverLane < 0; myPositionOverLane = getLaneParents().front()->getGeometry().shape.nearest_offset_to_point2D(newPosition, false); if (storeNegative) { myPositionOverLane -= getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(); } // Update geometry updateGeometry(); }
Position GNEAccess::getPositionInView() const { if (!canParse<double>(myPositionOverLane)) { return getLaneParents().front()->getGeometry().shape.front(); } else { double posOverLane = parse<double>(myPositionOverLane); if (posOverLane < 0) { return getLaneParents().front()->getGeometry().shape.front(); } else if (posOverLane > getLaneParents().front()->getGeometry().shape.length()) { return getLaneParents().front()->getGeometry().shape.back(); } else { return getLaneParents().front()->getGeometry().shape.positionAtOffset(posOverLane); } } }
std::string GNEAccess::getAttribute(SumoXMLAttr key) const { switch (key) { case SUMO_ATTR_ID: return getAdditionalID(); case SUMO_ATTR_LANE: return getLaneParents().front()->getID(); case SUMO_ATTR_POSITION: return toString(myPositionOverLane); case SUMO_ATTR_LENGTH: return toString(myLength); case SUMO_ATTR_FRIENDLY_POS: return toString(myFriendlyPosition); case GNE_ATTR_BLOCK_MOVEMENT: return toString(myBlockMovement); case GNE_ATTR_PARENT: return getAdditionalParents().at(0)->getID(); case GNE_ATTR_SELECTED: return toString(isAttributeCarrierSelected()); case GNE_ATTR_GENERIC: return getGenericParametersStr(); default: throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'"); } }
void GNECalibrator::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // iterate over every Calibrator symbol for (int i = 0; i < (int)myGeometry.shape.size(); ++i) { const Position& pos = myGeometry.shape[i]; double rot = myGeometry.shapeRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), getType()); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(exaggeration, exaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(RGBColor(255, 204, 0)); } // base glBegin(GL_TRIANGLES); glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); // draw text if isn't being drawn for selecting if ((s.scale * exaggeration >= 1.) && !s.drawForSelecting) { // set color depending of selection status RGBColor textColor = drawUsingSelectColor() ? s.selectionColor : RGBColor::BLACK; // draw "C" GLHelper::drawText("C", Position(0, 1.5), 0.1, 3, textColor, 180); // draw "edge" or "lane " if (getLaneParents().size() > 0) { GLHelper::drawText("lane", Position(0, 3), .1, 1, textColor, 180); } else if (getEdgeParents().size() > 0) { GLHelper::drawText("edge", Position(0, 3), .1, 1, textColor, 180); } else { throw ProcessError("Both myEdge and myLane aren't defined"); } } glPopMatrix(); // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), pos, 2.8, 6, rot, 0, 3); } } // draw name drawName(getPositionInView(), s.scale, s.addName); // pop name glPopName(); }
std::string GNECalibrator::getAttribute(SumoXMLAttr key) const { switch (key) { case SUMO_ATTR_ID: return getAdditionalID(); case SUMO_ATTR_EDGE: return getEdgeParents().front()->getID(); case SUMO_ATTR_LANE: return getLaneParents().front()->getID(); case SUMO_ATTR_POSITION: return toString(myPositionOverLane); case SUMO_ATTR_FREQUENCY: return toString(myFrequency); case SUMO_ATTR_NAME: return myAdditionalName; case SUMO_ATTR_OUTPUT: return myOutput; case SUMO_ATTR_ROUTEPROBE: return myRouteProbe; case GNE_ATTR_SELECTED: return toString(isAttributeCarrierSelected()); case GNE_ATTR_GENERIC: return getGenericParametersStr(); default: throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'"); } }
std::string GNEDetectorE1::getAttribute(SumoXMLAttr key) const { switch (key) { case SUMO_ATTR_ID: return getAdditionalID(); case SUMO_ATTR_LANE: return getLaneParents().front()->getID(); case SUMO_ATTR_POSITION: return toString(myPositionOverLane); case SUMO_ATTR_FREQUENCY: return toString(myFreq); case SUMO_ATTR_NAME: return myAdditionalName; case SUMO_ATTR_FILE: return myFilename; case SUMO_ATTR_VTYPES: return myVehicleTypes; case SUMO_ATTR_FRIENDLY_POS: return toString(myFriendlyPosition); case GNE_ATTR_BLOCK_MOVEMENT: return toString(myBlockMovement); case GNE_ATTR_SELECTED: return toString(isAttributeCarrierSelected()); case GNE_ATTR_GENERIC: return getGenericParametersStr(); default: throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'"); } }
void GNEDetectorE2::fixAdditionalProblem() { if (getLaneParents().size() == 1) { // obtain position and lenght double newPositionOverLane = myPositionOverLane; double newLength = myLength; // fix pos and lenght using fixE2DetectorPosition GNEAdditionalHandler::fixE2DetectorPosition(newPositionOverLane, newLength, getLaneParents().at(0)->getParentEdge().getNBEdge()->getFinalLength(), true); // set new position and length setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myViewNet->getUndoList()); setAttribute(SUMO_ATTR_LENGTH, toString(myLength), myViewNet->getUndoList()); } else { if (!myE2valid) { // build connections between all consecutive lanes bool foundConnection = true; int i = 0; // iterate over all lanes, and stop if myE2valid is false while (i < ((int)getLaneParents().size() - 1)) { // change foundConnection to false foundConnection = false; // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again for (auto j : getLaneParents().at(i)->getParentEdge().getGNEConnections()) { if (j->getLaneFrom() == getLaneParents().at(i) && j->getLaneTo() == getLaneParents().at(i + 1)) { foundConnection = true; } } // if connection wasn't found if (!foundConnection) { // create new connection manually NBEdge::Connection newCon(getLaneParents().at(i)->getIndex(), getLaneParents().at(i + 1)->getParentEdge().getNBEdge(), getLaneParents().at(i + 1)->getIndex()); // allow to undo creation of new lane myViewNet->getUndoList()->add(new GNEChange_Connection(&getLaneParents().at(i)->getParentEdge(), newCon, false, true), true); } // update lane iterator i++; } } else { // declare new position double newPositionOverLane = myPositionOverLane; // fix pos and lenght checkAndFixDetectorPosition GNEAdditionalHandler::checkAndFixDetectorPosition(newPositionOverLane, getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(), true); // set new position setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myViewNet->getUndoList()); // declare new end position double newEndPositionOverLane = myEndPositionOverLane; // fix pos and lenght checkAndFixDetectorPosition GNEAdditionalHandler::checkAndFixDetectorPosition(newEndPositionOverLane, getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength(), true); // set new position setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myViewNet->getUndoList()); } } }
bool GNECalibrator::isValid(SumoXMLAttr key, const std::string& value) { switch (key) { case SUMO_ATTR_ID: return isValidAdditionalID(value); case SUMO_ATTR_EDGE: if (myViewNet->getNet()->retrieveEdge(value, false) != nullptr) { return true; } else { return false; } case SUMO_ATTR_LANE: if (myViewNet->getNet()->retrieveLane(value, false) != nullptr) { return true; } else { return false; } case SUMO_ATTR_POSITION: if (canParse<double>(value)) { // obtain position and check if is valid double newPosition = parse<double>(value); PositionVector shape = (getLaneParents().size() > 0) ? getLaneParents().front()->getGeometry().shape : getEdgeParents().front()->getLanes().at(0)->getGeometry().shape; if ((newPosition < 0) || (newPosition > shape.length())) { return false; } else { return true; } } else { return false; } case SUMO_ATTR_FREQUENCY: return (canParse<double>(value) && parse<double>(value) >= 0); case SUMO_ATTR_NAME: return SUMOXMLDefinitions::isValidAttribute(value); case SUMO_ATTR_OUTPUT: return SUMOXMLDefinitions::isValidFilename(value); case SUMO_ATTR_ROUTEPROBE: return SUMOXMLDefinitions::isValidNetID(value); case GNE_ATTR_SELECTED: return canParse<bool>(value); case GNE_ATTR_GENERIC: return isGenericParametersValid(value); default: throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'"); } }
void GNEAccess::updateGeometry() { // Clear all containers myGeometry.clearGeometry(); // Get shape of lane parent myGeometry.shape = getLaneParents().front()->getGeometry().shape; // set start position double fixedPositionOverLane; if (!canParse<double>(myPositionOverLane)) { fixedPositionOverLane = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(); } else if (parse<double>(myPositionOverLane) < 0) { fixedPositionOverLane = 0; } else if (parse<double>(myPositionOverLane) > getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength()) { fixedPositionOverLane = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(); } else { fixedPositionOverLane = parse<double>(myPositionOverLane); } // obtain position myGeometry.shape[0] = getLaneParents().front()->getGeometry().shape.positionAtOffset(fixedPositionOverLane * getLaneParents().front()->getLengthGeometryFactor()); // Save rotation (angle) of the vector constructed by points f and s myGeometry.shapeRotations.push_back(getLaneParents().front()->getGeometry().shape.rotationDegreeAtOffset(fixedPositionOverLane) * -1); // Set block icon position myBlockIcon.position = myGeometry.shape.getLineCenter(); // Set offset of the block icon myBlockIcon.offset = Position(-1, 0); // Set block icon rotation, and using their rotation for logo myBlockIcon.setRotation(getLaneParents().front()); }
void GNEPOI::moveGeometry(const Position& oldPos, const Position& offset) { if (!myBlockMovement) { // Calculate new position using old position Position newPosition = oldPos; newPosition.add(offset); // filtern position using snap to active grid newPosition = myNet->getViewNet()->snapToActiveGrid(newPosition); // set position depending of POI Type if (getLaneParents().size() > 0) { myPosOverLane = getLaneParents().at(0)->getGeometry().shape.nearest_offset_to_point2D(newPosition, false); } else { set(newPosition); } // Update geometry updateGeometry(); } }
void GNEDetectorE1::fixAdditionalProblem() { // declare new position double newPositionOverLane = myPositionOverLane; // fix pos and lenght checkAndFixDetectorPosition GNEAdditionalHandler::checkAndFixDetectorPosition(newPositionOverLane, getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(), true); // set new position setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myViewNet->getUndoList()); }
bool GNEDetectorE1::isAdditionalValid() const { // with friendly position enabled position are "always fixed" if (myFriendlyPosition) { return true; } else { return fabs(myPositionOverLane) <= getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(); } }
void GNEStop::moveGeometry(const Position& offset) { // only move if at leats start or end positions is defined if ((getLaneParents().size() > 0) && ((parametersSet & STOP_START_SET) || (parametersSet & STOP_END_SET))) { // Calculate new position using old position Position newPosition = myMove.originalViewPosition; newPosition.add(offset); // filtern position using snap to active grid newPosition = myViewNet->snapToActiveGrid(newPosition); double offsetLane = getLaneParents().front()->getShape().nearest_offset_to_point2D(newPosition, false) - getLaneParents().front()->getShape().nearest_offset_to_point2D(myMove.originalViewPosition, false); // check if both position has to be moved if ((parametersSet & STOP_START_SET) && (parametersSet & STOP_END_SET)) { // calculate stoppingPlace lenght and lane lenght (After apply geometry factor) double stoppingPlaceLenght = fabs(parse<double>(myMove.secondOriginalPosition) - parse<double>(myMove.firstOriginalLanePosition)); double laneLengt = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength() * getLaneParents().front()->getLengthGeometryFactor(); // avoid changing stopping place's lenght if ((parse<double>(myMove.firstOriginalLanePosition) + offsetLane) < 0) { startPos = 0; endPos = stoppingPlaceLenght; std::cout << "A" << std::endl; } else if ((parse<double>(myMove.secondOriginalPosition) + offsetLane) > laneLengt) { startPos = laneLengt - stoppingPlaceLenght; endPos = laneLengt; std::cout << "B" << std::endl; } else { startPos = parse<double>(myMove.firstOriginalLanePosition) + offsetLane; endPos = parse<double>(myMove.secondOriginalPosition) + offsetLane; std::cout << toString(offsetLane) << " | " << toString(startPos) << " " << toString(endPos) << std::endl; } } else { // check if start position must be moved if ((parametersSet & STOP_START_SET)) { startPos = parse<double>(myMove.firstOriginalLanePosition) + offsetLane; } // check if start position must be moved if ((parametersSet & STOP_END_SET)) { endPos = parse<double>(myMove.secondOriginalPosition) + offsetLane; } } // Update geometry updateGeometry(false); } }
void GNEDetectorE2::checkE2MultilaneIntegrity() { // we assume that E2 is valid myE2valid = true; int i = 0; // iterate over all lanes, and stop if myE2valid is false while (i < ((int)getLaneParents().size() - 1) && myE2valid) { // set myE2valid to false myE2valid = false; // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again for (auto j : getLaneParents().at(i)->getParentEdge().getGNEConnections()) { if (j->getLaneFrom() == getLaneParents().at(i) && j->getLaneTo() == getLaneParents().at(i + 1)) { myE2valid = true; } } // update iterator i++; } }
bool GNEPOI::isValid(SumoXMLAttr key, const std::string& value) { switch (key) { case SUMO_ATTR_ID: return SUMOXMLDefinitions::isValidNetID(value) && (myNet->retrievePOI(value, false) == nullptr); case SUMO_ATTR_COLOR: return canParse<RGBColor>(value); case SUMO_ATTR_LANE: return (myNet->retrieveLane(value, false) != nullptr); case SUMO_ATTR_POSITION: if (getLaneParents().size() > 0) { return canParse<double>(value); } else { return canParse<Position>(value); } case SUMO_ATTR_POSITION_LAT: return canParse<double>(value); case SUMO_ATTR_GEOPOSITION: { return canParse<Position>(value); } case SUMO_ATTR_GEO: return canParse<bool>(value); case SUMO_ATTR_TYPE: return true; case SUMO_ATTR_LAYER: if (value == "default") { return true; } else { return canParse<double>(value); } case SUMO_ATTR_IMGFILE: if (value == "") { return true; } else { // check that image can be loaded return GUITexturesHelper::getTextureID(value) != -1; } case SUMO_ATTR_RELATIVEPATH: return canParse<bool>(value); case SUMO_ATTR_WIDTH: return canParse<double>(value) && (parse<double>(value) >= 0); case SUMO_ATTR_HEIGHT: return canParse<double>(value) && (parse<double>(value) >= 0); case SUMO_ATTR_ANGLE: return canParse<double>(value); case GNE_ATTR_BLOCK_MOVEMENT: return canParse<bool>(value); case GNE_ATTR_SELECTED: return canParse<bool>(value); case GNE_ATTR_GENERIC: return isGenericParametersValid(value); default: throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'"); } }
std::string GNEDetectorE2::getAdditionalProblem() const { // declare variable for error position std::string errorFirstLanePosition, separator, errorLastLanePosition; if (getLaneParents().size() == 1) { // check positions over lane if (myPositionOverLane < 0) { errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0"); } if (myPositionOverLane > getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength()) { errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length"); } if ((myPositionOverLane + myLength) > getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength()) { errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " + " + toString(SUMO_ATTR_LENGTH) + " > lanes's length"); } } else { if (myE2valid) { // check positions over first lane if (myPositionOverLane < 0) { errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0"); } if (myPositionOverLane > getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength()) { errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length"); } // check positions over last lane if (myEndPositionOverLane < 0) { errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0"); } if (myEndPositionOverLane > getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength()) { errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " > lanes's length"); } } else { errorFirstLanePosition = "lanes aren't consecutives"; } } // check separator if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) { separator = " and "; } // return error message return errorFirstLanePosition + separator + errorLastLanePosition; }
void GNEPOI::commitGeometryMoving(const Position& oldPos, GNEUndoList* undoList) { if (!myBlockMovement) { // restore original Position before moving (to avoid problems in GL Tree) Position myNewPosition(*this); set(oldPos); // commit new position allowing undo/redo if (getLaneParents().size() > 0) { // restore old position before commit new position double originalPosOverLane = getLaneParents().at(0)->getGeometry().shape.nearest_offset_to_point2D(oldPos, false); undoList->p_begin("position of " + getTagStr()); undoList->p_add(new GNEChange_Attribute(this, myNet, SUMO_ATTR_POSITION, toString(myPosOverLane), true, toString(originalPosOverLane))); undoList->p_end(); } else { undoList->p_begin("position of " + getTagStr()); undoList->p_add(new GNEChange_Attribute(this, myNet, SUMO_ATTR_POSITION, toString(myNewPosition), true, toString(oldPos))); undoList->p_end(); } } }
void GNEAccess::moveGeometry(const Position& offset) { // Calculate new position using old position Position newPosition = myMove.originalViewPosition; newPosition.add(offset); // filtern position using snap to active grid newPosition = myViewNet->snapToActiveGrid(newPosition); myPositionOverLane = toString(getLaneParents().front()->getGeometry().shape.nearest_offset_to_point2D(newPosition, false)); // Update geometry updateGeometry(); }
void GNECalibrator::updateGeometry() { // Clear all containers myGeometry.clearGeometry(); // get shape depending of we have a edge or a lane if (getLaneParents().size() > 0) { // Get shape of lane parent myGeometry.shape.push_back(getLaneParents().front()->getGeometry().shape.positionAtOffset(myPositionOverLane)); // Save rotation (angle) of the vector constructed by points f and s myGeometry.shapeRotations.push_back(getLaneParents().front()->getGeometry().shape.rotationDegreeAtOffset(myPositionOverLane) * -1); } else if (getEdgeParents().size() > 0) { for (auto i : getEdgeParents().front()->getLanes()) { // Get shape of lane parent myGeometry.shape.push_back(i->getGeometry().shape.positionAtOffset(myPositionOverLane)); // Save rotation (angle) of the vector constructed by points f and s myGeometry.shapeRotations.push_back(getEdgeParents().front()->getLanes().at(0)->getGeometry().shape.rotationDegreeAtOffset(myPositionOverLane) * -1); } } else { throw ProcessError("Both myEdge and myLane aren't defined"); } }
std::string GNEDetectorE1::getAdditionalProblem() const { // declare variable for error position std::string errorPosition; const double len = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength(); // check positions over lane if (myPositionOverLane < -len) { errorPosition = (toString(SUMO_ATTR_POSITION) + " < 0"); } if (myPositionOverLane > len) { errorPosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length"); } return errorPosition; }
void GNEStop::commitGeometryMoving(GNEUndoList* undoList) { // only commit geometry moving if at leats start or end positions is defined if ((getLaneParents().size() > 0) && ((parametersSet & STOP_START_SET) || (parametersSet & STOP_END_SET))) { undoList->p_begin("position of " + getTagStr()); if (parametersSet & STOP_START_SET) { undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), SUMO_ATTR_STARTPOS, toString(startPos), true, myMove.firstOriginalLanePosition)); } if (parametersSet & STOP_END_SET) { undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), SUMO_ATTR_ENDPOS, toString(endPos), true, myMove.secondOriginalPosition)); } undoList->p_end(); } }