Package huskymaps
Class MapGraph
- java.lang.Object
- 
- huskymaps.MapGraph
 
- 
- All Implemented Interfaces:
- AStarGraph<org.locationtech.spatial4j.shape.Point>,- Graph<org.locationtech.spatial4j.shape.Point>
 
 public class MapGraph extends Object implements AStarGraph<org.locationtech.spatial4j.shape.Point> AStarGraphof places asPointvertices and streets edges weighted by physical distance.- See Also:
- AStarGraph,- MapServer
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description private classMapGraph.HandlerParses OSM XML files to construct a StreetMapGraph.
 - 
Field SummaryFields Modifier and Type Field Description private Autocompleteautocompleteprivate org.locationtech.spatial4j.context.SpatialContextcontextprivate Map<CharSequence,Integer>importanceprivate Map<String,List<org.locationtech.spatial4j.shape.Point>>locationsprivate Map<org.locationtech.spatial4j.shape.Point,Set<Edge<org.locationtech.spatial4j.shape.Point>>>neighborsprivate StringosmPathprivate StringplacesPath
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddEdge(org.locationtech.spatial4j.shape.Point from, org.locationtech.spatial4j.shape.Point to)Adds an edge to this graph if it doesn't already exist, using distance as the weight.org.locationtech.spatial4j.shape.Pointclosest(org.locationtech.spatial4j.shape.Point target)Returns the location closest to the given target location.doubleestimatedDistance(org.locationtech.spatial4j.shape.Point start, org.locationtech.spatial4j.shape.Point end)Returns an estimated distance from start to end.private static InputStreamfileStream(String path)Returns an input stream from the contents of the file at the given path.List<org.locationtech.spatial4j.shape.Point>getLocations(String locationName, org.locationtech.spatial4j.shape.Point center)Return all locations that match a valid location name.List<CharSequence>getLocationsByPrefix(String prefix)Return the names of all locations that prefix-match the query string.List<Edge<org.locationtech.spatial4j.shape.Point>>neighbors(org.locationtech.spatial4j.shape.Point v)Returns a list of the outgoing edges from the given vertex.StringtoString()
 
- 
- 
- 
Field Detail- 
osmPathprivate final String osmPath 
 - 
placesPathprivate final String placesPath 
 - 
contextprivate final org.locationtech.spatial4j.context.SpatialContext context 
 - 
neighborsprivate final Map<org.locationtech.spatial4j.shape.Point,Set<Edge<org.locationtech.spatial4j.shape.Point>>> neighbors 
 - 
autocompleteprivate final Autocomplete autocomplete 
 - 
importanceprivate final Map<CharSequence,Integer> importance 
 
- 
 - 
Constructor Detail- 
MapGraphpublic MapGraph(String osmPath, String placesPath, org.locationtech.spatial4j.context.SpatialContext context) throws ParserConfigurationException, SAXException, IOException Constructs a new street map graph from the path to an OSM file and a places TSV.- Parameters:
- osmPath- The path to a gzipped OSM (XML) file.
- placesPath- The path to a gzipped TSV file representing places and importance.
- Throws:
- ParserConfigurationException- if a parser cannot be created.
- SAXException- for SAX errors.
- IOException- if a file is not found or if the file is not gzipped.
 
 
- 
 - 
Method Detail- 
fileStreamprivate 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.
 
 - 
closestpublic org.locationtech.spatial4j.shape.Point closest(org.locationtech.spatial4j.shape.Point 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.
 
 - 
getLocationsByPrefixpublic 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.
 
 - 
getLocationspublic List<org.locationtech.spatial4j.shape.Point> getLocations(String locationName, org.locationtech.spatial4j.shape.Point 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.
 
 - 
neighborspublic List<Edge<org.locationtech.spatial4j.shape.Point>> neighbors(org.locationtech.spatial4j.shape.Point v) Description copied from interface:GraphReturns a list of the outgoing edges from the given vertex.
 - 
estimatedDistancepublic double estimatedDistance(org.locationtech.spatial4j.shape.Point start, org.locationtech.spatial4j.shape.Point end)Description copied from interface:AStarGraphReturns an estimated distance from start to end.- Specified by:
- estimatedDistancein interface- AStarGraph<org.locationtech.spatial4j.shape.Point>
- Parameters:
- start- the beginning vertex.
- end- the destination vertex.
- Returns:
- an estimated distance from start to end.
 
 - 
addEdgeprivate void addEdge(org.locationtech.spatial4j.shape.Point from, org.locationtech.spatial4j.shape.Point to)Adds an edge to this graph if it doesn't already exist, using distance as the weight.
 
- 
 
-