Пример #1
0
 /**
  * Pass in the id of the way, and gets the way object.
  *
  * @param wayID of the way
  * @param waysFileData the file data representing the ways file we want to binary search through
  * @return the way object
  * @throws IOException
  */
 public Way getWayFromID(String wayID, FileData waysFileData)
     throws IllegalArgumentException, IOException {
   String chunkID = MapsAlgorithms.getChunkID(wayID);
   if (_chunkIDToWaysMaps.containsKey(chunkID)
       && _chunkIDToWaysMaps.get(chunkID).containsKey(wayID)) {
     return _chunkIDToWaysMaps.get(chunkID).get(wayID);
   } else {
     String wayLine =
         FileSearchAlgorithms.binarySearch(waysFileData, wayID, waysFileData.headerIndices[0]);
     return getWayFromLine(wayLine, waysFileData);
   }
 }
Пример #2
0
  /**
   * Given the id of the node, gets a MapGraphNode that represents the node How is this different
   * from the previous method? It takes in a fileData and is ONLY called by the intersection request
   * handler which needs a new copy of the file data
   *
   * @param nodeID the node's id
   * @param nodesFileData the file data representing the nodes file we want to binary search through
   * @return a MapGraphNode that represents the node
   * @throws IOException
   */
  public MapGraphNode getNodeFromID(String nodeID, FileData nodesFileData)
      throws IllegalArgumentException, IOException {
    if (nodeID == null) throw new IllegalArgumentException("ID is null");
    if (nodeID.equals("")) throw new IllegalArgumentException("ID is an empty string");
    String chunkID = MapsAlgorithms.getChunkID(nodeID);

    if (_chunkIDToNodesMaps.containsKey(chunkID)
        && _chunkIDToNodesMaps.get(chunkID).containsKey(nodeID)) {
      return _chunkIDToNodesMaps.get(chunkID).get(nodeID);
    } else {
      String nodeLine =
          FileSearchAlgorithms.binarySearch(nodesFileData, nodeID, nodesFileData.headerIndices[0]);
      return getNodeFromLine(nodeLine, nodesFileData);
    }
  }