Package org.geotools.graph.build.polygon
Class PolygonGraphGenerator
Object
PolygonGraphGenerator
- All Implemented Interfaces:
GraphGenerator
An implementation of GraphGenerator used to build graphs from a set of polygons.
This graph generator takes Polygon objects as input when constructing a graph.
The following code constructs a graph from a set of polygons.
//get some polygons
Polygon[] polygons = ...
//determine what the relationship will be
PolygonGraphGenerator rel = new PolygonGraphGenerator.PolygonRelationship() {
public boolean related(Polygon p1, Polygon p2) {
return p1.intersects(p2);
}
public boolean equal(Polygon p1, Polygon p2) {
return p1.equals(p2);
}
}
//create the generator
PolygonGraphGenerator gg = new PolygonGraphGenerator(new BasicGraphBuilder(),rel);
//start building
for (int i = 0; i < polygons.length; i++) {
gg.add(polygons[i]);
}
For each distinct polygon added to the graph, a node is created. If two polygons are considered equal, only a single
node is created. If two polygons are considered related, the associated nodes share an edge. Equality and
relationship is determined by PolygonGraphGenerator.PolygonRelationship
interface. An instance of this interface is passed to the generator at construction.- Author:
- Justin Deoliveira, The Open Planning Project
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDetermines the relationship among two polygons. -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionAdds an object to the graph.protected NodeRetrieves a component of the graph.getGraph()Returns the graph being generated.Returns the underlying builder.protected voidRemoves an object from the graph.voidsetGraphBuilder(GraphBuilder builder) Sets the underlying builder used to physically construct the graph.
-
Constructor Details
-
PolygonGraphGenerator
-
-
Method Details
-
add
Description copied from interface:GraphGeneratorAdds an object to the graph.- Specified by:
addin interfaceGraphGenerator- Parameters:
obj- The object to be modelled in the graph.- Returns:
- The graph component used to model the object.
-
get
Description copied from interface:GraphGeneratorRetrieves a component of the graph.- Specified by:
getin interfaceGraphGenerator- Parameters:
obj- The object modelled by the component.- Returns:
- The graph component used to model the object.
-
remove
Description copied from interface:GraphGeneratorRemoves an object from the graph.- Specified by:
removein interfaceGraphGenerator- Parameters:
obj- The object modelled by the component.- Returns:
- The graph component used to model the object.
-
setGraphBuilder
Description copied from interface:GraphGeneratorSets the underlying builder used to physically construct the graph.- Specified by:
setGraphBuilderin interfaceGraphGenerator- Parameters:
builder- The new underlying GraphBuilder.
-
getGraphBuilder
Description copied from interface:GraphGeneratorReturns the underlying builder.- Specified by:
getGraphBuilderin interfaceGraphGenerator- Returns:
- The underyling builder.
-
getGraph
Description copied from interface:GraphGeneratorReturns the graph being generated.- Specified by:
getGraphin interfaceGraphGenerator- Returns:
- The generated graph.
-
find
-
relate
-