public static double getAngleOfSection(Survey survey, Station station) { int numIncomingLegs = station == survey.getOrigin() ? 0 : 1; int numOutgoingLegs = station.getConnectedOnwardLegs().size(); double angle; if (numIncomingLegs == 1 && numOutgoingLegs == 1) { double incomingAzimuth = getIncomingAzimuth(survey, station); double outgoingAzimuth = getOutgoingAzimuth(station); angle = (incomingAzimuth + outgoingAzimuth) / 2; } else if (numIncomingLegs == 1) { // just consider the incoming leg (end of a passage or, lots of ways on) double incomingAzimuth = getIncomingAzimuth(survey, station); angle = incomingAzimuth; } else if (numOutgoingLegs == 1) { // just consider the outgoing leg (must be doing X-section at the origin) double outgoingAzimuth = getOutgoingAzimuth(station); angle = outgoingAzimuth; } else { // at the origin with no or lots of outgoing legs?? No idea.... angle = 0; } return angle; }
private static double getOutgoingAzimuth(Station station) { return station.getConnectedOnwardLegs().get(0).getAzimuth(); }