Package org.geotools.graph.structure

Examples of org.geotools.graph.structure.Node


        public int visit(Graphable component) {
          if (component.getID() == 50) return(Graph.PASS_AND_CONTINUE);
          return(Graph.FAIL_QUERY)
        }
     };
     Node source = (Node)builder().getGraph().queryNodes(visitor).get(0);
    
     CountingWalker walker = new CountingWalker();
     BreadthFirstIterator iterator = createIterator();
    
     BasicGraphTraversal traversal = new BasicGraphTraversal(
View Full Code Here


    m_maxitr = maxitr;
    m_maxplen = maxplen;
  }
 
  public Path getPath(Node from, Node to) {
       final Node dst = to;
       GraphVisitor visitor = new GraphVisitor() {
         public int visit(Graphable component) {
         if (component.equals(dst)) return(END_PATH_AND_STOP);
         return(CONTINUE_PATH);
         }
View Full Code Here

       if (paths.isEmpty()) return(null);
       return((Path)paths.get(0));
  }
 
  public List getPaths(Node from, Node to) {
    final Node dst = to;
    GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
      if (component.equals(dst)) return(END_PATH_AND_CONTINUE);
      return(CONTINUE_PATH);
    }
View Full Code Here

    stack.push(from);
   
    int iterations = 0;
O: while(!stack.isEmpty() && (iterations++ < m_maxitr)) {
      //peek the stack
      Node top = (Node)stack.peek();
     
      switch(visitor.visit(top)) {
        case END_PATH_AND_CONTINUE:
          paths.add(new Path(stack));
          stack.pop();
          continue;
       
        case END_PATH_AND_STOP:
          paths.add(new Path(stack));
          break O;
       
        case KILL_PATH:
          stack.pop();
          continue;
         
        case CONTINUE_PATH:
         
       
      }
     
      Iterator related = null;
      if ((related = (Iterator)node2related.get(top)) == null) {
        related = top.getRelated();
        node2related.put(top,related);
      }
     
      while(stack.size() < m_maxplen && related.hasNext()) {
        Node adj = (Node)related.next();
        if (stack.contains(adj)) continue;
       
        //push adjacent onto stack, and reset iterator
        stack.push(adj);
        node2related.put(adj, adj.getRelated());
     
        continue O;
      }
       
      //all adjacent have been processed or are in stack
View Full Code Here

   
    index = new Quadtree();
  }
 
  public Graphable add(Object obj) {
    Node node = (Node) get(obj);
    if (node == null) {
      node = builder.buildNode();
      builder.addNode(node);
     
      node.setObject(obj);
      relate(node);
     
      //TODO: the envelope should be buffered by some tolerance
      index.insert(((Polygon)obj).getEnvelopeInternal(),node);
    }
View Full Code Here

        */
        public Path getPath() throws WrongPathException {
                Path path = new Path();

                path.add(m_target);
                Node parent = m_iterator.getParent(m_target);
                while ( parent != null ) {
                        path.add(parent);
                        parent =  m_iterator.getParent(parent);
                }
                if (!path.getLast().equals(m_iterator.getSource())) {
View Full Code Here

    Polygon polygon = (Polygon)obj;
    return find(polygon);
  }

  public Graphable remove(Object obj) {
    Node node = (Node) get(obj);
    if (node != null) {
      Polygon polygon = (Polygon) node.getObject();
      index.remove(polygon.getEnvelopeInternal(),node);
     
      builder.removeNode(node);
    }
   
View Full Code Here

  }
 
  protected Node find(Polygon polygon) {
    List close = index.query(polygon.getEnvelopeInternal());
    for (Iterator itr = close.iterator(); itr.hasNext();) {
      Node node = (Node)itr.next();
      Polygon p = (Polygon)node.getObject();
     
      if (rel.equal(polygon,p)) {
        return node;
      }
    }
View Full Code Here

  protected void relate(Node node) {
    Polygon polygon = (Polygon)node.getObject();
    List close = index.query(polygon.getEnvelopeInternal());
   
    for (Iterator itr = close.iterator(); itr.hasNext();) {
      Node n = (Node)itr.next();
      Polygon p = (Polygon)n.getObject();
     
      if (!rel.equal(polygon,p) && rel.related(polygon,p)) {
        Edge edge = builder.buildEdge(node,n);
        builder.addEdge(edge);
        builder.addEdge(edge);
View Full Code Here

   
    return(edge)
  }
 
  public Node getNode(Coordinate c) {
    Node n = (Node)m_in2count.get(c);
   
    if (n != null) return(n);
    return((Node)m_out2count.get(c));
  }
View Full Code Here

TOP

Related Classes of org.geotools.graph.structure.Node

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.