svn-gvsig-desktop / tags / PilotoRedes_Build_4 / extensions / extGraph_predes / src / com / iver / cit / gvsig / graph / core / GvNode.java @ 12191
History | View | Annotate | Download (4.29 KB)
1 | 7841 | fjp | /* 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 | 7951 | fjp | import java.util.ArrayList; |
44 | |||
45 | 7841 | fjp | public class GvNode { |
46 | 7985 | fjp | public final static int statNotInList = 0; |
47 | public final static int statNowInList = 1; |
||
48 | public final static int statWasInList = 2; |
||
49 | 7951 | fjp | private int idNode; |
50 | private double x; |
||
51 | private double y; |
||
52 | |||
53 | 8028 | fjp | int from_link = -1; // id del Arco desde el que hemos llegado |
54 | 7951 | fjp | int numSoluc = 0; // Empezamos con esto a cero en toda la red. |
55 | // De manera global, habr? una variable numSolucGlobal que indica el n? de cada petici?n de ruta.
|
||
56 | // Sirve para no tener que inicializar siempre tooooda la red. Lo que hacemos es comparar el
|
||
57 | // n? de petici?n global con este. Si no coinciden, antes de hacer nada hay que inicializar su
|
||
58 | // best_cost a infinito.
|
||
59 | 7841 | fjp | |
60 | 7951 | fjp | double best_cost = Double.MAX_VALUE; |
61 | 11631 | fjp | double accumulatedLength = 0; |
62 | 8522 | fjp | double stimation = Double.MAX_VALUE; // bestCost + algo relacionado con la distancia al destino |
63 | 7951 | fjp | int status;
|
64 | ArrayList enlaces = new ArrayList(); // Enlaces con los vecinos |
||
65 | ArrayList giros = new ArrayList(); // Costes de los giros. Si existe un CGiro, miraremos su coste y lo a?adimos. |
||
66 | // Si es negativo, suponemos que es un giro prohibido.
|
||
67 | |||
68 | 8211 | fjp | public GvNode() {
|
69 | initialize(); |
||
70 | } |
||
71 | |||
72 | 7985 | fjp | public void initialize() { |
73 | numSoluc = AbstractNetSolver.numSolucGlobal; |
||
74 | from_link = -1;
|
||
75 | best_cost = Double.MAX_VALUE;
|
||
76 | 8522 | fjp | stimation = Double.MAX_VALUE;
|
77 | 12157 | fjp | accumulatedLength = 0;
|
78 | 7985 | fjp | status = statNotInList; |
79 | |||
80 | } |
||
81 | |||
82 | 7951 | fjp | public int getIdNode() { |
83 | return idNode;
|
||
84 | } |
||
85 | public void setIdNode(int idNode) { |
||
86 | this.idNode = idNode;
|
||
87 | } |
||
88 | public double getX() { |
||
89 | return x;
|
||
90 | } |
||
91 | public void setX(double x) { |
||
92 | this.x = x;
|
||
93 | } |
||
94 | public double getY() { |
||
95 | return y;
|
||
96 | } |
||
97 | public void setY(double y) { |
||
98 | this.y = y;
|
||
99 | } |
||
100 | 7985 | fjp | public double getBestCost() { |
101 | 7951 | fjp | return best_cost;
|
102 | } |
||
103 | 7985 | fjp | public void setBestCost(double best_cost) { |
104 | 7951 | fjp | this.best_cost = best_cost;
|
105 | } |
||
106 | public ArrayList getEnlaces() { |
||
107 | return enlaces;
|
||
108 | } |
||
109 | public void setEnlaces(ArrayList enlaces) { |
||
110 | this.enlaces = enlaces;
|
||
111 | } |
||
112 | 8522 | fjp | public double getStimation() { |
113 | return stimation;
|
||
114 | 7951 | fjp | } |
115 | 8522 | fjp | public void setStimation(double estimacion) { |
116 | this.stimation = estimacion;
|
||
117 | 7951 | fjp | } |
118 | 8028 | fjp | public int getFromLink() { |
119 | 7951 | fjp | return from_link;
|
120 | } |
||
121 | 8028 | fjp | public void setFromLink(int from_link) { |
122 | 7951 | fjp | this.from_link = from_link;
|
123 | } |
||
124 | 7985 | fjp | public ArrayList getTurns() { |
125 | 7951 | fjp | return giros;
|
126 | } |
||
127 | 7985 | fjp | public void setTurns(ArrayList turns) { |
128 | 8192 | azabala | this.giros = turns;
|
129 | 7951 | fjp | } |
130 | public int getNumSoluc() { |
||
131 | return numSoluc;
|
||
132 | } |
||
133 | public void setNumSoluc(int numSoluc) { |
||
134 | this.numSoluc = numSoluc;
|
||
135 | } |
||
136 | public int getStatus() { |
||
137 | return status;
|
||
138 | } |
||
139 | public void setStatus(int status) { |
||
140 | this.status = status;
|
||
141 | } |
||
142 | |||
143 | 8523 | fjp | public void calculateStimation(GvNode finalNode, double newCost) { |
144 | 8522 | fjp | double DeltaX = ((finalNode.getX() - x)/1000.0)*((finalNode.getX() - x)/1000.0); |
145 | double DeltaY = ((finalNode.getY() - y)/1000.0)*((finalNode.getY() - y)/1000.0); |
||
146 | double distLineaRecta = Math.sqrt(DeltaX + DeltaY); // En Km |
||
147 | 8523 | fjp | stimation = newCost + (distLineaRecta* 30.0); // Segundos que tardamos en recorrer esos Km a 120 Km/hora |
148 | 8522 | fjp | |
149 | |||
150 | } |
||
151 | |||
152 | 11631 | fjp | public double getAccumulatedLength() { |
153 | return accumulatedLength;
|
||
154 | } |
||
155 | |||
156 | public void setAccumulatedLength(double accumulatedLength) { |
||
157 | this.accumulatedLength = accumulatedLength;
|
||
158 | } |
||
159 | |||
160 | 7841 | fjp | } |
161 |