Statistics
| Revision:

root / trunk / extensions / extGraph_predes / src / com / iver / cit / gvsig / graph / core / Network.java @ 8261

History | View | Annotate | Download (17.1 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.awt.geom.PathIterator;
44
import java.awt.geom.Point2D;
45
import java.util.ArrayList;
46

    
47
import com.iver.cit.gvsig.fmap.DriverException;
48
import com.iver.cit.gvsig.fmap.core.IFeature;
49
import com.iver.cit.gvsig.fmap.core.IGeometry;
50
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
51
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
52
import com.iver.cit.gvsig.fmap.layers.FBitSet;
53
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
54
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
55
import com.iver.cit.gvsig.graph.GraphException;
56
import com.vividsolutions.jts.geom.Coordinate;
57
import com.vividsolutions.jts.geom.Geometry;
58
import com.vividsolutions.jts.geom.LineSegment;
59
import com.vividsolutions.jts.geom.MultiLineString;
60

    
61
public class Network {
62
        protected FLyrVect lyrVect;
63

    
64
        protected IGraph graph;
65

    
66
        protected ArrayList flags = new ArrayList();
67

    
68
        protected int numOriginalEdges;
69

    
70
        protected int numOriginalNodes;
71

    
72
        public void reconstruyeTramo(int idArc) {
73
                // TODO Auto-generated method stub
74

    
75
        }
76

    
77
        private int findClosestArc(double x, double y, double tolerance) {
78
                Point2D p = new Point2D.Double(x, y);
79
                FBitSet bitSet;
80
                try {
81
                        bitSet = lyrVect.queryByPoint(p, tolerance);
82
                        VectorialAdapter va = (VectorialAdapter) lyrVect.getSource();
83
                        double minDist = tolerance;
84
                        int foundGeom = -1;
85
                        for (int i = bitSet.nextSetBit(0); i >= 0; i = bitSet
86
                                        .nextSetBit(i + 1)) {
87
                                IGeometry geom;
88
                                geom = va.getShape(i);
89
                                Point2D nearest = getNearestPoint(p, geom, tolerance);
90
                                if (nearest != null) {
91
                                        double dist = nearest.distance(p);
92
                                        if (dist < minDist) {
93
                                                minDist = dist;
94
                                                foundGeom = i;
95
                                        }
96
                                }
97
                        }
98
                        return foundGeom;
99
                } catch (DriverException e1) {
100
                        // TODO Auto-generated catch block
101
                        e1.printStackTrace();
102
                } catch (DriverIOException e) {
103
                        // TODO Auto-generated catch block
104
                        e.printStackTrace();
105
                }
106
                return -1;
107

    
108
        }
109

    
110
        protected Point2D getNearestPoint(Point2D point, IGeometry geom,
111
                        double tolerance) {
112
                Point2D resul = null;
113
                Coordinate c = new Coordinate(point.getX(), point.getY());
114

    
115
                PathIterator theIterator = geom.getPathIterator(null,
116
                                FConverter.FLATNESS); // polyLine.getPathIterator(null,
117
                                                                                // flatness);
118
                double[] theData = new double[6];
119
                double minDist = tolerance;
120
                Coordinate from = null, first = null;
121
                while (!theIterator.isDone()) {
122
                        // while not done
123
                        int theType = theIterator.currentSegment(theData);
124

    
125
                        switch (theType) {
126
                        case PathIterator.SEG_MOVETO:
127
                                from = new Coordinate(theData[0], theData[1]);
128
                                first = from;
129
                                break;
130

    
131
                        case PathIterator.SEG_LINETO:
132

    
133
                                // System.out.println("SEG_LINETO");
134
                                Coordinate to = new Coordinate(theData[0], theData[1]);
135
                                LineSegment line = new LineSegment(from, to);
136
                                Coordinate closestPoint = line.closestPoint(c);
137
                                double dist = c.distance(closestPoint);
138
                                if ((dist < minDist)) {
139
                                        resul = new Point2D.Double(closestPoint.x, closestPoint.y);
140
                                        minDist = dist;
141
                                }
142

    
143
                                from = to;
144
                                break;
145
                        case PathIterator.SEG_CLOSE:
146
                                line = new LineSegment(from, first);
147
                                closestPoint = line.closestPoint(c);
148
                                dist = c.distance(closestPoint);
149
                                if ((dist < minDist)) {
150
                                        resul = new Point2D.Double(closestPoint.x, closestPoint.y);
151
                                        minDist = dist;
152
                                }
153

    
154
                                from = first;
155
                                break;
156

    
157
                        } // end switch
158

    
159
                        theIterator.next();
160
                }
161

    
162
                return resul;
163
        }
164

    
165
        /**
166
         * TODO: POR TERMINAR!!!
167
         * 
168
         * @param flag
169
         * @return
170
         */
171
        public int creaArcosVirtuales(GvFlag flag) {
172
                // Devuelve el idNodo del nodo virtual creado.
173
                /*
174
                 * 0.- Creamos el nuevo Nodo virtual. 1.- Recorremos los arcos nuevos
175
                 * mirando su idTramo. 2.- Si existe ese idtramo=> Ya hemos partido
176
                 * antes ese idTramo. Buscamos el arco virtual que contiene ese nodo y
177
                 * lo partimos. Ojo, recorrer hasta el final los tramos para asegurarnos
178
                 * de que es el trozo m?s peque?o. 3.- Si NO existe, utilizamos el
179
                 * IndiceArcos para coger los arcos que toca y partirlos.
180
                 * 
181
                 * 4.- OJO: Si el porcentaje es 0 ? 100, no partimos el arco, devolvemos
182
                 * el id del nodo que toca.
183
                 */
184
                // NUEVO: 20/7/2004:
185
                // Cuando trabajamos con sentidos, al partir un arco no podemos insertar
186
                // 2 nuevos sin mirar
187
                // si es o no de un ?nico sentido.) (Mirar idArco. Si es -1, no partimos
188
                // el arco).
189
                // FIN NUEVO
190
                int idNodo1, idNodo2;
191
                int idArco, elIdArco, elIdContraArco;
192
                boolean encontrado;
193
                GvNode newNode;
194

    
195
                // Sacamos los idNodos del tramo
196
                EdgePair edgePair = graph.getEdgesByIdArc(flag.getIdArc());
197
                if (edgePair.getIdEdge() != -1) {
198
                        // idNodo1 = Arcos[IndiceArcos[idTramo].idArco].idNodo1;
199
                        // idNodo2 = Arcos[IndiceArcos[idTramo].idArco].idNodo2;
200
                        idNodo1 = graph.getEdgeByID(edgePair.getIdEdge()).getIdNodeOrig();
201
                        idNodo2 = graph.getEdgeByID(edgePair.getIdEdge()).getIdNodeEnd();
202

    
203
                } else {
204
                        // idNodo2 = Arcos[IndiceArcos[idTramo].idContraArco].idNodo1;
205
                        // idNodo1 = Arcos[IndiceArcos[idTramo].idContraArco].idNodo2;
206
                        idNodo2 = graph.getEdgeByID(edgePair.getIdInverseEdge())
207
                                        .getIdNodeOrig();
208
                        idNodo1 = graph.getEdgeByID(edgePair.getIdInverseEdge())
209
                                        .getIdNodeEnd();
210

    
211
                }
212

    
213
                if (flag.getPct() == 0)
214
                        return idNodo1;
215
                if (flag.getPct() == 1)
216
                        return idNodo2;
217

    
218
                // Creamos el nodo de enmedio
219

    
220
                // if (numNodos == maxNodos) // La jodimos, T?rtola, hay que usar
221
                // reallocate
222
                // {
223
                // // NOTA: ESTO EN DEBUG HACE QUE FALLE AL USAR DESPUES EnlacesSTL. ES
224
                // POR NO S? QU? HISTORIA
225
                // // DEL HEAP. EN RELEASE NO FALLA. (TAMPOCO S? SI FASTIDIA ALGO).
226
                // Nodos = (CNode *) realloc(Nodos,(numNodos + MAX_RESERVA_NODOS) *
227
                // sizeof(CNode)); // Deber?amos chequear que devuelve algo correcto
228
                // maxNodos = numNodos + MAX_RESERVA_NODOS;
229
                // }
230

    
231
                newNode = new GvNode();
232
                // Nodo = &Nodos[numNodos];
233

    
234
                // pNuevoNodo->idNodo = numNodos;
235
                newNode.setIdNode(graph.numVertices());
236

    
237
                // OJO: Las coordenadas estas puede que no tengan que ver con la
238
                // realidad. Algo m?s correcto
239
                // ser?a tener en cuenta el shape de verdad, pero creo que no influye en
240
                // el resultado final.
241
                // pNuevoNodo->x = Nodos[idNodo1].x + (Nodos[idNodo2].x -
242
                // Nodos[idNodo1].x) * Porcentaje;
243
                // pNuevoNodo->y = Nodos[idNodo1].y + (Nodos[idNodo2].y -
244
                // Nodos[idNodo1].y) * Porcentaje;
245
                GvNode node1 = graph.getNodeByID(idNodo1);
246
                GvNode node2 = graph.getNodeByID(idNodo2);
247
                newNode.setX(node1.getX() + (node2.getX() - node1.getX())
248
                                * flag.getPct());
249
                newNode.setY(node1.getY() + (node2.getY() - node1.getY())
250
                                * flag.getPct());
251
                graph.addNode(newNode);
252
                Coordinate newC = new Coordinate(newNode.getX(), newNode.getY());
253

    
254
                encontrado = false;
255

    
256
                elIdArco = -1;
257
                elIdContraArco = -1;
258

    
259
                boolean bIdTramoYaPartido = false;
260

    
261
                // TODO: POR AQUI VOY
262
                for (idArco = numOriginalEdges; idArco < graph.numEdges(); idArco++) {
263
                        GvEdge addedEdge = graph.getEdgeByID(idArco);
264
                        if (addedEdge.getIdArc() == flag.getIdArc()) {
265
                                bIdTramoYaPartido = true;
266

    
267
                                idNodo1 = addedEdge.getIdNodeOrig();
268
                                idNodo2 = addedEdge.getIdNodeEnd();
269

    
270
                                // Comprobamos si est? enmedio
271
                                GvNode n1 = graph.getNodeByID(idNodo1);
272
                                GvNode n2 = graph.getNodeByID(idNodo2);
273
                                Coordinate c1 = new Coordinate(n1.getX(), n1.getY());
274
                                Coordinate c2 = new Coordinate(n2.getX(), n2.getY());
275
                                LineSegment line = new LineSegment(c1, c2);
276
                                double t = line.projectionFactor(newC);
277

    
278
                                // Si la proyecci?n es positiva y menor que la magnitud d, est?
279
                                // en medio
280
                                if ((t >= 0) && (t <= 1)) {
281
                                        encontrado = true;
282
                                        if (t == 0)
283
                                                return idNodo1; // No partimos
284
                                        if (t == 1)
285
                                                return idNodo2; // Tampoco partimos
286

    
287
                                        if (addedEdge.getDirec() == 1)
288
                                                elIdArco = idArco;
289
                                        else
290
                                                elIdContraArco = idArco;
291

    
292
                                } // if est? enmedio
293
                        } // if idTramo encontrado
294
                } // for idArco
295
                if (bIdTramoYaPartido && (!encontrado))
296
                        throw new RuntimeException(
297
                                        "Algo va mal con lo del producto escalar");
298

    
299
                if (encontrado) {
300
                        // sprintf(Mensaje,"Voy a partir el idTramo= %ld (idArco
301
                        // %ld)",idTramo,elIdArco);
302
                        // MessageBox(NULL,Mensaje,"",MB_OK);
303
                        if (elIdArco != -1)
304
                                PartirArco(elIdArco, newNode.getIdNode());
305

    
306
                        if (elIdContraArco != -1)
307
                                PartirArco(elIdContraArco, newNode.getIdNode());
308
                } else {
309
                        // Creamos 2 Arcos por cada arco que ten?amos antes.
310
                        if (edgePair.getIdEdge() != -1)
311
                                PartirArco(edgePair.getIdEdge(), newNode.getIdNode());
312

    
313
                        if (edgePair.getIdInverseEdge() != -1)
314
                                PartirArco(edgePair.getIdInverseEdge(), newNode.getIdNode());
315

    
316
                } // else encontrado
317

    
318
                return newNode.getIdNode();
319

    
320
        }
321

    
322
        /**
323
         * TODO: Por ahora, cogemos el nodo m?s cercano. Lo correcto es a?adir un
324
         * nuevo nodo que divida el arco, y devolver el id de ese nodo.
325
         * 
326
         * @param flag
327
         * @return
328
         */
329
        public int creaArcosVirtualesSimple(GvFlag flag) {
330
                EdgePair pair = graph.getEdgesByIdArc(flag.getIdArc());
331
                if (pair.getIdEdge() != -1) {
332
                        GvEdge edge = graph.getEdgeByID(pair.getIdEdge());
333
                        GvNode from = graph.getNodeByID(edge.getIdNodeOrig());
334
                        GvNode to = graph.getNodeByID(edge.getIdNodeEnd());
335

    
336
                        double dist1 = flag.getOriginalPoint().distance(from.getX(),
337
                                        from.getY());
338
                        double dist2 = flag.getOriginalPoint().distance(to.getX(),
339
                                        to.getY());
340
                        if (dist1 < dist2)
341
                                return from.getIdNode();
342
                        else
343
                                return to.getIdNode();
344
                        // if (flag.getPct() > 0.5)
345
                        // return to.getIdNode();
346
                        // else
347
                        // return from.getIdNode();
348
                } else {
349
                        GvEdge edge = graph.getEdgeByID(pair.getIdInverseEdge());
350
                        GvNode from = graph.getNodeByID(edge.getIdNodeOrig());
351
                        GvNode to = graph.getNodeByID(edge.getIdNodeEnd());
352

    
353
                        double dist1 = flag.getOriginalPoint().distance(from.getX(),
354
                                        from.getY());
355
                        double dist2 = flag.getOriginalPoint().distance(to.getX(),
356
                                        to.getY());
357
                        if (dist1 < dist2)
358
                                return from.getIdNode();
359
                        else
360
                                return to.getIdNode();
361

    
362
                        // if (flag.getPct() < 0.5)
363
                        // return to.getIdNode();
364
                        // else
365
                        // return from.getIdNode();
366
                }
367
        }
368

    
369
        /**
370
         * @param idArc
371
         * @param x
372
         * @param y
373
         * @return entre 0.0 y 1.0
374
         * @throws DriverIOException
375
         */
376
        private double percentAlong(int idArc, double x, double y)
377
                        throws DriverIOException {
378
                // Le pasamos el idTramo, la coordenada X de donde hemos pulsado y la
379
                // coordenada Y
380
                // Primero calculamos la longitud total del shape.
381
                // Luego calculamos el punto m?s cercano y su distancia para cada
382
                // segmento del shape.
383
                // Nos quedamos con el que est? m?s cerca y luego recorremos hasta ?l
384
                // acumulando distancia.
385
                // Finalmente, dividimos esa distancia por la longitud total.
386
                IGeometry geom = lyrVect.getSource().getShape(idArc);
387
                MultiLineString jtsGeom = (MultiLineString) geom.toJTSGeometry();
388

    
389
                Coordinate[] coords = jtsGeom.getCoordinates();
390

    
391
                Coordinate userCoord = new Coordinate(x, y);
392

    
393
                double longReal = 0;
394
                // Le pegamos una primera pasada para saber su longitud real.
395
                // OJO, NO TRABAJAMOS CON SHAPES MULTIPARTE, NO TIENE SENTIDO CON LAS
396
                // REDES (CREO)
397
                // POR ESO SUPONEMOS UNA ?NICA PARTE (L?NEA CONT?NUA)
398
                // A la vez calculamos el punto m?s cercano y su distancia para cada
399
                // segmento.
400
                double minDist = Double.MAX_VALUE;
401
                double distTo = 0;
402
                double dist = 0;
403
                Coordinate cOrig = null;
404
                Coordinate closestPoint = null;
405
                for (int j = 0; j < coords.length - 1; j++) {
406
                        Coordinate c1 = coords[j];
407
                        Coordinate c2 = coords[j + 1];
408
                        LineSegment line = new LineSegment(c1, c2);
409

    
410
                        Coordinate auxPoint = line.closestPoint(userCoord);
411
                        dist = userCoord.distance(auxPoint);
412
                        if ((dist < minDist)) {
413
                                minDist = dist;
414
                                cOrig = c1;
415
                                closestPoint = auxPoint;
416
                                distTo = longReal;
417
                        }
418
                        longReal += line.getLength();
419
                }
420

    
421
                dist = cOrig.distance(closestPoint);
422
                double longBuscada = distTo + dist;
423

    
424
                double pct;
425
                if (longReal > 0)
426
                        pct = longBuscada / longReal;
427
                else
428
                        pct = 0.0;
429

    
430
                return pct;
431
        }
432

    
433
        /**
434
         * Adds a flag on a network. flagDirection set if the flag must be on left
435
         * or right edge.
436
         * 
437
         * @param x
438
         * @param y
439
         * @param flagDirection
440
         * @param tol
441
         *            tolerance in map units
442
         * @return null if there is no place to add flag. You can increase the
443
         *         tolerance, then.
444
         * @throws GraphException
445
         */
446
        public GvFlag addFlag(double x, double y, int flagDirection, double tol)
447
                        throws GraphException {
448
                try {
449
                        int idArc = findClosestArc(x, y, tol);
450
                        if (idArc == -1)
451
                                return null;
452
                        GvFlag flag = new GvFlag(x, y);
453
                        flag.setIdArc(idArc);
454

    
455
                        flag.setPct(percentAlong(idArc, x, y));
456
                        flag.setDirec(flagDirection);
457
                        flag.setIdFlag(flags.size());
458
                        return flag;
459
                } catch (DriverIOException e) {
460
                        e.printStackTrace();
461
                        throw new GraphException(e);
462
                }
463

    
464
        }
465

    
466
        /**
467
         * Adds 2 flags on a network. (On both sides of an arc)
468
         * 
469
         * @param x
470
         * @param y
471
         * @param tol
472
         *            tolerance in map units
473
         * @return null if there is no place to add flag. You can increase the
474
         *         tolerance, then.
475
         * @throws GraphException 
476
         */
477
        public GvFlag addFlag(double x, double y, double tol) throws GraphException {
478
                try {
479
                        int idArc = findClosestArc(x, y, tol);
480
                        if (idArc == -1)
481
                                return null;
482

    
483
                        GvFlag flag = new GvFlag(x, y);
484
                        flag.setIdArc(idArc);
485
                        flag.setDirec(GvFlag.BOTH_DIRECTIONS);
486

    
487
                        flag.setPct(percentAlong(idArc, x, y));
488
                        flag.setIdFlag(flags.size());
489
                        flags.add(flag);
490
                        return flag;
491
                } catch (DriverIOException e) {
492
                        e.printStackTrace();
493
                        throw new GraphException(e);
494
                }
495

    
496
        }
497

    
498
        public void addFlag(GvFlag flag) {
499
                flags.add(flag);
500
        }
501

    
502
        public GvFlag[] getFlags() {
503
                return (GvFlag[]) flags.toArray(new GvFlag[0]);
504
        }
505

    
506
        public void setFlags(ArrayList flags) {
507
                this.flags = flags;
508
        }
509

    
510
        public IGraph getGraph() {
511
                return graph;
512
        }
513

    
514
        public void setGraph(IGraph graph) {
515
                this.graph = graph;
516
                numOriginalEdges = graph.numEdges();
517
                numOriginalNodes = graph.numVertices();
518
        }
519

    
520
        public FLyrVect getLayer() {
521
                return lyrVect;
522
        }
523

    
524
        public void setLayer(FLyrVect lyr) {
525
                this.lyrVect = lyr;
526
        }
527

    
528
        public void removeFlags() {
529
                flags = new ArrayList();
530
        }
531

    
532
        void PartirArco(int idEdge, int idNode) {
533
                // Se supone que el nuevo Nodo YA est? creado. Aqui dentro se coge el
534
                // arco viejo y se le pega un tajo.
535
                // (Se modifican los enlaces de los nodos de ese arco y se crean los
536
                // arcos nuevos, fijando sus costes).
537
                // Para sacar el porcentaje nos aprovechamos de que el nuevo nodo est?
538
                // puesto en base a ese porcentaje
539
                // en distancia de los extremos.
540
                GvEdge oldEdge;
541
                GvNode pN1, pN2;
542
                double pct;
543

    
544
                oldEdge = graph.getEdgeByID(idEdge);
545

    
546
                // OJO, controlando los ceros por si acaso la recta es horizontal o
547
                // vertical (Y si mide cero???)
548

    
549
                // pN1 = &Nodos[Arcos[idArco].idNodo1];
550
                // pN2 = &Nodos[Arcos[idArco].idNodo2];
551
                pN1 = graph.getNodeByID(graph.getEdgeByID(idEdge).getIdNodeOrig());
552
                pN2 = graph.getNodeByID(graph.getEdgeByID(idEdge).getIdNodeEnd());
553
                GvNode newNode = graph.getNodeByID(idNode);
554

    
555
                if (newNode.getX() != pN1.getX())
556
                        pct = Math.abs((newNode.getX() - pN1.getX())
557
                                        / (pN2.getX() - pN1.getX()));
558
                else
559
                        pct = Math.abs((newNode.getY() - pN1.getY())
560
                                        / (pN2.getY() - pN1.getY()));
561

    
562
                GvEdge first = new GvEdge();
563
                first.setIdEdge(graph.numEdges());
564
                first.setIdArc(oldEdge.getIdArc());
565
                first.setDistance(oldEdge.getDistance() * pct);
566
                first.setWeight(oldEdge.getWeight() * pct);
567

    
568
                first.setDirec(oldEdge.getDirec());
569
                first.setIdNodeOrig(oldEdge.getIdNodeOrig());
570
                first.setType(oldEdge.getType());
571
                first.setIdNodeEnd(idNode);
572
                graph.addEdge(first);
573

    
574
                GvEdge second = new GvEdge();
575
                second.setIdEdge(graph.numEdges());
576
                second.setDistance(oldEdge.getDistance() * (1.0 - pct));
577
                second.setWeight(oldEdge.getWeight() * (1.0 - pct));
578
                second.setIdArc(oldEdge.getIdArc());
579
                second.setDirec(oldEdge.getDirec());
580
                second.setType(oldEdge.getType());
581
                second.setIdNodeOrig(idNode);
582
                second.setIdNodeEnd(oldEdge.getIdNodeEnd());
583
                graph.addEdge(second);
584

    
585
                // ////////////////////////////////////////////////////
586
                // Ahora retocamos los enlaces que salen de cada nodo
587
                // ////////////////////////////////////////////////////
588
                int i;
589
                // boolean encontrado = false;
590
                for (i = 0; i < pN1.getEnlaces().size(); i++) {
591
                        GvEdge aux = (GvEdge) pN1.getEnlaces().get(i);
592
                        if (aux.getIdEdge() == idEdge) {
593
                                pN1.getEnlaces().set(i, first);
594
                                // encontrado = true;
595
                                break;
596
                        }
597
                } // for
598

    
599
                newNode.getEnlaces().add(second);
600

    
601
        }
602

    
603
}