/** * Java to KML * The object graph is marshalled to a File object. * The object is not saved as a zipped .kmz file. * @see marshalKmz(String, Kml...) * */ public boolean marshal(final File filename) throws FileNotFoundException { OutputStream out = new FileOutputStream(filename); return this.marshal(out); }
/** * Java to KML * The object graph is marshalled to a File object. * The object is not saved as a zipped .kmz file. * @see marshalKmz(String, Kml...) * */ public boolean marshal(final File filename) throws FileNotFoundException { OutputStream out = new FileOutputStream(filename); return this.marshal(out); }
final Kml kml = new Kml(); Document document = kml.createAndSetDocument(); listForms = formDAO.getAll(); for (Form list : listForms){ document.createAndAddPlacemark() .withName(String.valueOf(list.getId())) .withDescription(list.toStringKML()) .createAndSetPoint().addToCoordinates(-20.3978398, -43.5146653); } kml.setFeature(document); kml.marshal(new File("test.kml"));
/** * Internal method * */ private void addKmzFile(Kml kmzFile, ZipOutputStream out, boolean mainfile) throws IOException { String fileName = null; if (((kmzFile.getFeature() == null)||(kmzFile.getFeature().getName() == null))||(kmzFile.getFeature().getName().length() == 0)) { fileName = (("noFeatureNameSet"+ missingNameCounter ++)+".kml"); } else { fileName = kmzFile.getFeature().getName(); if (!fileName.endsWith(".kml")) { fileName += ".kml"; } } if (mainfile) { fileName = "doc.kml"; } out.putNextEntry(new ZipEntry(URLEncoder.encode(fileName, "UTF-8"))); kmzFile.marshal(out); out.closeEntry(); }
/** * Internal method * */ private void addKmzFile(Kml kmzFile, ZipOutputStream out, boolean mainfile) throws IOException { String fileName = null; if (((kmzFile.getFeature() == null)||(kmzFile.getFeature().getName() == null))||(kmzFile.getFeature().getName().length() == 0)) { fileName = (("noFeatureNameSet"+ missingNameCounter ++)+".kml"); } else { fileName = kmzFile.getFeature().getName(); if (!fileName.endsWith(".kml")) { fileName += ".kml"; } } if (mainfile) { fileName = "doc.kml"; } out.putNextEntry(new ZipEntry(URLEncoder.encode(fileName, "UTF-8"))); kmzFile.marshal(out); out.closeEntry(); }
kml.marshal(out); String test = out.toString(); Writer outUTF8;
kml.marshal(outputFile); logger.info("KML file published. Location:" + outputFile.getAbsolutePath());