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 Graphableadd(Object obj)Adds a line to the graph.protected EdgegenerateEdge(LineSegment line)protected voidgenerateNodes()EdgegetEdge(Coordinate c1, Coordinate c2)Retrieve edge between the two coordinates.Map<Coordinate,Object>getInNodeMap()Returns the coordinate to in node map.NodegetNode(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:
addin interfaceGraphGenerator- Overrides:
addin 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:
generateNodesin classOptLineGraphGenerator
-
generateEdge
protected Edge generateEdge(LineSegment line)
- Overrides:
generateEdgein classOptLineGraphGenerator
-
getNode
public Node getNode(Coordinate c)
Description copied from interface:LineGraphGeneratorLook up a Node for the provided coordinate.- Specified by:
getNodein interfaceLineGraphGenerator- Overrides:
getNodein classOptLineGraphGenerator- Returns:
- Node
-
getEdge
public Edge getEdge(Coordinate c1, Coordinate c2)
Description copied from interface:LineGraphGeneratorRetrieve edge between the two coordinates.- Specified by:
getEdgein interfaceLineGraphGenerator- Overrides:
getEdgein classOptLineGraphGenerator- Returns:
- Edge
-
-