Strabon

changeset 134:ddaa14997077

KMZ in endpoint too
author Manos Karpathiotakis <mk@di.uoa.gr>
date Tue May 08 18:35:48 2012 +0300 (2012-05-08)
parents abb14d6fd936
children de305c240be4
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Tue May 08 18:32:08 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Tue May 08 18:35:48 2012 +0300
     1.3 @@ -169,7 +169,15 @@
     1.4  					file.createNewFile();
     1.5  				}
     1.6  
     1.7 -				FileWriter fw = new FileWriter(basePath + temp + ".kml");
     1.8 +				FileWriter fw = null;
     1.9 +				if(hive.getFormat().equalsIgnoreCase("KML"))
    1.10 +				{
    1.11 +					fw = new FileWriter(basePath + temp + ".kml");
    1.12 +				}
    1.13 +				else //KMZ
    1.14 +				{
    1.15 +					fw = new FileWriter(basePath + temp + ".kmz");
    1.16 +				}
    1.17  				BufferedWriter bw = new BufferedWriter(fw);
    1.18  				bw.write(answer);
    1.19  				bw.close();
    1.20 @@ -177,31 +185,7 @@
    1.21  
    1.22  				//System.out.println("Done");
    1.23  
    1.24 -				if (hive.getFormat().equalsIgnoreCase("KMZ")) {
    1.25 -					//compress
    1.26 -					byte[] buf = new byte[1024];
    1.27 -					String outFilename = basePath + temp + ".kmz";
    1.28 -					ZipOutputStream kmzout = new ZipOutputStream(new FileOutputStream(outFilename));
    1.29 -
    1.30 -					// Compress the files
    1.31 -					FileInputStream in = new FileInputStream(basePath + temp + ".kml");
    1.32 -
    1.33 -					// Add ZIP entry to output stream.
    1.34 -					kmzout.putNextEntry(new ZipEntry("doc.kml"));
    1.35 -
    1.36 -					// Transfer bytes from the file to the ZIP file
    1.37 -					int len;
    1.38 -					while ((len = in.read(buf)) > 0) {
    1.39 -						kmzout.write(buf, 0, len);
    1.40 -					}
    1.41 -
    1.42 -					// Complete the entry
    1.43 -					kmzout.closeEntry();
    1.44 -					in.close();
    1.45 -
    1.46 -					// Complete the ZIP file
    1.47 -					kmzout.close();
    1.48 -				}
    1.49 +				
    1.50  			} catch(IOException e) {
    1.51  				e.printStackTrace();
    1.52  			}