Ticket #3447: ignore_oneways.patch
| File ignore_oneways.patch, 4.3 KB (added by , 14 years ago) |
|---|
-
src/com/innovant/josm/jrt/core/RoutingGraph.java
35 35 import org.jgrapht.Graph; 36 36 import org.jgrapht.alg.BellmanFordShortestPath; 37 37 import org.jgrapht.alg.DijkstraShortestPath; 38 import org.jgrapht.graph.AsUndirectedGraph;39 38 import org.jgrapht.graph.DirectedWeightedMultigraph; 39 import org.openstreetmap.josm.Main; 40 40 import org.openstreetmap.josm.data.osm.DataSet; 41 41 import org.openstreetmap.josm.data.osm.Node; 42 42 import org.openstreetmap.josm.data.osm.Way; … … 42 42 import org.openstreetmap.josm.data.osm.Way; 43 43 44 44 import com.innovant.josm.jrt.osm.OsmEdge; 45 import com.innovant.josm.plugin.routing.RoutingLayer; 46 import com.innovant.josm.plugin.routing.RoutingModel; 45 47 46 48 /** 47 49 * Class utility to work with graph routers. … … 197 199 198 200 199 201 //this is where we link the vertices 202 if (!routingProfile.isOnewayUsed()) 203 //"Ignore oneways" is selected 204 addEdgeBidirectional(way, from, to); 205 206 else //"Ignore oneways" is not selected 200 207 if (oneway_val == null || oneway_val == "false" || oneway_val == "no" || oneway_val == "0") { 201 208 //Case 1 (bi-way): oneway=false OR oneway=unset OR oneway=0 OR oneway=no 202 209 addEdgeBidirectional(way, from, to); … … 325 332 Graph<Node,OsmEdge> g; 326 333 double totalWeight = 0; 327 334 328 if (graph == null) 335 RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer(); 336 RoutingModel routingModel = layer.getRoutingModel(); 337 338 if (graph == null || routingModel.getWaysChanged()) 329 339 this.createGraph(); 330 340 logger.debug("apply algorithm between nodes "); 331 341 … … 334 344 } 335 345 logger.debug("-----------------------------------"); 336 346 337 // Assign the graph or an undirected view of the graph to g, 338 // depending on whether oneway tags are used or not 339 if (routingProfile.isOnewayUsed()) 347 // Assign the graph to g 340 348 g = graph; 341 else 342 g = new AsUndirectedGraph<Node, OsmEdge>((DirectedWeightedMultigraph<Node,OsmEdge>)graph); 343 //TODO: Problemas no tiene encuenta el tema de oneway. 349 344 350 switch (algorithm) { 345 351 case ROUTING_ALG_DIJKSTRA: 346 352 logger.debug("Using Dijkstra algorithm"); -
src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
131 131 else 132 132 routingModel.routingGraph.getRoutingProfile().setOnewayUse(true); 133 133 routingModel.setNodesChanged(); 134 routingModel.setWaysChanged(); 134 135 Main.map.repaint(); 135 136 } 136 137 } -
src/com/innovant/josm/plugin/routing/RoutingModel.java
68 68 */ 69 69 private boolean changeNodes=false; 70 70 /** 71 * Flag to advise about changes in ways. 72 */ 73 private boolean changeWays=false; 74 /** 71 75 * Default Constructor. 72 76 */ 73 77 public RoutingModel(DataSet data) { … … 137 141 { 138 142 path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA); 139 143 this.changeNodes=false; 144 this.changeWays=false; 140 145 } 141 146 return path; 142 147 } … … 147 152 public void setNodesChanged() { 148 153 this.changeNodes = true; 149 154 } 155 156 /** 157 * Marks that some node or the node order has changed so the path should be computed again 158 */ 159 public void setWaysChanged() { 160 this.changeWays = true; 161 } 162 163 /** 164 * Marks that some node or the node order has changed so the path should be computed again 165 */ 166 public boolean getWaysChanged() { 167 return this.changeWays; 168 } 150 169 151 170 /** 152 171 * Resets all data.
