@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;
    }
  /**
   * 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);
  }
  /** Initialize the CourseFactory with some courses. */
  private void initializeCourses() {
    // CPSC 210 Students: You can change this data if you desire.
    CourseFactory courseFactory = CourseFactory.getInstance();

    Building dmpBuilding = new Building("DMP", new LatLon(49.261474, -123.248060));

    Course cpsc210 = courseFactory.getCourse("CPSC", 210);
    Section aSection = new Section("202", "MWF", "12:00", "12:50", dmpBuilding);
    cpsc210.addSection(aSection);
    aSection.setCourse(cpsc210);
    aSection = new Section("201", "MWF", "16:00", "16:50", dmpBuilding);
    cpsc210.addSection(aSection);
    aSection.setCourse(cpsc210);
    aSection = new Section("BCS", "MWF", "12:00", "12:50", dmpBuilding);
    cpsc210.addSection(aSection);
    aSection.setCourse(cpsc210);

    Course engl222 = courseFactory.getCourse("ENGL", 222);
    aSection =
        new Section(
            "007",
            "MWF",
            "14:00",
            "14:50",
            new Building("Buchanan", new LatLon(49.269258, -123.254784)));
    engl222.addSection(aSection);
    aSection.setCourse(engl222);

    Course scie220 = courseFactory.getCourse("SCIE", 220);
    aSection =
        new Section(
            "200",
            "MWF",
            "15:00",
            "15:50",
            new Building("Swing", new LatLon(49.262786, -123.255044)));
    scie220.addSection(aSection);
    aSection.setCourse(scie220);

    Course math200 = courseFactory.getCourse("MATH", 200);
    aSection =
        new Section(
            "201",
            "MWF",
            "09:00",
            "09:50",
            new Building("Buchanan", new LatLon(49.269258, -123.254784)));
    math200.addSection(aSection);
    aSection.setCourse(math200);

    Course fren102 = courseFactory.getCourse("FREN", 102);
    aSection =
        new Section(
            "202",
            "MWF",
            "11:00",
            "11:50",
            new Building("Barber", new LatLon(49.267442, -123.252471)));
    fren102.addSection(aSection);
    aSection.setCourse(fren102);

    Course japn103 = courseFactory.getCourse("JAPN", 103);
    aSection =
        new Section(
            "002",
            "MWF",
            "10:00",
            "11:50",
            new Building("Buchanan", new LatLon(49.269258, -123.254784)));
    japn103.addSection(aSection);
    aSection.setCourse(japn103);

    Course scie113 = courseFactory.getCourse("SCIE", 113);
    aSection =
        new Section(
            "213",
            "MWF",
            "13:00",
            "13:50",
            new Building("Swing", new LatLon(49.262786, -123.255044)));
    scie113.addSection(aSection);
    aSection.setCourse(scie113);

    Course micb308 = courseFactory.getCourse("MICB", 308);
    aSection =
        new Section(
            "201",
            "MWF",
            "12:00",
            "12:50",
            new Building("Woodward", new LatLon(49.264704, -123.247536)));
    micb308.addSection(aSection);
    aSection.setCourse(micb308);

    Course math221 = courseFactory.getCourse("MATH", 221);
    aSection =
        new Section(
            "202",
            "TR",
            "11:00",
            "12:20",
            new Building("Klinck", new LatLon(49.266112, -123.254776)));
    math221.addSection(aSection);
    aSection.setCourse(math221);

    Course phys203 = courseFactory.getCourse("PHYS", 203);
    aSection =
        new Section(
            "201",
            "TR",
            "09:30",
            "10:50",
            new Building("Hennings", new LatLon(49.266400, -123.252047)));
    phys203.addSection(aSection);
    aSection.setCourse(phys203);

    Course crwr209 = courseFactory.getCourse("CRWR", 209);
    aSection =
        new Section(
            "002",
            "TR",
            "12:30",
            "13:50",
            new Building("Geography", new LatLon(49.266039, -123.256129)));
    crwr209.addSection(aSection);
    aSection.setCourse(crwr209);

    Course fnh330 = courseFactory.getCourse("FNH", 330);
    aSection =
        new Section(
            "002",
            "TR",
            "15:00",
            "16:20",
            new Building("MacMillian", new LatLon(49.261167, -123.251157)));
    fnh330.addSection(aSection);
    aSection.setCourse(fnh330);

    Course cpsc499 = courseFactory.getCourse("CPSC", 430);
    aSection =
        new Section(
            "201", "TR", "16:20", "17:50", new Building("Liu", new LatLon(49.267632, -123.259334)));
    cpsc499.addSection(aSection);
    aSection.setCourse(cpsc499);

    Course chem250 = courseFactory.getCourse("CHEM", 250);
    aSection =
        new Section(
            "203",
            "TR",
            "10:00",
            "11:20",
            new Building("Klinck", new LatLon(49.266112, -123.254776)));
    chem250.addSection(aSection);
    aSection.setCourse(chem250);

    Course eosc222 = courseFactory.getCourse("EOSC", 222);
    aSection =
        new Section(
            "200", "TR", "11:00", "12:20", new Building("ESB", new LatLon(49.262866, -123.25323)));
    eosc222.addSection(aSection);
    aSection.setCourse(eosc222);

    Course biol201 = courseFactory.getCourse("BIOL", 201);
    aSection =
        new Section(
            "201",
            "TR",
            "14:00",
            "15:20",
            new Building("BioSci", new LatLon(49.263920, -123.251552)));
    biol201.addSection(aSection);
    aSection.setCourse(biol201);

    Course math302 = courseFactory.getCourse("MATH", 302);
    aSection =
        new Section(
            "201",
            "MWF",
            "11:00",
            "11:50",
            new Building("LSK", new LatLon(49.265557, -123.255291)));
    math302.addSection(aSection);
    aSection.setCourse(math302);

    Course japn100 = courseFactory.getCourse("JAPN", 100);
    aSection =
        new Section(
            "022",
            "MWF",
            "14:00",
            "14:50",
            new Building("Buchanan", new LatLon(49.269258, -123.254784)));
    japn100.addSection(aSection);
    aSection.setCourse(japn100);
  }