public void buildNetwork(FeatureCollection networkFC, Point originPoint) throws TransformException {
coordinateReferenceSystem = networkFC.getSchema().getCoordinateReferenceSystem();
//get the object to generate the graph from line string objects
LineStringGraphGenerator lineStringGen = new LineStringGraphGenerator();
//wrap it in a feature graph generator
FeatureGraphGenerator featureGen = new FeatureGraphGenerator(lineStringGen);
//throw all the features into the graph generator
FeatureIterator featureIterator = networkFC.features();
try {
while (featureIterator.hasNext()) {
Feature feature = featureIterator.next();
featureGen.add(feature);
}
} finally {
featureIterator.close();
}
//build the graph
networkGraph = featureGen.getGraph();
//find the node of the graph closest to the origin point and returns the node
Node source = nodeHelper.getNearestGraphNode(lineStringGen, networkGraph, originPoint, coordinateReferenceSystem);
//distance between the origin location and the nearest graph node
distanceOriginToGraph = nodeHelper.getDistanceFromGraphNode();