test_class.file: encoder/src/test/java/openlr/encoder/routesearch/RouteSearchTest.java
test_class.identifier: RouteSearchTest
test_case.body: @Test
      public final void testLowestFrcRouting() {
          try {
              TestData td = TestData.getInstance();
              MapDatabase mdb = td.getMapDatabase();
              RouteSearch rs = new RouteSearch(Arrays.asList(mdb.getLine(1), mdb.getLine(3), mdb.getLine(5), mdb.getLine(8)));
              RouteSearchResult result = rs.calculateRoute();
              assertEquals(1, result.getIntermediatePos());
          } catch (Exception e) {
              fail("Wrong error detected: " + e.getMessage());
          }
      }
test_case.class_method_signature: RouteSearchTest.testLowestFrcRouting()
test_case.full_signature: @Test public final void testLowestFrcRouting()
test_case.identifier: testLowestFrcRouting
test_case.invocations: getInstance getMapDatabase asList getLine getLine getLine getLine calculateRoute assertEquals getIntermediatePos fail getMessage
test_case.modifiers: @Test public final
test_case.parameters: ()
test_case.return: void
test_case.signature: void testLowestFrcRouting()
focal_class.declarator: FRC_COMPARATOR = new FunctionalRoadClass.FrcComparator()
focal_class.modifier: private static final
focal_class.original_string: private static final FrcComparator FRC_COMPARATOR = new FunctionalRoadClass.FrcComparator();
focal_class.type: FrcComparator
focal_class.var_name: FRC_COMPARATOR
focal_class.declarator: LOG = Logger.getLogger(RouteSearch.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = Logger.getLogger(RouteSearch.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: location
focal_class.modifier: private final
focal_class.original_string: private final List<? extends Line> location;
focal_class.type: List<? extends Line>
focal_class.var_name: location
focal_class.declarator: startLine
focal_class.modifier: private final
focal_class.original_string: private final Line startLine;
focal_class.type: Line
focal_class.var_name: startLine
focal_class.declarator: destLine
focal_class.modifier: private final
focal_class.original_string: private final Line destLine;
focal_class.type: Line
focal_class.var_name: destLine
focal_class.declarator: startLoopIndex
focal_class.modifier: private final
focal_class.original_string: private final int startLoopIndex;
focal_class.type: int
focal_class.var_name: startLoopIndex
focal_class.declarator: endLoopIndex
focal_class.modifier: private final
focal_class.original_string: private final int endLoopIndex;
focal_class.type: int
focal_class.var_name: endLoopIndex
focal_class.declarator: destX = 0
focal_class.modifier: private
focal_class.original_string: private double destX = 0;
focal_class.type: double
focal_class.var_name: destX
focal_class.declarator: destY = 0
focal_class.modifier: private
focal_class.original_string: private double destY = 0;
focal_class.type: double
focal_class.var_name: destY
focal_class.declarator: lengthBetweenStartAndEndLineAlongLocation = 0
focal_class.modifier: private
focal_class.original_string: private int lengthBetweenStartAndEndLineAlongLocation = 0;
focal_class.type: int
focal_class.var_name: lengthBetweenStartAndEndLineAlongLocation
focal_class.file: encoder/src/main/java/openlr/encoder/routesearch/RouteSearch.java
focal_class.identifier: RouteSearch
focal_class.class_method_signature: RouteSearch.RouteSearch(final List<? extends Line> loc)
focal_class.full_signature: public  RouteSearch(final List<? extends Line> loc)
focal_class.identifier: RouteSearch
focal_class.modifiers: public
focal_class.parameters: (final List<? extends Line> loc)
focal_class.signature:  RouteSearch(final List<? extends Line> loc)
focal_class.class_method_signature: RouteSearch.checkLoopAtStart()
focal_class.full_signature: private int checkLoopAtStart()
focal_class.identifier: checkLoopAtStart
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int checkLoopAtStart()
focal_class.class_method_signature: RouteSearch.checkLoopAtEnd()
focal_class.full_signature: private int checkLoopAtEnd()
focal_class.identifier: checkLoopAtEnd
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int checkLoopAtEnd()
focal_class.class_method_signature: RouteSearch.calculateRoute()
focal_class.full_signature: public final RouteSearchResult calculateRoute()
focal_class.identifier: calculateRoute
focal_class.modifiers: public final
focal_class.parameters: ()
focal_class.return: RouteSearchResult
focal_class.signature: RouteSearchResult calculateRoute()
focal_class.class_method_signature: RouteSearch.extractNextLines(final PQElem actualElement,
                                    final RouteSearchData data)
focal_class.full_signature: private void extractNextLines(final PQElem actualElement,
                                    final RouteSearchData data)
focal_class.identifier: extractNextLines
focal_class.modifiers: private
focal_class.parameters: (final PQElem actualElement,
                                    final RouteSearchData data)
focal_class.return: void
focal_class.signature: void extractNextLines(final PQElem actualElement,
                                    final RouteSearchData data)
focal_class.class_method_signature: RouteSearch.toString()
focal_class.full_signature: @Override public final String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public final
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_method.body: public final RouteSearchResult calculateRoute()
              throws OpenLREncoderProcessingException {
          if (LOG.isDebugEnabled()) {
              LOG.debug("route search between start (" + startLine.getID()
                      + ") and dest (" + destLine.getID() + ")");
          }
          RouteSearchResult result = null;
  
          // start and end are equals but there is a path in between
          // so skip the start and proceed with the next line in the location
          if (startLine.getID() == destLine.getID() && location.size() > 1) {
              List<Line> route = new ArrayList<Line>(1);
              route.add(startLine);
              result = new RouteSearchResult(
                      RouteSearchReturnCode.INTERMEDIATE_FOUND, route, location
                      .get(1), 1);
          } else if (startLoopIndex == 0) {
              // there is a loop of a single line in the location
              List<Line> route = new ArrayList<Line>();
              route.add(startLine);
              result = new RouteSearchResult(RouteSearchReturnCode.INTERMEDIATE_FOUND, route, location.get(1), 1);
          } else {
              //we have to start a search
              // global data structures
              IntermediateHandler iHandler = new IntermediateHandler(location);
              RouteSearchData data = new RouteSearchData();
  
              // for the use of the heuristic
              Node e = destLine.getEndNode();
              destX = e.getLongitudeDeg();
              destY = e.getLatitudeDeg();
  
              // initialize the open list with the start element
              int startLength = startLine.getLineLength();
              PQElem startElem = new PQElem(startLine, 0/* HACK */, startLength,
                      null);
              data.addToOpen(startElem);
              // open.add(startElem);
              // bestValues.put(startLine.getID(), startLength);
              OpenLongHashSet locationIDs = new OpenLongHashSet(location.size());
              for (Line l : location) {
                  locationIDs.put(l.getID());
              }
  
              // main loop
              while (!data.isOpenEmpty()) {
                  // stop if route or intermediate is found or if no further line
                  // is
                  // available
  
                  // get the top element of the open list
                  PQElem actualElement = data.pollElement();
  
                  // check the location being part of the shortest path tree and
                  // if not change the state to INTERMEDIATE_FOUND
                  if (locationIDs.containsKey(actualElement.getLine().getID())) {
                      result = iHandler.checkIntermediate(actualElement, data);
                      if (result != null) {
                          break;
                      }
                  }
  
                  // check if we have found the destination and if so then
                  // construct the route and stop calculation
                  if (actualElement.getLine().getID() == destLine.getID()) {
                      if (endLoopIndex >= 0) {
                          //route found until the end loop starts
                          //break here and add intermediate
                          List<Line> route = PathUtils
                                  .constructPath(actualElement.getPrevious());
                          result = new RouteSearchResult(
                                  RouteSearchReturnCode.INTERMEDIATE_FOUND,
                                  route, destLine, endLoopIndex);
                          break;
                      } else {
                          List<Line> route = PathUtils
                                  .constructPath(actualElement);
                          if (route.isEmpty()) {
                              // strange error
                              throw new OpenLREncoderProcessingException(
                                      EncoderProcessingError.ROUTE_CONSTRUCTION_ERROR);
                          } else {
                              // route found and constructed
                              result = new RouteSearchResult(
                                      RouteSearchResult.RouteSearchReturnCode.ROUTE_FOUND,
                                      route);
                              break;
                          }
                      }
                  }
  
                  //check for loops at start
                  if (startLoopIndex > 0
                          && iHandler.getLastElemOnRoutePos() == startLoopIndex) {
                      // the start loop is completed and route search needs to be
                      // interrupted, add intermediate
                      if (LOG.isDebugEnabled()) {
                          LOG.debug("loop is traversed, intermediate found");
                      }
                      List<Line> route = PathUtils.constructPath(actualElement.getPrevious());
                      result = new RouteSearchResult(
                              RouteSearchReturnCode.INTERMEDIATE_FOUND, route,
                              startLine, startLoopIndex);
                      break;
                  }
                  //route search can continue so
                  // iterate over the successors, because we have not reached the
                  // end
                  extractNextLines(actualElement, data);
              }
              if (result == null) {
                  //no route found
                  result = new RouteSearchResult(RouteSearchReturnCode.NO_ROUTE_FOUND);
              }
          }
          return result;
      }
focal_method.class_method_signature: RouteSearch.calculateRoute()
focal_method.full_signature: public final RouteSearchResult calculateRoute()
focal_method.identifier: calculateRoute
focal_method.invocations: isDebugEnabled debug getID getID getID getID size add get add get getEndNode getLongitudeDeg getLatitudeDeg getLineLength addToOpen size put getID isOpenEmpty pollElement containsKey getID getLine checkIntermediate getID getLine getID constructPath getPrevious constructPath isEmpty getLastElemOnRoutePos isDebugEnabled debug constructPath getPrevious extractNextLines
focal_method.modifiers: public final
focal_method.parameters: ()
focal_method.return: RouteSearchResult
focal_method.signature: RouteSearchResult calculateRoute()