コード例 #1
0
    @Override
    protected SchedulePlot doInBackground(SchedulePlot... params) {

      // The params[0] element contains the schedulePlot object
      SchedulePlot scheduleToPlot = params[0];

      // construct a list of geopoints for the schedule
      List<GeoPoint> geoPoints = new ArrayList<GeoPoint>();

      // sections of given schedule
      SortedSet<Section> sectionsOfSchedule = scheduleToPlot.getSections();
      // if the schedule has sections all at same location, or have 0 or 1 section,
      // then there is no route to be plotted
      if (sectionsOfSchedule.size() == 0 || sectionsOfSchedule.size() == 1) {
        scheduleToPlot.setRoute(null);
      } else {
        Iterator<Section> iterator = sectionsOfSchedule.iterator();
        Section prev = iterator.next();
        while (iterator.hasNext()) {
          Section next = iterator.next();
          LatLon prevLatLon = prev.getBuilding().getLatLon();
          LatLon nextLatLon = next.getBuilding().getLatLon();
          geoPoints.addAll(getGeoPoints(getJSON(prevLatLon, nextLatLon)));
          prev = next;
        }

        // set the route of the schedule by setting the geopoints
        scheduleToPlot.setRoute(geoPoints);
      }

      // CPSC 210 Students: Complete this method. This method should
      // call the MapQuest webservice to retrieve a List<GeoPoint>
      // that forms the routing between the buildings on the
      // schedule. The List<GeoPoint> should be put into
      // scheduleToPlot object.

      return scheduleToPlot;
    }
コード例 #2
0
  /**
   * Plot all buildings referred to in the given information about plotting a schedule.
   *
   * @param schedulePlot All information about the schedule and route to plot.
   */
  private void plotBuildings(SchedulePlot schedulePlot) {

    // CPSC 210 Students: Complete this method by plotting each building in the
    // schedulePlot with an appropriate message displayed
    if (schedulePlot.getSections().size() == 0) {
      AlertDialog aDialog = createSimpleDialog("Schedule To Plot Is Empty");
      aDialog.show();
    } else {
      for (Section s : schedulePlot.getSections()) {
        plotABuilding(
            s.getBuilding(),
            "Building: " + s.getBuilding().getName(),
            "Schedule for: " + schedulePlot.getName() + " " + s.getCourseInfo(),
            schedulePlot.getIcon());
      }
    }

    // CPSC 210 Students: You will need to ensure the buildingOverlay is in
    // the overlayManager. The following code achieves this. You should not likely
    // need to touch it
    OverlayManager om = mapView.getOverlayManager();
    om.add(buildingOverlay);
  }