コード例 #1
0
  public void OnGetDistanceDocumentComplete(Document doc, int i, int j) {
    int distance = md.getDistanceValue(doc);
    adj[i][j] = distance;
    docAdj[i][j] = doc;

    if ((vertices.size() * vertices.size()) - vertices.size() == counter.incrementAndGet()) {
      findOptimalPath();
    }
  }
コード例 #2
0
  public void showOptimalPath(Document doc) {
    ArrayList<LatLng> directionPoint = md.getDirection(doc);
    PolylineOptions rectLine = new PolylineOptions().width(8).color(Color.BLUE);

    for (int i = 0; i < directionPoint.size(); i++) {
      rectLine.add(directionPoint.get(i));
    }
    googleMap.addPolyline(rectLine);
  }
コード例 #3
0
 private void generateAdjacencyMatrix() {
   for (int i = 0; i < vertices.size(); i++) {
     for (int j = 0; j < vertices.size(); j++) {
       if (i != j) {
         if (adj[i][j] == 0) {
           md.getDocument(
               new LatLng(vertices.get(i).getLatitude(), vertices.get(i).getLongitude()),
               new LatLng(vertices.get(j).getLatitude(), vertices.get(j).getLongitude()),
               GMapV2Direction.MODE_DRIVING,
               this,
               i,
               j);
         }
       }
     }
   }
 }