@Test(expected = Exception.class) public void testNoGroundTruthDataset2() { assertNotNull(reader2); GroundTruth gt2 = reader2.getGroundTruth(); assertNotNull(gt2); GPSPoint home1 = gt2.getHomeLocation(1); assertNull(home1); assertNotNull(home1); }
@Test public void testGroundTruth() { assertNotNull(reader1); GroundTruth gt1 = reader1.getGroundTruth(); assertNotNull(gt1); GPSPoint home1 = gt1.getHomeLocation(1); assertNotNull(home1); assertTrue(home1.latitude >= 21.9779 && home1.latitude <= 21.9780); assertTrue(home1.longitude <= -159.3494 && home1.longitude >= -159.3495); GPSPoint home43344 = gt1.getHomeLocation(43344); assertNotNull(home43344); double dist = home1.distanceTo(home43344); assertTrue(dist >= 4246.5 && dist <= 4247.0); }
/** * Reads, parses the specified dataset, and constructs the SocialNetwork and GroundTruth objects. * The operation should correctly separate the ground truth data from the social network data, and * create 'gt', and 'sn'. * * @return true, if the operation is successful, false otherwise. */ public boolean read() { BufferedReader br = null; String currentLine; String[] lineArgs; long userId; GPSPoint home; // __________________________SETTING GROUND TRUTH__________________________ try { br = new BufferedReader(new FileReader(homesFilePath)); while ((currentLine = br.readLine()) != null) { // System.out.println(currentLine); lineArgs = currentLine.split(", "); // Implement CHECK here // System.out.println(lineArgs[0] + "::" + lineArgs[1] + "::" + lineArgs[2] + "::" // + lineArgs[3]); gt = new GroundTruth(); userId = Long.parseLong(lineArgs[0]); home = new GPSPoint(Double.parseDouble(lineArgs[1]), Double.parseDouble(lineArgs[2])); gt.setHomeLocation(userId, home); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null) br.close(); } catch (IOException e) { e.printStackTrace(); } } // __________________________SETTING SOCIAL NETWORK__________________________ try { br = new BufferedReader(new FileReader(edgesFilePath)); while ((currentLine = br.readLine()) != null) { lineArgs = currentLine.split(", "); sn = new SocialNetwork(); User user = new User(); // USER without userid? sn.addUser(user); if (!sn.setFriends(Long.parseLong(lineArgs[0]), Long.parseLong(lineArgs[1]))) return false; // ek k liye b false hua to loop toota } } catch (IOException e) { e.printStackTrace(); } return false; }