There's a saying in NYC:
"If you're pregnant or elderly, you won't get a seat. But, if you smell bad, you can get a whole subway car."
Sadly, the number of (homeless, usually) smelly people found in the NYC subway is increasing. Shulchan Aruch O.C. 79:1 states that one needs to distance himself 4 amot from excrement. 79:8 says to distance oneself from smelly garbage. Most of the smelly people on the subway smell from B.O.; possibly from urine; possibly from alcohol and possibly from cigarette or "weed" smoke. It's neither of the above. Thus, I'm not sure if these rules apply to any type of these foul odors, and I couldn't infer that these apply to even a person that smells from excrement rather than excrement itself that came out of the person. (Some of them smell like garbage, BTW, but I wouldn't know if they smell from garbage.)
In many of the NYC subway cars, you cannot pass from one car to the next; the doors are locked. Let's say someone was davening, and a smelly person entered the subway car. Can he continue davening?
Thanks to @WhyEnBe who states that 4 amot = 8-10 feet. A NYC subway car is significantly longer than this. Technically, one could be sitting more than 4 amot away from the smelly person. However, as implied by my opening paragraph, the bad smell occupies the entire car, typically. So, I'm not sure if the halacha also applies to source of the bad smell being there regardless of the distance you may be from its source.
1/8/18 - Adding to this - Typical NYC subway elevators also smell from urine. Can one daven in there?