Class KMZWriter

  • All Implemented Interfaces:
    MatsimSomeWriter

    public class KMZWriter
    extends Object
    implements MatsimSomeWriter
    A writer for complex keyhole markup files used by Google Earth. It supports packing multiple kml-files into one zip-compressed file which can directly be read by Google Earth. The files will have the ending *.kmz.
    Author:
    mrieser
    • Constructor Detail

      • KMZWriter

        public KMZWriter​(String outFilename)
        Creates a new kmz-file and a writer for it and opens the file for writing.
        Parameters:
        outFilename - the location of the file to be written.
    • Method Detail

      • writeLinkedKml

        public void writeLinkedKml​(String filename,
                                   net.opengis.kml.v_2_2_0.KmlType kml)
        Adds the specified KML-object to the file.
        Parameters:
        filename - The internal filename of this kml-object in the kmz-file. Other kml-objects in the same kmz-file can reference this kml with the specified filename.
        kml - The KML-object to store in the file.
      • writeMainKml

        public void writeMainKml​(net.opengis.kml.v_2_2_0.KmlType kml)
        Writes the specified KML-object as the main kml into the file. The main kml is the one Google Earth reads when the file is opened. It should contain NetworkLinks to the other KMLs stored in the same file.
        Parameters:
        kml - the KML-object that will be read by Google Earth when opening the file.
      • close

        public void close()
        Closes this file for writing.
      • addNonKMLFile

        public void addNonKMLFile​(String filename,
                                  String inZipFilename)
                           throws IOException
        Adds a file to the kmz which is not a kml file.
        Parameters:
        filename - the path to the file, relative or absolute
        inZipFilename - the filename used for the file in the kmz file
        Throws:
        IOException
      • addNonKMLFile

        public void addNonKMLFile​(InputStream data,
                                  String inZipFilename)
                           throws IOException
        Adds some data as a file to the kmz. The data stream will be closed at the end of the method.
        Parameters:
        data - the data to add to the kmz
        inZipFilename - the filename used for the file in the kmz file
        Throws:
        IOException
      • addNonKMLFile

        public void addNonKMLFile​(byte[] data,
                                  String inZipFilename)
                           throws IOException
        Adds a file (in form of a byte array) to a kml file.
        Parameters:
        data -
        inZipFilename - inZipFilename the filename used for the file in the kmz file
        Throws:
        IOException