svn-gvsig-desktop / trunk / extensions / extGraph / src / com / iver / cit / gvsig / graph / core / GvNode.java @ 14780
History | View | Annotate | Download (4.44 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.graph.core; |
42 |
|
43 |
import java.util.ArrayList; |
44 |
|
45 |
import edu.uci.ics.jung.graph.predicates.IsolatedVertexPredicate; |
46 |
|
47 |
public class GvNode { |
48 |
public final static int statNotInList = 0; |
49 |
public final static int statNowInList = 1; |
50 |
public final static int statWasInList = 2; |
51 |
private int idNode; |
52 |
private double x; |
53 |
private double y; |
54 |
|
55 |
int from_link = -1; // id del Arco desde el que hemos llegado |
56 |
int numSoluc = 0; // Empezamos con esto a cero en toda la red. |
57 |
// De manera global, habr? una variable numSolucGlobal que indica el n? de cada petici?n de ruta.
|
58 |
// Sirve para no tener que inicializar siempre tooooda la red. Lo que hacemos es comparar el
|
59 |
// n? de petici?n global con este. Si no coinciden, antes de hacer nada hay que inicializar su
|
60 |
// best_cost a infinito.
|
61 |
|
62 |
double best_cost = Double.MAX_VALUE; |
63 |
double accumulatedLength = 0; |
64 |
double stimation = Double.MAX_VALUE; // bestCost + algo relacionado con la distancia al destino |
65 |
int status;
|
66 |
ArrayList enlaces = new ArrayList(); // Enlaces con los vecinos |
67 |
ArrayList giros = new ArrayList(); // Costes de los giros. Si existe un CGiro, miraremos su coste y lo a?adimos. |
68 |
// Si es negativo, suponemos que es un giro prohibido.
|
69 |
|
70 |
public GvNode() {
|
71 |
initialize(); |
72 |
} |
73 |
|
74 |
public void initialize() { |
75 |
numSoluc = GlobalCounter.numSolucGlobal; |
76 |
from_link = -1;
|
77 |
best_cost = Double.MAX_VALUE;
|
78 |
stimation = Double.MAX_VALUE;
|
79 |
accumulatedLength = 0;
|
80 |
status = statNotInList; |
81 |
|
82 |
} |
83 |
|
84 |
public int getIdNode() { |
85 |
return idNode;
|
86 |
} |
87 |
public void setIdNode(int idNode) { |
88 |
this.idNode = idNode;
|
89 |
} |
90 |
public double getX() { |
91 |
return x;
|
92 |
} |
93 |
public void setX(double x) { |
94 |
this.x = x;
|
95 |
} |
96 |
public double getY() { |
97 |
return y;
|
98 |
} |
99 |
public void setY(double y) { |
100 |
this.y = y;
|
101 |
} |
102 |
public double getBestCost() { |
103 |
if (numSoluc != GlobalCounter.getGlobalSolutionNumber())
|
104 |
return Double.MAX_VALUE; |
105 |
return best_cost;
|
106 |
} |
107 |
public void setBestCost(double best_cost) { |
108 |
this.best_cost = best_cost;
|
109 |
} |
110 |
public ArrayList getEnlaces() { |
111 |
return enlaces;
|
112 |
} |
113 |
public void setEnlaces(ArrayList enlaces) { |
114 |
this.enlaces = enlaces;
|
115 |
} |
116 |
public double getStimation() { |
117 |
return stimation;
|
118 |
} |
119 |
public void setStimation(double estimacion) { |
120 |
this.stimation = estimacion;
|
121 |
} |
122 |
public int getFromLink() { |
123 |
return from_link;
|
124 |
} |
125 |
public void setFromLink(int from_link) { |
126 |
this.from_link = from_link;
|
127 |
} |
128 |
public ArrayList getTurns() { |
129 |
return giros;
|
130 |
} |
131 |
public void setTurns(ArrayList turns) { |
132 |
this.giros = turns;
|
133 |
} |
134 |
public int getNumSoluc() { |
135 |
return numSoluc;
|
136 |
} |
137 |
public void setNumSoluc(int numSoluc) { |
138 |
this.numSoluc = numSoluc;
|
139 |
} |
140 |
public int getStatus() { |
141 |
return status;
|
142 |
} |
143 |
public void setStatus(int status) { |
144 |
this.status = status;
|
145 |
} |
146 |
|
147 |
public void calculateStimation(GvNode finalNode, double newCost) { |
148 |
double DeltaX = ((finalNode.getX() - x)/1000.0)*((finalNode.getX() - x)/1000.0); |
149 |
double DeltaY = ((finalNode.getY() - y)/1000.0)*((finalNode.getY() - y)/1000.0); |
150 |
double distLineaRecta = Math.sqrt(DeltaX + DeltaY); // En Km |
151 |
stimation = newCost + (distLineaRecta* 30.0); // Segundos que tardamos en recorrer esos Km a 120 Km/hora |
152 |
|
153 |
|
154 |
} |
155 |
|
156 |
public double getAccumulatedLength() { |
157 |
return accumulatedLength;
|
158 |
} |
159 |
|
160 |
public void setAccumulatedLength(double accumulatedLength) { |
161 |
this.accumulatedLength = accumulatedLength;
|
162 |
} |
163 |
|
164 |
} |
165 |
|
166 |
|