Previous: Manipulating Images Next: ISL Exercises Table of contents Index Glossary Images Frames U09-NRM-127: The role of Distributed Data Access Technologies in NRM - for ITC-IDV version 2.7 > Advanced Topics > ISL - Scripting with IDV

5.4.3 ISL - KMZ Generation
An in-depth look at an ISL that is used to generate Google Earth KMZ products. This uses the import, procedure, call and output tags.
  1. To start make an /home/idv/example directory.
  2. Right click on the link below and save the file to the example directory.
    example.isl
  3. You will need to create 2 bundles in the example directory:
    example1.jnlp
    example2.jnlp
  4. To run this:
    idv /home/idv/example/example.isl
    


Here is the list of bundles:

<?xml version="1.0" encoding="ISO-8859-1"?>
<isl
   loop="1"
   offscreen="false"
   debug="true">

<!-- 
This file shows how to generate google earth, quicktime, etc., products
using the isl. This also automatically generates an html page
(named from the target attribute in the generate_start call below)
and scp's  all of the files to a web site or cp's them somewhere

This file can be evaluated with:
idv bundles.isl

You can make your own version of this. You need to 
change the target, wwwroot and scpdest in the generate_start tag below
The wwwroot points to where the generated files reside.
The scpdest is used to scp the files to the web server (optional)
The cpdest is used to cp the files somewhere  (optional)


You need to do the following import to include the generate library
Then call generate_start, passing in the relevant arguments.
Then do successive generate calls
Then finish with  the generate_end call
 -->

<!-- 
Import the library

Normally we would just include  the system script
  <import file="/ucar/unidata/idv/isl/generate.isl"/>
-->

  <import file="/ucar/unidata/idv/isl/generate.isl"/>

<!--  <import file="${islpath}/generate.isl"/> -->

<!--
The generate_ flags allow you to control what is generated.
You can also include them in the generate calls to
override the default (e.g., don't generate a quicktime movie
for a particular bundle)

The filepath flag is where the products are first written out to

The "ignore_" part of ignore_scpdest comments out that attribute
If it was there we would try to scp the generated products to that
destination.
-->

  <generate_start 
        title="Example IDV Image Products"
        description="Some example image products generated by the IDV"
        target="examples"
        wwwroot="http://www.unidata.ucar.edu/software/idv/examples"
        ignore_cpdest="/some/path"
        ignore_scpdest="somemachine:/somepath"
        filepath="${islpath}"
        generate_html="1"
        generate_kmz="1"
        generate_mov="1"
        generate_animatedgif="1"
        generate_image="1"/>


<!-- 
Put any number of generate calls here. There should be a ${id}.jnlp file
in this directory.  You can make the .jnlp files from the idv by
doing a File-Save As and specifying a jnlp file. When asked you
should include the bundle in the jnlp file.


id  is used to uniquely identify the products

bundle is the bundle to load. Note: the {islpath} makes this relative to
where this isl file is

The transparency attribute can be "none" but is normally the background color
of the idv view that is being captured. We make this color transparent.

-->


  <generate
     id="example1"
     bundle="${islpath}/example1.jnlp"
     label="This is example 1"
     generate_kmz="1"
     generate_mov="1"
     generate_animatedgif="1">
  </generate>


  <generate
     id="example2"
     bundle="${islpath}/example2.jnlp"
     label="This is example 2"
     generate_kmz="1"
     generate_mov="1"
     generate_animatedgif="1">
  </generate>



  <generate_end/>

</isl>
example.isl


Here is the file that actually does the work. By default this is in the IDV library.

<?xml version="1.0" encoding="ISO-8859-1"?>
<group>
  <procedure
     name="generate_start"
     target="idvproducts"
     title="IDV Image Products"
     description=""
     scpdest=""
     cpdest=""
     generate_image="1"
     filepath="${islpath}"
     libpath="/data/idv/isl"
     generate_kmz="1"
     generate_html="1"
     generate_mov="1"
     generate_animatedgif="1">


    <property
       name="filepath"
       value="${filepath}"
       global="true"/>


    <property
       name="libpath"
       value="${libpath}"
       global="true"/>
    <property
       name="wwwroot"
       value="${wwwroot}"
       global="true"/>
    <property
       name="generate_kmz"
       value="${generate_kmz}"
       global="true"/>
    <property
       name="generate_mov"
       value="${generate_mov}"
       global="true"/>
    <property
       name="generate_image"
       value="${generate_image}"
       global="true"/>
    <property
       name="generate_animatedgif"
       value="${generate_animatedgif}"
       global="true"/>
    <property
       name="generate_html"
       value="${generate_html}"
       global="true"/>
    <property
       name="scpdest"
       value="${scpdest}"
       global="true"/>
    <property
       name="cpdest"
       value="${cpdest}"
       global="true"/>
    <property
       name="target"
       value="${target}"
       global="true"/>
    <property
       name="title"
       value="${title}"
       global="true"/>
    <property
       name="description"
       value="${description}"
       global="true"/>
    <property
       name="html"
       value=""
       global="true"/>
    <property
       name="kml"
       value=""
       global="true"/>
    <property
       name="imagecount"
       value="0"
       global="true"/>
    <append name="html">
