Package com.apps.ubc.cc.model

Examples of com.apps.ubc.cc.model.BuildingModel


 
    public UBCWayfindingService(){   
    }

    public BuildingModel search(String in) {
      BuildingModel result = null;
      try {
        result = parseURLContent(getURLContentReader(in, "bldgName"));
        if(result == null){
          result = parseURLContent(getURLContentReader(in, "keyword"));
        }
        if(result == null) {
          String crsResult = crs.search(in);
          if(crsResult != null) {
            String[] latlong = gls.getLatLong(crsResult + ", Vancouver");
            return new BuildingModel(in, crsResult, "",latlong[0], latlong[1]);
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      } catch (Exception e) {
View Full Code Here


      return new BufferedReader(new InputStreamReader(
          new URL(url).openStream()));
    }

    private BuildingModel parseURLContent(BufferedReader br) throws IOException {
      BuildingModel bm = null;
      String name = "";
      String address = "";
      String pcode = "";
      String line = br.readLine();
      while (line != null) {
        if(line.contains("<td style=\"background:")) {
          name = line.substring(line.indexOf("<p>")+3,line.indexOf("</p>"));
          line = br.readLine();
          if(line!=null&&line.contains("<td style=\"background:")) {
            address = line.substring(line.indexOf("<p>")+3,line.indexOf("<br>"));
            pcode = line.substring(line.indexOf("<br>")+4,line.indexOf("</p>"));
            String[] latlong = gls.getLatLong(name + " " + pcode);
            bm = new BuildingModel(name, address, pcode, latlong[0], latlong[1]);
            break;
          }
        }
       
        line = br.readLine();
View Full Code Here

  private String replaceTag(SectionInformationObject section,
      String to_replace, String url) {

    // This is to get the lat/long
    UBCWayfindingService addrParser;
    BuildingModel addr;
    String buffer;

    addrParser = new UBCWayfindingService();
    addr = addrParser.search(section.getBuilding());

    buffer = addr.getLatitude();
    buffer = buffer.concat(",");
    buffer = buffer.concat(addr.getLongitude());

    return url.replace(to_replace, buffer);
  }
View Full Code Here

    for (int j = 0; j < course_list.size(); j++) {

      // This is to get the lat/long
      UBCWayfindingService addrParser;
      BuildingModel addr;

      addrParser = new UBCWayfindingService();
      addr = addrParser.search(course_list.get(j).getBuilding());

      if (addr != null) {
        LatLongModel geo = new LatLongModel(addr.getLatitude(),
            addr.getLongitude());
        sort_term.add(geo);
        System.out.println("Course name: "
            + course_list.get(j).getSectionId());
      }
View Full Code Here

    UBCCourseSpiderDatastore sd = new UBCCourseSpiderDatastore();
    SectionInformationObject sio = sd.querySectionFromId(d, c, s);
    CourseInformationObject cio = sd.queryCourseFromId(d, c);
   
    UBCWayfindingService uws = UBCWayfindingServiceFactory.getUBCWayfindingService();
    BuildingModel blo = uws.search(sio.getBuilding());
   
    String lat = "";
    String lng = "";
    if (blo != null) {
      lat = blo.getLatitude();
      lng = blo.getLongitude();
    }
   
    String dept = sio.getDepartmentId();
    String course = sio.getCourseId();
    String section = sio.getSectionId();
View Full Code Here

    String dept = sio.getDepartmentId();
    String course = sio.getCourseId();
    String section = sio.getSectionId();
    String day = sio.getDay();
    String term = sio.getTerm();
    BuildingModel blo = uws.search(sio.getBuilding());
    UBCSectionDetailService w = new UBCSectionDetailService();
    w.initContent(new UniqueCourseObject(dept,course,section));
    List<BookInformation> biol = w.getBookList();
   
    out += "<table>";
    out += "<tr>\n";
    out += "<td>"+dept+"&nbsp;"+course+"&nbsp;"+section+"</td>\n";
    out += "</tr>\n";
    out += "<tr>\n";
    out += "<td><b>Activity: </b>"+sio.getActivity()+"</td>\n";
    out += "<td><b>Term: </b>"+term+"</td>\n";
    out += "</tr>\n";
    out += "<tr>\n";
    out += "<td><b>Day: </b>"+day+"</td>\n";
    out += "<td><b>Time: </b>"+sio.getStart()+" - "+sio.getEnd()+"</td>\n";
    out += "</tr>\n";
    if(!sio.getInstructor().isEmpty()){
      out += "<tr>\n";
      out += "<td><b>Instructor: </b>"+sio.getInstructor()+"</td>\n";
      out += "</tr>\n";
    }
    if(blo != null) {
    out += "<tr>\n";
    out += "<td><b>Building: </b>"+sio.getBuilding()+"</td>\n";
    out += "<td><b>Room: </b>"+sio.getRoom()+"</td>\n";
    if(blo.getLatitude() != "" && blo.getLongitude() != "")
      out += "<td>"+"<img src=\"http://maps.googleapis.com/maps/api/staticmap?center="+blo.getLatitude()+","+blo.getLongitude()+"&zoom=17&size=320x320&markers=color:blue%7Clabel:S%7C"+blo.getLatitude()+","+blo.getLongitude()+"&maptype=hybrid&sensor=false\"  width=\"320\" height=\"320\">"+"</td>";
    out += "</tr>\n";
    }
    if(!biol.isEmpty()){
    out += "<tr>\n";
    out += "Books: \n";
View Full Code Here

  @Test
  public void test() { 
   
    UBCWayfindingService uws = UBCWayfindingServiceFactory.getUBCWayfindingService();
   
    BuildingModel bmod = uws.search("DMP");
   
   
    assertTrue(bmod.getAddress().equals("6245 Agronomy Road"));
   
   
  }
View Full Code Here

TOP

Related Classes of com.apps.ubc.cc.model.BuildingModel

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.