Package huskymaps

Class MapGraph

    • Method Detail

      • fileStream

        private static InputStream fileStream​(String path)
                                       throws FileNotFoundException
        Returns an input stream from the contents of the file at the given path.
        Parameters:
        path - a file path.
        Returns:
        an input stream with the contents of the specified file.
        Throws:
        FileNotFoundException - if there is no file at the specified path.
      • closest

        public Location closest​(Location target)
        Returns the location closest to the given target location.
        Parameters:
        target - the target location.
        Returns:
        the id of the location closest to the target.
      • getLocationsByPrefix

        public List<CharSequence> getLocationsByPrefix​(String prefix)
        Return the names of all locations that prefix-match the query string.
        Parameters:
        prefix - prefix string that could be any case with or without punctuation.
        Returns:
        a list of full names of locations matching the prefix.
      • getLocations

        public List<Location> getLocations​(String locationName,
                                           Location center)
        Return all locations that match a valid location name.
        Parameters:
        locationName - a full name of a valid location.
        Returns:
        a list of locations whose name matches the location name.
      • neighbors

        public List<Edge<Location>> neighbors​(Location v)
        Description copied from interface: Graph
        Returns a list of the outgoing edges from the given vertex.
        Specified by:
        neighbors in interface Graph<Location>
        Parameters:
        v - the node of interest.
        Returns:
        a list of the outgoing edges from the given vertex.
      • estimatedDistance

        public double estimatedDistance​(Location start,
                                        Location end)
        Description copied from interface: AStarGraph
        Returns an estimated distance from start to end.
        Specified by:
        estimatedDistance in interface AStarGraph<Location>
        Parameters:
        start - the beginning vertex.
        end - the destination vertex.
        Returns:
        an estimated distance from start to end.
      • addEdge

        private void addEdge​(Location from,
                             Location to)
        Adds an edge to this graph if it doesn't already exist, using distance as the weight.