--- android/TrainInfoService/src/dk/thoerup/traininfoservice/RequestPlotter.java 2011/04/19 16:31:11 1311 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/RequestPlotter.java 2011/04/19 16:39:07 1312 @@ -17,7 +17,6 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.zip.GZIPInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -85,18 +84,10 @@ return Arrays.copyOfRange(logFiles, from, to); } - protected PositionContainer getRequestsFromFileWorker(boolean multiple) throws IOException{ + protected PositionContainer getRequestsFromFileWorker(int count) throws IOException{ PositionContainer positions = new PositionContainer(); - try { - - int count; - - if (multiple == false) { - count = 1; - } else { - count = 4; - } + try { File files[] = getFiles(count); @@ -345,20 +336,16 @@ return sb.toString(); } - protected String getRequestsFromFile(boolean multiple) throws IOException { + protected String getRequestsFromFile(int count) throws IOException { String kmlData = null; String key; - if (multiple == false) { - key = "kmldata"; - } else { - key = "kmldata-multi"; - } + key = "kmldata-" + count; - kmlData = null;// = cache.get(key); + kmlData = cache.get(key); if (kmlData == null) { - kmlData = formatXml( getRequestsFromFileWorker(multiple) ); + kmlData = formatXml( getRequestsFromFileWorker(count) ); cache.put(key, kmlData); kmlData += ""; } else { @@ -384,9 +371,13 @@ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - boolean multiple = enabled( req.getParameter("multi") ); - String kmlData = getRequestsFromFile(multiple); + int count = Integer.parseInt( req.getParameter("count") ); + + if (count > 30) //limit to 30 days + count = 30; + + String kmlData = getRequestsFromFile(count); if ( enabled(req.getParameter("zip")) ) {