//create an array to store the geometry of each Edge linestring that will need to be merged into one Route object
Geometry[] geomArray = new Geometry[result.size()];
//populate the geometry array with the route edges
for (int i = 0; i < result.size(); i++) {
BasicEdge eg = (BasicEdge) result.get(i);
SimpleFeature feature = (SimpleFeature) eg.getObject();
Geometry geom = (Geometry) feature.getDefaultGeometry();
geomArray[i] = geom;
}
//call the function to merge the geometries into one feature