Package org.geotools.graph.build.line
Class OptDirectedLineGraphGenerator
- Object
-
- OptLineGraphGenerator
-
- OptDirectedLineGraphGenerator
-
- All Implemented Interfaces:
GraphGenerator
,LineGraphGenerator
public class OptDirectedLineGraphGenerator extends OptLineGraphGenerator
An implementation of GraphGenerator used to generate an optimized graph representing a line network. Graphs are generated by supplying the generator with objects of type LineSegment via the add(Object) method.
For each line segment added, an edge in the graph is created. The builder records the end coordinates of each line added, and maintains a map of coordinates to nodes, creating nodes when neccessary.
Edges created by the generator are of type OptBasicEdge. Nodes created by the generator are of type OptXYNode.
-
-
Constructor Summary
Constructors Constructor Description OptDirectedLineGraphGenerator()
Constructs a new OptLineGraphGenerator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Graphable
add(Object obj)
Adds a line to the graph.protected Edge
generateEdge(LineSegment line)
protected void
generateNodes()
Edge
getEdge(Coordinate c1, Coordinate c2)
Retrieve edge between the two coordinates.Map<Coordinate,Object>
getInNodeMap()
Returns the coordinate to in node map.Node
getNode(Coordinate c)
Look up a Node for the provided coordinate.Map<Coordinate,Object>
getOutNodeMap()
Returns the coordinate to out node map.-
Methods inherited from class OptLineGraphGenerator
generate, generateEdges, get, getGraph, getGraphBuilder, getLines, getNodeMap, remove, setGraphBuilder
-
-
-
-
Method Detail
-
add
public Graphable add(Object obj)
Adds a line to the graph. Note that this method returns null since actual building of the graph components is delayed until generate() is called.- Specified by:
add
in interfaceGraphGenerator
- Overrides:
add
in classOptLineGraphGenerator
- Parameters:
obj
- A LineSegment object.- Returns:
- null because the actual building of the graph components is delayed until generate() is called.
-
getInNodeMap
public Map<Coordinate,Object> getInNodeMap()
Returns the coordinate to in node map. Note that before the call to generate the map does not contain any nodes.- Returns:
- Coordinate to in node map.
-
getOutNodeMap
public Map<Coordinate,Object> getOutNodeMap()
Returns the coordinate to out node map. Note that before the call to generate the map does not contain any nodes.- Returns:
- Coordinate to out node map.
-
generateNodes
protected void generateNodes()
- Overrides:
generateNodes
in classOptLineGraphGenerator
-
generateEdge
protected Edge generateEdge(LineSegment line)
- Overrides:
generateEdge
in classOptLineGraphGenerator
-
getNode
public Node getNode(Coordinate c)
Description copied from interface:LineGraphGenerator
Look up a Node for the provided coordinate.- Specified by:
getNode
in interfaceLineGraphGenerator
- Overrides:
getNode
in classOptLineGraphGenerator
- Returns:
- Node
-
getEdge
public Edge getEdge(Coordinate c1, Coordinate c2)
Description copied from interface:LineGraphGenerator
Retrieve edge between the two coordinates.- Specified by:
getEdge
in interfaceLineGraphGenerator
- Overrides:
getEdge
in classOptLineGraphGenerator
- Returns:
- Edge
-
-