<![CDATA[
<html>
<title>${title}</title>
<body>
<h3>${title}</h3>
${description}
<i>Generated: ${MMMMM} ${d}, ${yyyy} ${HH}:${mm} ${Z}</i><br>
<hr>
<table width="100%"><tr  valign="top">
]]>    </append>
  </procedure>

<!-- 
    Define the procedure to load in the bundle, generate the images, etc.  
    The transparency attribute is one of the default arguments used
  -->

  <procedure
     name="generate"
     thebundle=""
     label=""
     transparency="none">

    <if expr="'${thebundle}'==''">
       <then>
          <property name="bundle" value="${islpath}/${id}.jnlp"/>
       </then>
       <else>
          <property name="bundle" value="${thebundle}"/>
       </else>
    </if>

    <property name="jnlplink"><![CDATA[<a href="${bundle}">IDV Bundle</a> <br>]]></property>

    <increment name="imagecount"/>
    <if expr="${imagecount}>2">
      <append name="html">
<![CDATA[
</tr>
<tr><td> <p></td></tr>
<tr valign="top">
]]>      </append>
      <replace
         name="imagecount"
         value="1"/>
    </if>

<!-- Load in the bundle    -->
    <bundle file="${bundle}"/>

    <property
       name="movie_files"
       value=""/>
    <property
       name="links"
       value=""/>
    <if expr="${generate_kmz}">
      <append
         name="movie_files"
         value=",${filepath}/${id}.kmz"/>
      <append name="links"><![CDATA[<a href="${id}.kmz">Google Earth</a><br>]]></append>
    </if>
    <if expr="${generate_mov}">
      <append
         name="movie_files"
         value=",${filepath}/${id}.mov"/>
      <append name="links"><![CDATA[<a href="${id}.mov">Quicktime</a> <br>]]></append>
    </if>
    <if expr="${generate_animatedgif}">
      <append
         name="movie_files"
         value=",${filepath}/${id}.gif"/>
      <append name="links"><![CDATA[<a href="${id}.gif">Animated GIF</a> <br>]]></append>
    </if>

<!-- Generate the movie and the thumbnail   -->
<!--         kml_desc="<a href="http://www.unidata.ucar.edu/cgi-bin/idv/getbundle.jnlp?bundleurl=${wwwroot}/${bundle}">Run in the IDV</a> (Needs Java Webstart)"
-->
    <if expr="'${movie_files}'!=''">
      <movie
         file="${movie_files}"
         imageprefix="image_%count%"
         imagesuffix="png"
         kml_desc="<a href="${wwwroot}/${bundle}">Run in the IDV</a> (Needs Java Webstart)"
         kml_name="${label}"
         kml_visibility="0"
         kml_open="0">
        <transparent color="${transparency}"/>
      </movie>
    </if>
    <if expr="${generate_mov}">
      <generate_copy file="${filepath}/${id}.mov"/>
    </if>
    <if expr="${generate_animatedgif}">
      <generate_copy file="${filepath}/${id}.gif"/>
    </if>
    <if expr="${generate_kmz}">
      <generate_copy file="${bundle}"/>
      <generate_copy file="${filepath}/${id}.kmz"/>
      <append
         name="kml"
         fromfile="${libpath}/networklink.kml"/>
    </if>
    <if expr="${generate_image}">
      <image file="${filepath}/${id}.png">
        <transparent color="${transparency}"/>
      </image>
      <generate_copy file="${filepath}/${id}.png"/>
    </if>
    <if expr="${generate_html}">
      <image file="${filepath}/${id}_thumb.png">
        <resize width="300"/>
        <transparent color="${transparency}"/>
      </image>
      <generate_copy file="${filepath}/${id}_thumb.png"/>
      <append name="html">
<![CDATA[
<td><b>${label}</b><br><table><tr  valign="top"><td><img src="${id}_thumb.png">
</td> <td>
See it in:<br>
${links}
${jnlplink}
</td></tr></table>
${paramtext}
</td>
]]>      </append>
    </if>
  </procedure>
  <procedure name="generate_copy">
    <if expr="'${scpdest}'!=''">
      <exec command="scp ${file} ${scpdest}"/>
    </if>
    <if expr="'${cpdest}'!=''">
      <exec command="cp ${file} ${cpdest}"/>
    </if>
  </procedure>
  <procedure name="generate_end">
    <if expr="${generate_kmz}">
      <output file="${filepath}/${target}.kml">
        <output fromfile="${libpath}/header.kml"/>
        <output text="${kml}"/>
        <output fromfile="${libpath}/footer.kml"/>
      </output>
      <generate_copy file="${filepath}/${target}.kml"/>
    </if>

    <if expr="${generate_html}">
      <output file="${filepath}/${target}.html">
        <output text="${html}"/>
      </output>
      <generate_copy file="${filepath}/${target}.html"/>
    </if>
  </procedure>
</group>
generate.isl

 


Previous: Manipulating Images Next: ISL Exercises Table of contents Index Glossary Images Frames Français Español Portugese Italian Japanese Korean Russian Chinese-simp Chinese-trad Dutch German Greek Français Español Portugese Italian Japanese Korean Russian Chinese-simp Chinese-trad Dutch German Greek

U09-NRM-127: The role of Distributed Data Access Technologies in NRM - for ITC-IDV version 2.7 > Advanced Topics > ISL - Scripting with IDV