CrossSectioner { 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) { double incomingAzimuth = getIncomingAzimuth(survey, station); angle = incomingAzimuth; } else if (numOutgoingLegs == 1) { double outgoingAzimuth = getOutgoingAzimuth(station); angle = outgoingAzimuth; } else { angle = 0; } return angle; }  static CrossSection section(Survey survey, final Station station); static double getAngleOfSection(Survey survey, Station station);  }
@Test public void testStraightNorthCrossSection() { Survey testSurvey = BasicTestSurveyCreator.createStraightNorth(); Station s2 = testSurvey.getStationByName("2"); double angle = CrossSectioner.getAngleOfSection(testSurvey, s2); Assert.assertEquals(0.0, angle); }
@Test public void testStraightSouthCrossSection() { Survey testSurvey = BasicTestSurveyCreator.createStraightSouth(); Station s2 = testSurvey.getStationByName("2"); double angle = CrossSectioner.getAngleOfSection(testSurvey, s2); Assert.assertEquals(180.0, angle); }