Package org.geotools.graph.path

Examples of org.geotools.graph.path.Path


        List<Edge> edgeList = new ArrayList<Edge>();
        for ( int i = 0; i < list.size() - 1; i++ ) {
            DijkstraShortestPathFinder pf = new DijkstraShortestPathFinder( graph, list.get( i ), weighter );
            pf.calculate();
            Path path = pf.getPath( list.get( i + 1 ) );
            if ( path != null ) {
                edgeList.addAll( path.getEdges() );
            }
        }
        mapboard.put( "path", edgeList );
        layer.refresh( null );
View Full Code Here


      MyVisitor visitor = new MyVisitor();
      builder().getGraph().visitNodes(visitor);
      //#1
      assertTrue(visitor.count > 0);
      assertTrue(visitor.count < map.size() + 1);
      Path p = null;
    try {
      p = walker.getPath();
    } catch (Exception e) {
      e.printStackTrace();
    }
      p.getEdges();
      assertTrue(p.size() == 4);
      // #2
      for (int j = 0; j < p.size() - 1; j++) {
        Node n = (Node) p.get(j);
        Node parent = (Node) p.get(j + 1);
        String n_id = rmap.get(n).toString();
        String parent_id = rmap.get(parent).toString();
        assertTrue(n_id.startsWith(parent_id));
      }
    }
View Full Code Here

        Iterator it1 = graph.getNodes().iterator();

        while (it1.hasNext()) {
            Node d = (Node) it1.next();

            Path path = pf.getPath((Graphable) d);

            gotArray.add(pf.getCost(d));

        }
View Full Code Here

    DijkstraShortestPathFinder pfinder = new DijkstraShortestPathFinder(
      builder().getGraph(), ends[0], costFunction()
    );
   
    pfinder.calculate();
    Path p = pfinder.getPath(ends[1]);
   
    int count = 99;
    for (Iterator itr = p.iterator(); itr.hasNext();) {
      Node n = (Node)itr.next();
      assertTrue(n.getID() == count--);
    }
  }
View Full Code Here

    DijkstraShortestPathFinder pfinder = new DijkstraShortestPathFinder(
      builder().getGraph(), ends[0], costFunction()
    );
   
    pfinder.calculate();
    Path p = pfinder.getPath(ends[1]);
   
    assertTrue(p.size() == 2);
    assertTrue(p.get(0) == ends[1]);
    assertTrue(p.get(1) == ends[0]);
  }
View Full Code Here

    for (Iterator itr = builder().getGraph().getNodes().iterator(); itr.hasNext();) {
      Node node = (Node)itr.next();
      String id = node.getObject().toString();
     
      if (id2node.get(id + ".0") == null) {
        Path p = pfinder.getPath(node);
        assertTrue(p.size() == k+1)
    
        for (Iterator pitr = p.iterator(); pitr.hasNext();) {
          Node n = (Node)pitr.next();
          assertTrue(n.getObject().toString().equals(id));
          if (id.length() > 2) id = id.substring(0, id.length()-2);
        }   
      } 
View Full Code Here

        //get the graph node closest to the destination point object
        Node destination = nodeHelper.getNearestGraphNode(lineStringGen, networkGraph, destinationPoint, coordinateReferenceSystem);
        //get the path (route) from origin to destination
        Logger.d("Calc route feature, destination: " + destination);
        Path path = shortestPathFinder.getPath(destination);
        //Logger.d("Calc route feature, path: " + path);

        //this happens if the closest node is the endpoint of a disconnected line
        if (path == null) {
            Logger.w("Could not calculate the route to this destination" +
                    ". There is probably a problem with the network data set (dangles etc ...)");
            return false;
        }

        //create a vector object to store all the edges
        Vector result = new Vector();
        Node previous = null;
        Node node;

        //iterate through the path object getting each node and it's neighbour and build edge objects from them
        for (Iterator iterator = path.riterator(); iterator.hasNext();) {
            node = (Node) iterator.next();
            if (previous != null) {
                // Adds the resulting edge into the vector
                result.add(node.getEdge(previous));
            }
View Full Code Here

TOP

Related Classes of org.geotools.graph.path.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.