示例#1
0
 private Segment createSegmentFromEdges(long edgeId, long segmentId, boolean isEdgeOrigin) {
   double length = 0.0;
   Segment seg = null;
   try {
     List<Edge> subset = null;
     seg = db.ReadSegment(segmentId);
     ArrayList<Edge> edges = db.ReadEdges(segmentId);
     Edge edge = null;
     if (!edges.isEmpty()) {
       if (isEdgeOrigin) {
         edge =
             edges
                 .stream()
                 .filter(
                     (Edge e) -> {
                       return e.mOrigin == edgeId;
                     })
                 .findFirst()
                 .get();
       } else {
         edge =
             edges
                 .stream()
                 .filter(
                     (Edge e) -> {
                       return e.mDestination == edgeId;
                     })
                 .findFirst()
                 .get();
       }
       int index = edges.indexOf(edge);
       subset = edges.subList(index, edges.size());
       for (Edge ed : subset) {
         length = +ed.mLength;
       }
     }
     long origin, destination;
     origin = (isEdgeOrigin ? edgeId : seg.mOrigin);
     destination = (isEdgeOrigin ? seg.mDestination : edgeId);
     Segment s = new Segment(nextSegId++, length, seg.mWayId, origin, destination);
     return s;
   } catch (SQLException e) {
     System.err.println("Error getting segmentid from method modelNodeToSegment");
     e.printStackTrace();
   }
   return null;
 }