Statistics
| Revision:

svn-gvsig-desktop / tags / PilotoRedes_Build_3 / extensions / extGraph_predes / src / com / iver / cit / gvsig / graph / core / GvNode.java @ 11678

History | View | Annotate | Download (4.27 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
                status = statNotInList;
78

    
79
        }
80
        
81
        public int getIdNode() {
82
                return idNode;
83
        }
84
        public void setIdNode(int idNode) {
85
                this.idNode = idNode;
86
        }
87
        public double getX() {
88
                return x;
89
        }
90
        public void setX(double x) {
91
                this.x = x;
92
        }
93
        public double getY() {
94
                return y;
95
        }
96
        public void setY(double y) {
97
                this.y = y;
98
        }
99
        public double getBestCost() {
100
                return best_cost;
101
        }
102
        public void setBestCost(double best_cost) {
103
                this.best_cost = best_cost;
104
        }
105
        public ArrayList getEnlaces() {
106
                return enlaces;
107
        }
108
        public void setEnlaces(ArrayList enlaces) {
109
                this.enlaces = enlaces;
110
        }
111
        public double getStimation() {
112
                return stimation;
113
        }
114
        public void setStimation(double estimacion) {
115
                this.stimation = estimacion;
116
        }
117
        public int getFromLink() {
118
                return from_link;
119
        }
120
        public void setFromLink(int from_link) {
121
                this.from_link = from_link;
122
        }
123
        public ArrayList getTurns() {
124
                return giros;
125
        }
126
        public void setTurns(ArrayList turns) {
127
                this.giros = turns;
128
        }
129
        public int getNumSoluc() {
130
                return numSoluc;
131
        }
132
        public void setNumSoluc(int numSoluc) {
133
                this.numSoluc = numSoluc;
134
        }
135
        public int getStatus() {
136
                return status;
137
        }
138
        public void setStatus(int status) {
139
                this.status = status;
140
        }
141

    
142
        public void calculateStimation(GvNode finalNode, double newCost) {
143
                double DeltaX = ((finalNode.getX() - x)/1000.0)*((finalNode.getX() - x)/1000.0);
144
                double DeltaY = ((finalNode.getY() - y)/1000.0)*((finalNode.getY() - y)/1000.0);
145
                double distLineaRecta = Math.sqrt(DeltaX + DeltaY); // En Km
146
                stimation = newCost + (distLineaRecta* 30.0);  // Segundos que tardamos en recorrer esos Km a 120 Km/hora
147

    
148
                
149
        }
150

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

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

    
159
}
160

    
161