Statistics
| Revision:

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
/* 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
public class GvNode {
46
        public final static int statNotInList = 0;
47
        public final static int statNowInList = 1;
48
        public final static int statWasInList = 2;
49
        private int idNode;
50
        private double x;
51
        private double y;
52
        
53
        int from_link = -1; // id del Arco desde el que hemos llegado
54
        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

    
60
        double best_cost = Double.MAX_VALUE;
61
        double accumulatedLength = 0;
62
        double stimation = Double.MAX_VALUE; // bestCost + algo relacionado con la distancia al destino
63
        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
        public GvNode() {
69
                initialize();
70
        }
71
        
72
        public void initialize() {
73
                numSoluc = AbstractNetSolver.numSolucGlobal;
74
                from_link = -1;
75
                best_cost = Double.MAX_VALUE;
76
                stimation = Double.MAX_VALUE;
77
                accumulatedLength = 0;
78
                status = statNotInList;
79

    
80
        }
81
        
82
        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
        public double getBestCost() {
101
                return best_cost;
102
        }
103
        public void setBestCost(double best_cost) {
104
                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
        public double getStimation() {
113
                return stimation;
114
        }
115
        public void setStimation(double estimacion) {
116
                this.stimation = estimacion;
117
        }
118
        public int getFromLink() {
119
                return from_link;
120
        }
121
        public void setFromLink(int from_link) {
122
                this.from_link = from_link;
123
        }
124
        public ArrayList getTurns() {
125
                return giros;
126
        }
127
        public void setTurns(ArrayList turns) {
128
                this.giros = turns;
129
        }
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
        public void calculateStimation(GvNode finalNode, double newCost) {
144
                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
                stimation = newCost + (distLineaRecta* 30.0);  // Segundos que tardamos en recorrer esos Km a 120 Km/hora
148

    
149
                
150
        }
151

    
152
        public double getAccumulatedLength() {
153
                return accumulatedLength;
154
        }
155

    
156
        public void setAccumulatedLength(double accumulatedLength) {
157
                this.accumulatedLength = accumulatedLength;
158
        }
159

    
160
}
161

    
162