public List<Period> getIndoorData(String manipulatedString) { /* * 127.36504046 36.3742216 9.0 1407381330 * 127.36506211 36.37423924 11.0 1407381340 * 127.36496859 36.37421911 11.0 1407381350 * 127.3648429 36.37416071 11.0 1407381360 * 127.36469597 36.37409721 11.0 1407381370 */ List<Period> indoorPeriods = new ArrayList<Period>(); String[] lines = manipulatedString.split("\n"); boolean isIndoorStart = false; Period period = new Period(); long lastPeriod = 0; for (int i = 0; i < lines.length; i++) { String line = lines[i]; String[] elements = line.split("\t"); if (elements.length == 4) { int numSatellites = (int) Double.parseDouble(elements[2]); if (isIndoorStart == false && numSatellites < 6) { isIndoorStart = true; period = new Period(); period.setLongitude(Double.parseDouble(elements[0])); period.setLatitude(Double.parseDouble(elements[1])); period.setFrom(Long.parseLong(elements[3])); } else if (isIndoorStart == false && numSatellites != 0) { // Keep going } else if (isIndoorStart == true && numSatellites == 0) { // Keep going } else if (isIndoorStart == true && numSatellites >= 6) { isIndoorStart = false; period.setTo(Long.parseLong(elements[3])); // We assume that Staying a place over 10 minutes is indoor if (period.getTo() - period.getFrom() >= 600) { // System.out.println(" [Location Clusterer] : [DEBUG] Success " + (period.getTo() - // period.getFrom())); indoorPeriods.add(period); } else { // System.out.println(" [Location Clusterer] : [DEBUG] Fail " + (period.getTo() - // period.getFrom())); } } lastPeriod = Long.parseLong(elements[3]); } } if (isIndoorStart == true) { period.setTo(lastPeriod); // We assume that Staying a place over 10 minutes is indoor if (period.getTo() - period.getFrom() >= 600) { // System.out.println(" [Location Clusterer] : [DEBUG] Success " + (period.getTo() - // period.getFrom())); indoorPeriods.add(period); } else { // System.out.println(" [Location Clusterer] : [DEBUG] Fail " + (period.getTo() - // period.getFrom())); } } return indoorPeriods; }