/** * Extract the major roads from the road network * * @return a connected network of major roads */ public Network extractMajorRoads() { Network majorRoads = new Network(); // go through all nodes for (Object o : roads.getAllNodes()) { GeoNode n = (GeoNode) o; // go through all edges for (Object p : roads.getEdgesOut(n)) { sim.field.network.Edge e = (sim.field.network.Edge) p; // String type = ((MasonGeometry)e.info).getStringAttribute("class"); // save major roads // if(type.equals("major")) majorRoads.addEdge(e.from(), e.to(), e.info); } } // merge the major roads into a connected component NetworkUtilities.attachUnconnectedComponents(majorRoads, roads); return majorRoads; }