Revision 8100
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/ShortestPathExtension.java | ||
---|---|---|
86 | 86 |
Route route; |
87 | 87 |
try { |
88 | 88 |
solver.setNetwork(net); |
89 |
solver.setFielStreetName("Nombre");
|
|
89 |
// solver.setFielStreetName("STREET_NAM");
|
|
90 | 90 |
route = solver.calculateRoute(); |
91 |
JOptionPane.showMessageDialog(null, route.getInstructions()); |
|
91 |
JOptionPane.showMessageDialog(null, route.getInstructions());
|
|
92 | 92 |
createGraphicsFrom(route.getFeatureList(), v.getMapControl()); |
93 | 93 |
|
94 | 94 |
} catch (GraphException e) { |
... | ... | |
105 | 105 |
private void createGraphicsFrom(Collection featureList, MapControl mapControl) { |
106 | 106 |
Iterator it = featureList.iterator(); |
107 | 107 |
GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer(); |
108 |
if (idSymbolLine == -1) |
|
108 |
// if (idSymbolLine == -1)
|
|
109 | 109 |
{ |
110 | 110 |
FSymbol lineSymbol = new FSymbol(FShape.LINE, Color.RED); |
111 | 111 |
lineSymbol.setStroke(new BasicStroke(3.0f)); |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/NetworkExtension.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.graph; |
42 | 42 |
|
43 |
import java.awt.Component; |
|
43 | 44 |
import java.io.File; |
44 | 45 |
|
45 | 46 |
import javax.swing.JOptionPane; |
... | ... | |
96 | 97 |
shapeType = lyrVect.getShapeType(); |
97 | 98 |
if (shapeType == FShape.LINE) |
98 | 99 |
{ |
99 |
if (actionCommand.equalsIgnoreCase("GENERAR_RED")) {
|
|
100 |
generateNetwork(lyrVect); |
|
100 |
if (actionCommand.equalsIgnoreCase("GENERATE_RED")) {
|
|
101 |
generateRedNetwork(lyrVect);
|
|
101 | 102 |
} |
102 | 103 |
if (actionCommand.equalsIgnoreCase("LOAD_RED")) { |
103 | 104 |
loadNetwork(lyrVect); |
... | ... | |
166 | 167 |
// nombres de campos |
167 | 168 |
|
168 | 169 |
NetworkRedLoader netLoader = new NetworkRedLoader(); |
170 |
File redFile = new File("c:/" + lyrVect.getName().replaceAll("\\Q.shp\\E", ".red")); |
|
171 |
netLoader.setNetFile(redFile); |
|
169 | 172 |
|
170 |
netLoader.setNetFile(new File("c:/ejes.red")); |
|
171 |
|
|
172 | 173 |
IGraph g = netLoader.loadNetwork(); |
173 | 174 |
|
174 | 175 |
System.out.println("Num nodos=" + g.getNumNodes() + " numEdges = " + g.getNumEdges()); |
175 | 176 |
|
177 |
// TODO: MOSTRAR UN CUADRO DE DI?LOGO CON UN COMBOBOX PARA QUE ESCOJA EL CAMPO DE NOMBRE DE CALLE. |
|
178 |
String fieldStreetName = JOptionPane.showInputDialog((Component) PluginServices.getMainFrame(), |
|
179 |
"Street-Route field name?", "STREET_NAM"); |
|
180 |
|
|
176 | 181 |
Network net = new Network(); |
177 | 182 |
net.setGraph(g); |
178 | 183 |
net.setLayer(lyrVect); |
184 |
ShortestPathExtension.solver.setNetwork(net); |
|
185 |
ShortestPathExtension.solver.setFielStreetName(fieldStreetName); |
|
186 |
|
|
179 | 187 |
lyrVect.setProperty("network", net); |
180 | 188 |
|
181 | 189 |
} |
... | ... | |
213 | 221 |
|
214 | 222 |
} |
215 | 223 |
|
224 |
private void generateRedNetwork(FLyrVect lyr) { |
|
225 |
NetworkWriter netBuilder = new NetworkWriter(); |
|
226 |
// Por ahora, a pelo, pero hay que sacar un cuadro |
|
227 |
// de di?logo para hecer el mapping. |
|
228 |
// Tambi?n un cuadro de di?logo para seleccionar |
|
229 |
// en qu? tablas quiere escribir, y su formato |
|
230 |
// (dbf, postgres, etc) |
|
231 |
|
|
232 |
String fieldType = JOptionPane.showInputDialog(null, "fieldType:", "LPOLY_"); |
|
233 |
if (fieldType == null) |
|
234 |
return; |
|
235 |
String fieldDist = JOptionPane.showInputDialog(null, "fieldLength:", "length"); |
|
236 |
if (fieldDist == null) |
|
237 |
return; |
|
238 |
|
|
239 |
String fieldSense = JOptionPane.showInputDialog(null, "fieldSense:", ""); |
|
240 |
if (fieldSense == null) |
|
241 |
return; |
|
242 |
|
|
243 |
|
|
244 |
try { |
|
245 |
netBuilder.setLayer(lyr, fieldType, fieldDist, fieldSense); |
|
246 |
|
|
247 |
File redFile = new File("c:/" + lyr.getName().replaceAll("\\Q.shp\\E", ".red")); |
|
248 |
netBuilder.createRedFile(lyr, redFile); |
|
249 |
} catch (DriverException e1) { |
|
250 |
// TODO Auto-generated catch block |
|
251 |
e1.printStackTrace(); |
|
252 |
} |
|
253 |
JOptionPane.showMessageDialog(null, "Hecho. "); |
|
254 |
|
|
255 |
|
|
256 |
} |
|
257 |
|
|
258 |
|
|
216 | 259 |
public boolean isEnabled() { |
217 | 260 |
return true; |
218 | 261 |
} |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/core/EdgePair.java | ||
---|---|---|
43 | 43 |
public class EdgePair { |
44 | 44 |
int idEdge = -1; |
45 | 45 |
int idInverseEdge = -1; |
46 |
// int idArc; |
|
47 |
// |
|
48 |
// public EdgePair(int idArc) { |
|
49 |
// this.idArc = idArc; |
|
50 |
// } |
|
46 | 51 |
public int getIdEdge() { |
47 | 52 |
return idEdge; |
48 | 53 |
} |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/core/GvGraph.java | ||
---|---|---|
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
public void addEdgePair(EdgePair edgePair) { |
99 |
// assert(indexArcsEdges.size() == edgePair.idArc); |
|
99 | 100 |
indexArcsEdges.add(edgePair); |
100 | 101 |
} |
101 | 102 |
|
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/NetworkAddFlag.java | ||
---|---|---|
61 | 61 |
View v = (View) PluginServices.getMDIManager().getActiveWindow(); |
62 | 62 |
MapControl mapCtrl = v.getMapControl(); |
63 | 63 |
|
64 |
if (flagListener == null) // We create it for the first time.
|
|
64 |
if (!mapCtrl.hasTool("addFlag")) // We create it for the first time.
|
|
65 | 65 |
{ |
66 | 66 |
flagListener = new FlagListener(mapCtrl); |
67 | 67 |
mapCtrl.addMapTool("addFlag", new PointBehavior(flagListener)); |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graphtests/TestWriter.java | ||
---|---|---|
103 | 103 |
|
104 | 104 |
String fieldType = "tipored"; |
105 | 105 |
String fieldDist = "length"; |
106 |
String fieldSense = "sen";
|
|
106 |
String fieldSense = ""; |
|
107 | 107 |
|
108 | 108 |
netBuilder.setLayer(lyr, fieldType, fieldDist, fieldSense); |
109 | 109 |
DbfWriter nodeWriter = new DbfWriter(); |
Also available in: Unified diff