public static boolean isLocationWithin(
			CompoundLocation<Location> location1,
			CompoundLocation<Location> location2) {
		if (location1.getLocations() == null
				|| location2.getLocations() == null) {
			return false;
		}

		Location startFirstLocation = getStartFromLocations(location1);
		Location endFirstLocation = getEndFromLocations(location1);
		Location startSecondLocation = getStartFromLocations(location2);
		Location endSecondLocation = getEndFromLocations(location2);

		if (startFirstLocation != null && endFirstLocation != null
				&& startSecondLocation != null && endSecondLocation != null) {
			if ((startFirstLocation.getBeginPosition() >= startSecondLocation.getBeginPosition())
					&& (endFirstLocation.getEndPosition() <= endSecondLocation.getEndPosition())) {

				/*
				 * tests if the start and end locations being compared are on
				 * the same strand - they need to be for comparison to count.
				 * Need to look at the global complement and the complement of
				 * the inner location as the global complement can "neutralize"
				 * the inner one, so I check that the global complement and
				 * location complement to not match to count as being
				 * complement. I have separated into 2 if statements to try to
				 * keep the code more readable.
				 */
				boolean location1IsComplement = location1.isComplement();
				boolean location2IsComplement = location2.isComplement();

				if (doComplementsMatch(location1IsComplement,
						location2IsComplement, startFirstLocation,
						startSecondLocation)) {

					if (doComplementsMatch(location1IsComplement,
							location2IsComplement, endFirstLocation,
							endSecondLocation)) {
						return true;
					}
				}
			}
		}

		return false;
	}
public static boolean isLocationWithin ( CompoundLocation < Location > location1 , CompoundLocation < Location > location2 ) { if ( location1 . getLocations ( ) == null || location2 . getLocations ( ) == null ) { return false ; } Location startFirstLocation = getStartFromLocations ( location1 ) ; Location endFirstLocation = getEndFromLocations ( location1 ) ; Location startSecondLocation = getStartFromLocations ( location2 ) ; Location endSecondLocation = getEndFromLocations ( location2 ) ; if ( startFirstLocation != null && endFirstLocation != null && startSecondLocation != null && endSecondLocation != null ) { if ( ( startFirstLocation . getBeginPosition ( ) >= startSecondLocation . getBeginPosition ( ) ) && ( endFirstLocation . getEndPosition ( ) <= endSecondLocation . getEndPosition ( ) ) ) { boolean location1IsComplement = location1 . isComplement ( ) ; boolean location2IsComplement = location2 . isComplement ( ) ; if ( doComplementsMatch ( location1IsComplement , location2IsComplement , startFirstLocation , startSecondLocation ) ) { if ( doComplementsMatch ( location1IsComplement , location2IsComplement , endFirstLocation , endSecondLocation ) ) { return true ; } } } } return false ; }
NOTE : this method looks at the extreme boundaries of both locations passed in and regards one as being within
the other if these extremities are contained by the other feature. If both locations are segmented, it is
possible for the segments to have no overlap but still be within the extreme coordinates of the other feature,
this method will regard one to be contained by the other, when it could be argued that it is not contained due
to there being no overlap. We can change this method to deal with this if it becomes relevant to do so.

@param location1
@param location2
@return