Search in sources :

Example 1 with FormatDescription

use of com.dexels.navajo.document.metadata.FormatDescription in project navajo by Dexels.

the class KMLMap method getKmlData.

/**
 * TODO: Make thread safe
 * @return
 */
public Binary getKmlData() {
    try {
        if (!isPointFile()) {
            File kmz = createKmlFile(inMessage);
            myKmzData = new Binary(kmz, false);
            kmz.delete();
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("kmz");
            fd.addMimeType("application/vnd.google-earth.kmz");
            myKmzData.setMimeType("application/vnd.google-earth.kmz");
            myKmzData.setFormatDescriptor(fd);
            return myKmzData;
        } else {
            File kml = createPointKmlFile(inMessage, messagePath);
            myKmzData = new Binary(kml, false);
            kml.delete();
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("kml");
            fd.addMimeType("application/vnd.google-earth.kml");
            myKmzData.setMimeType("application/vnd.google-earth.kml");
            myKmzData.setFormatDescriptor(fd);
            return myKmzData;
        }
    } catch (XMLParseException e) {
        logger.error("Error: ", e);
    } catch (IOException e) {
        logger.error("Error: ", e);
    }
    return null;
}
Also used : Binary(com.dexels.navajo.document.types.Binary) IOException(java.io.IOException) FormatDescription(com.dexels.navajo.document.metadata.FormatDescription) XMLParseException(com.dexels.navajo.document.nanoimpl.XMLParseException) File(java.io.File)

Example 2 with FormatDescription

use of com.dexels.navajo.document.metadata.FormatDescription in project navajo by Dexels.

the class KMLMap method getSvgData.

public Binary getSvgData() throws IOException {
    if (myKmzData == null) {
        getKmlData();
    }
    InputStream bis = myKmzData.getDataAsStream();
    ZipInputStream zis = new ZipInputStream(bis);
    ZipEntry ze = null;
    do {
        ze = zis.getNextEntry();
        if (ze != null && ze.getName().equals("doc.kml")) {
            SvgRenderer sr = new SvgRenderer();
            mySvgData = sr.renderToBinary(zis);
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("svg");
            fd.addMimeType("image/svg");
            myKmzData.setMimeType("image/svg");
            zis.close();
            return mySvgData;
        }
    } while (ze != null);
    zis.close();
    return null;
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) SvgRenderer(com.dexels.navajo.geo.renderer.SvgRenderer) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) FormatDescription(com.dexels.navajo.document.metadata.FormatDescription)

Aggregations

FormatDescription (com.dexels.navajo.document.metadata.FormatDescription)2 XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)1 Binary (com.dexels.navajo.document.types.Binary)1 SvgRenderer (com.dexels.navajo.geo.renderer.SvgRenderer)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1