Revision 8402
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/core/NetworkWriter.java | ||
---|---|---|
47 | 47 |
import java.nio.ByteOrder; |
48 | 48 |
import java.sql.Types; |
49 | 49 |
import java.util.ArrayList; |
50 |
import java.util.Collection; |
|
51 | 50 |
import java.util.Hashtable; |
52 |
import java.util.Iterator; |
|
53 | 51 |
|
54 | 52 |
import javax.imageio.stream.FileImageOutputStream; |
55 | 53 |
|
54 |
import com.hardcode.gdbms.engine.values.IntValue; |
|
56 | 55 |
import com.hardcode.gdbms.engine.values.NumericValue; |
57 | 56 |
import com.hardcode.gdbms.engine.values.Value; |
58 | 57 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
59 |
import com.iver.andami.PluginServices; |
|
60 | 58 |
import com.iver.cit.gvsig.fmap.DriverException; |
61 | 59 |
import com.iver.cit.gvsig.fmap.core.DefaultRow; |
62 | 60 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
72 | 70 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
73 | 71 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
74 | 72 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
75 |
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask; |
|
76 |
import com.iver.utiles.swing.threads.AbstractMonitorableTask; |
|
77 | 73 |
import com.iver.utiles.swing.threads.CancellableMonitorable; |
78 | 74 |
import com.vividsolutions.jts.geom.Coordinate; |
79 | 75 |
import com.vividsolutions.jts.geom.Geometry; |
... | ... | |
381 | 377 |
// con su velocidad. Esa velocidad se fijar? en la funci?n |
382 | 378 |
// FijaVelocidades. OJO, empezar siempre desde el 0 |
383 | 379 |
|
384 |
float distance;
|
|
380 |
double distance, cost;
|
|
385 | 381 |
short arcType; |
386 | 382 |
int direction; |
387 | 383 |
int i; |
... | ... | |
435 | 431 |
edgeCount = 0; |
436 | 432 |
|
437 | 433 |
SelectableDataSource sds = lyrSrc.getRecordset(); |
438 |
int senseFieldIndex = sds.getFieldIndexByName(fieldSense); |
|
439 |
int distFieldIndex = sds.getFieldIndexByName(fieldDist); |
|
440 |
int typeFieldIndex = sds.getFieldIndexByName(fieldType); |
|
441 |
if (typeFieldIndex == -1) { |
|
442 |
throw new RuntimeException("Field invalid:" + fieldType); |
|
443 |
} |
|
444 |
if (distFieldIndex == -1) { |
|
445 |
throw new RuntimeException("Field invalid:" + fieldDist); |
|
446 |
} |
|
434 |
int senseFieldIndex = -1; |
|
435 |
int distFieldIndex = -1; |
|
436 |
int typeFieldIndex = -1; |
|
437 |
int costFieldIndex = -1; |
|
438 |
|
|
439 |
if (fieldSense != null) |
|
440 |
senseFieldIndex = sds.getFieldIndexByName(fieldSense); |
|
441 |
if (fieldDist != null) |
|
442 |
distFieldIndex = sds.getFieldIndexByName(fieldDist); |
|
443 |
if (fieldType != null) |
|
444 |
typeFieldIndex = sds.getFieldIndexByName(fieldType); |
|
445 |
if (fieldCost != null) |
|
446 |
costFieldIndex = sds.getFieldIndexByName(fieldCost); |
|
447 | 447 |
|
448 |
NumericValue valAux = null; |
|
448 | 449 |
for (i = 0; i < numTramos; i++) { |
449 | 450 |
IGeometry geom = adapter.getShape(i); |
450 | 451 |
Geometry jtsGeom = geom.toJTSGeometry(); |
... | ... | |
479 | 480 |
} |
480 | 481 |
idNodo2 = nodeAux.getId().intValue(); |
481 | 482 |
|
482 |
NumericValue valAux = (NumericValue) sds.getFieldValue(i, |
|
483 |
typeFieldIndex); |
|
483 |
if (typeFieldIndex != -1) |
|
484 |
valAux = (NumericValue) sds.getFieldValue(i, typeFieldIndex); |
|
485 |
else |
|
486 |
valAux = ValueFactory.createValue(0); // no hay tipo |
|
484 | 487 |
arcType = valAux.shortValue(); |
485 | 488 |
// TipoTramo = DBFReadIntegerAttribute(hDBF, i, indiceCampo1); |
486 |
valAux = (NumericValue) sds.getFieldValue(i, distFieldIndex); |
|
489 |
|
|
490 |
if (distFieldIndex != -1) |
|
491 |
valAux = (NumericValue) sds.getFieldValue(i, distFieldIndex); |
|
492 |
else |
|
493 |
valAux = ValueFactory.createValue(jtsGeom.getLength()); |
|
487 | 494 |
distance = valAux.floatValue(); |
488 | 495 |
// Distancia = (float) DBFReadDoubleAttribute(hDBF, i, |
489 | 496 |
// indiceCampo2); |
497 |
if (costFieldIndex != -1) |
|
498 |
{ |
|
499 |
valAux = (NumericValue) sds.getFieldValue(i, costFieldIndex); |
|
500 |
cost = valAux.doubleValue(); |
|
501 |
} |
|
502 |
else |
|
503 |
cost = distance; |
|
504 |
|
|
505 |
|
|
490 | 506 |
|
491 | 507 |
direction = -1; |
492 | 508 |
|
... | ... | |
503 | 519 |
if (direction == 3) { |
504 | 520 |
sentidoDigit = 1; // En esa direcci?n |
505 | 521 |
writeEdge(output, i, sentidoDigit, idNodo1, idNodo2, arcType, |
506 |
distance); |
|
522 |
distance, cost);
|
|
507 | 523 |
edgeCount++; |
508 | 524 |
|
509 | 525 |
sentidoDigit = 0; |
510 | 526 |
writeEdge(output, i, sentidoDigit, idNodo2, idNodo1, arcType, |
511 |
distance); |
|
527 |
distance, cost);
|
|
512 | 528 |
edgeCount++; |
513 | 529 |
|
514 | 530 |
} |
515 | 531 |
if (direction == 1) { |
516 | 532 |
sentidoDigit = 1; // En esa direcci?n |
517 | 533 |
writeEdge(output, i, sentidoDigit, idNodo1, idNodo2, arcType, |
518 |
distance); |
|
534 |
distance, cost);
|
|
519 | 535 |
edgeCount++; |
520 | 536 |
} |
521 | 537 |
if (direction == 2) { |
522 | 538 |
sentidoDigit = 0; |
523 | 539 |
writeEdge(output, i, sentidoDigit, idNodo2, idNodo1, arcType, |
524 |
distance); |
|
540 |
distance, cost);
|
|
525 | 541 |
edgeCount++; |
526 | 542 |
|
527 | 543 |
} |
... | ... | |
573 | 589 |
} |
574 | 590 |
|
575 | 591 |
private void writeEdge(FileImageOutputStream output, int id, short sense, |
576 |
int idNodeOrig, int idNodeEnd, short tipoTramo, float dist)
|
|
592 |
int idNodeOrig, int idNodeEnd, short tipoTramo, double dist, double cost)
|
|
577 | 593 |
throws IOException { |
578 | 594 |
output.writeInt(id); |
579 | 595 |
output.writeInt(sense); |
... | ... | |
581 | 597 |
output.writeInt(idNodeOrig); |
582 | 598 |
output.writeInt(idNodeEnd); |
583 | 599 |
output.writeInt(tipoTramo); |
584 |
output.writeFloat(dist); |
|
600 |
output.writeDouble(dist); |
|
601 |
output.writeDouble(cost); |
|
585 | 602 |
|
586 | 603 |
} |
587 | 604 |
|
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/core/NetworkRedLoader.java | ||
---|---|---|
96 | 96 |
GvGraph g = new GvGraph(numArcs, numEdges, numNodes); |
97 | 97 |
|
98 | 98 |
// Nodes |
99 |
buf.position(24*numEdges + 12);
|
|
99 |
buf.position(30*numEdges + 12);
|
|
100 | 100 |
for (int i=0; i < numNodes; i++) |
101 | 101 |
{ |
102 | 102 |
GvNode node = readNode(buf); |
... | ... | |
230 | 230 |
// memcpy(&Arcos[link_num].TipoTramo,puntero,sizeof(int)); |
231 | 231 |
|
232 | 232 |
// Distance |
233 |
// TODO: PONERLO COMO DOUBLE DENTRO DEL FICHERO!!!! |
|
234 |
edge.setDistance(buf.getFloat()); |
|
235 |
// TODO: POR AHORA, WEIGHT = LENGTH. Con setVelocities() lo cambiamos. |
|
236 |
edge.setWeight(edge.getDistance()); |
|
233 |
edge.setDistance(buf.getDouble()); |
|
234 |
edge.setWeight(buf.getDouble()); |
|
237 | 235 |
|
238 | 236 |
// memcpy(&Arcos[link_num].Coste2,puntero,sizeof(float)); |
239 | 237 |
|
trunk/extensions/extGraph_predes/.classpath | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 |
<classpathentry path="src" kind="src"/> |
|
4 |
<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/> |
|
5 |
<classpathentry path="/_fwAndami" kind="src"/> |
|
6 |
<classpathentry path="/libFMap" kind="src"/> |
|
7 |
<classpathentry path="/libCq CMS for java" kind="src"/> |
|
8 |
<classpathentry path="/libIverUtiles" kind="src"/> |
|
9 |
<classpathentry path="/libDriverManager" kind="src"/> |
|
10 |
<classpathentry path="/appgvSIG" kind="src"/> |
|
11 |
<classpathentry path="lib/colt.jar" kind="lib"/> |
|
12 |
<classpathentry path="lib/commons-collections-3.2.jar" kind="lib"/> |
|
13 |
<classpathentry sourcepath="/JUNG_1_7_4" path="lib/jung-1.7.4.jar" kind="lib"/> |
|
14 |
<classpathentry path="/libGDBMS" combineaccessrules="false" kind="src"/> |
|
15 |
<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.1.1/src/org.junit_3.8.1/junitsrc.zip" path="JUNIT_HOME/junit.jar" kind="var"/> |
|
16 |
<classpathentry sourcepath="" path="/_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/lib/fmap.jar" kind="lib"/> |
|
17 |
<classpathentry path="/extGeoProcessing" combineaccessrules="false" kind="src"/> |
|
18 |
<classpathentry sourcepath="D:/eclipse_3_1/workspace_pruebas/jts/src" path="/libFMap/lib/jts-1.7.jar" kind="lib"/> |
|
19 |
<classpathentry path="/appgvSIG/lib/batik-awt-util.jar" kind="lib"/> |
|
20 |
<classpathentry path="/_fwAndami/lib/castor-0.9.5.3-xml.jar" kind="lib"/> |
|
21 |
<classpathentry sourcepath="/libUI/src" path="/_fwAndami/lib/beans.jar" kind="lib"/> |
|
22 |
<classpathentry path="bin" kind="output"/> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="src" path="src-test"/> |
|
5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
6 |
<classpathentry kind="src" path="/_fwAndami"/> |
|
7 |
<classpathentry kind="src" path="/libFMap"/> |
|
8 |
<classpathentry kind="src" path="/libCq CMS for java"/> |
|
9 |
<classpathentry kind="src" path="/libIverUtiles"/> |
|
10 |
<classpathentry kind="src" path="/libDriverManager"/> |
|
11 |
<classpathentry kind="src" path="/appgvSIG"/> |
|
12 |
<classpathentry kind="lib" path="lib/colt.jar"/> |
|
13 |
<classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/> |
|
14 |
<classpathentry sourcepath="/JUNG_1_7_4" kind="lib" path="lib/jung-1.7.4.jar"/> |
|
15 |
<classpathentry combineaccessrules="false" kind="src" path="/libGDBMS"/> |
|
16 |
<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.1.1/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/> |
|
17 |
<classpathentry sourcepath="" kind="lib" path="/_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/lib/fmap.jar"/> |
|
18 |
<classpathentry combineaccessrules="false" kind="src" path="/extGeoProcessing"/> |
|
19 |
<classpathentry sourcepath="D:/eclipse_3_1/workspace_pruebas/jts/src" kind="lib" path="/libFMap/lib/jts-1.7.jar"/> |
|
20 |
<classpathentry kind="lib" path="/appgvSIG/lib/batik-awt-util.jar"/> |
|
21 |
<classpathentry kind="lib" path="/_fwAndami/lib/castor-0.9.5.3-xml.jar"/> |
|
22 |
<classpathentry sourcepath="/libUI/src" kind="lib" path="/_fwAndami/lib/beans.jar"/> |
|
23 |
<classpathentry kind="output" path="bin"/> |
|
23 | 24 |
</classpath> |
Also available in: Unified diff