@ SuppressWarnings ( "checkstyle:nestedifdepth" ) public boolean putHaltOnRoad ( BusItineraryHalt halt , RoadSegment road ) { if ( contains ( halt ) ) { final BusStop stop = halt . getBusStop ( ) ; if ( stop != null ) { final Point2d stopPosition = stop . getPosition2D ( ) ; if ( stopPosition != null ) { final int idx = indexOf ( road ) ; if ( idx >= 0 ) { final Point1d pos = road . getNearestPosition ( stopPosition ) ; if ( pos != null ) { halt . setRoadSegmentIndex ( idx ) ; halt . setPositionOnSegment ( pos . getCurvilineCoordinate ( ) ) ; halt . checkPrimitiveValidity ( ) ; fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ITINERARY_CHANGED , null , - 1 , "shape" , //$NON-NLS-1$ null , null ) ) ; checkPrimitiveValidity ( ) ; return true ; } } return false ; } } } return true ; }
Put the given bus itinerary halt on the nearest point on road .