<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>11. Metacat’s Use of Geoserver &mdash; Metacat 2.19.0 documentation</title>
    <link rel="stylesheet" href="_static/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="_static/font-awesome/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/metacatui.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2.19.0',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Metacat 2.19.0 documentation" href="index.html" />
    <link rel="prev" title="10. Metacat Authentication Mechanism" href="authinterface.html" />
    <link rel="next" title="12. Replication" href="replication.html" /> 
  </head>
  <body>
  <div id="metacatDocs">
	  <div class="banner">
	      <a href="index.html"><img class="logo" src="_static/metacat-logo-white.png" /></a>
	      <a href="index.html"><h1 class="title">Metacat: Metadata and Data Management Server</h1></a>
	      <img class="logo-right" src="_static/nceas-logo-white.png" />
	  </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right">
        <span id="searchbox" style="display: none;">
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" />
              <input type="submit" value="Go" class="icon-search"/>
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </span>
        </li>
        <script type="text/javascript">$('#searchbox').show(0);</script>
        <li class="right">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a>
           </li>
        <li class="right">
          <a href="replication.html" title="12. Replication"
             accesskey="N">next</a>
           </li>
        <li class="right">
          <a href="authinterface.html" title="10. Metacat Authentication Mechanism"
             accesskey="P">previous</a>
           </li>
        <li class="breadcrumb first"><a href="index.html">Metacat 2.19.0 documentation</a> &raquo;</li> 
      </ul>
      
    </div>

	
    <div class="document">
     	 <div class="documentwrapper">
	        <div class="bodywrapper">
	          <div class="body">
	            
  <div class="section" id="metacat-s-use-of-geoserver">
<h1>11. Metacat’s Use of Geoserver<a class="headerlink" href="#metacat-s-use-of-geoserver" title="Permalink to this headline">¶</a></h1>
<p>GeoServer 2.0.2, an open source Web Mapping Service (WMS) written in Java, is
bundled with Metacat and can be used to render spatial data as web-deliverable
maps. Metacat uses OpenLayers (<a class="reference external" href="http://openlayers.org/">http://openlayers.org/</a>) to provide a web-based
user interface for interacting with the generated maps. You can use any
WMS-compatible client (e.g., ArcGIS, QGIS, JUMP, UDig, OpenLayers, Mapbender,
Map Builder).</p>
<p>IMPORTANT: Regardless of whether you plan on using the mapping functionality
you should, for security purposes, configure GeoServer so that it doesn’t
use the default password. For instructions, please see
Geoserver Configuration.</p>
<div class="figure align-center" id="id1">
<img alt="_images/image051.jpg" src="_images/image051.jpg" />
<p class="caption"><span class="caption-text">A map generated by Metacat’s GeoServer. Points and “bounding boxes”
represent the geographic extent of datasets stored in the KNB Metacat repository.</span></p>
</div>
<p>GeoServer supports a wide variety of vector GIS data sources, which can be
styled using Styled Layer Descriptors (SLDs) and output as images (the default)
or raw vector data (GML or KML).</p>
<p>Currently, GeoServer can be used with the following limitations:</p>
<ul class="simple">
<li>GeoServer will only map documents that are publicly available. This is
because the mapping server’s support for permissions control is not as
fine-grained as Metacat’s.</li>
</ul>
<p>Metacat developers plan to continue extending and improving Metacat’s mapping
capabilities. If you are interested in contributing to those efforts, or if
you are interested in learning more about the architecture and future plans for
the mapping software, please contact the Metacat  development
team  (<a class="reference external" href="mailto:metacat-dev&#37;&#52;&#48;ecoinformatics&#46;org">metacat-dev<span>&#64;</span>ecoinformatics<span>&#46;</span>org</a>).</p>
<div class="section" id="installing-and-configuring">
<h2>11.1. Installing and Configuring<a class="headerlink" href="#installing-and-configuring" title="Permalink to this headline">¶</a></h2>
<p>The GeoServer webapp should be installed as a sibling of Metacat. If you do
NOT wish to run GeoServer, the deployment can be skipped, but any skins that
use maps will not render correctly. (NOTE: Geoserver recommends using a PermGen
space setting of at least 128MB.).</p>
<p>Metacat comes with a pre-configured data directory to be used by GeoServer.
This includes a world-countries base layer and a default configuration that
is already aware of Metacat’s spatial cache. The Metacat configuration interface
is used to configure GeoServer to use this shared data directory. To further
configure GeoServer, use the Web-based configuration utility,
which is available at: <a class="reference external" href="http://your.server.com">http://your.server.com</a>/&lt;geoserver_context&gt;
(e.g., <a class="reference external" href="http://knb.ecoinformatics.org/geoserver">http://knb.ecoinformatics.org/geoserver</a>).</p>
<p>Common configuration tasks include:</p>
<ul class="simple">
<li>Adding a Map to a Web Page or Skin</li>
<li>Configuring the Size and Initial Extent of the Map</li>
<li>Configuring the Layout of the HTML Mapping Interface</li>
<li>Configuring the “Select Location Drop-down Menu</li>
<li>Configuring the Visual Portrayal of Geospatial Data (e.g., symbology and color)</li>
<li>Adding Other Spatial Datasets to the Web Map</li>
</ul>
<div class="figure align-center" id="id2">
<img alt="_images/image053.png" src="_images/image053.png" />
<p class="caption"><span class="caption-text">GeoServer’s Web-based administrative interface.</span></p>
</div>
<p>Note: Some configurations may need to be made to the XML files as well.</p>
<p>OpenLayers, which Metacat uses as the front-end for GeoServer’s WMS service,
provides interface components or “widgets” (e.g., the map, a box zoom, layer
list, “Select Location” drop-down menu, scale bar, lat/long coordinates, and
a query form) that make it easy to deploy web-based mapping applications with
minimal coding.</p>
<p>OpenLayers has three main configuration files used to customize the map interface.
Default configurations are in:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$METACAT/lib/style/common/spatial/
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="31%" />
<col width="14%" />
<col width="55%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Document</th>
<th class="head">Location</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>The named location file</td>
<td>locations.jsp</td>
<td>The list of pre-defined locations (name and lat/lon bounds)</td>
</tr>
<tr class="row-odd"><td>Main map rendering functions</td>
<td>maps.js</td>
<td>Defines the map, widgets and their behavior</td>
</tr>
<tr class="row-even"><td>The rendered map and page layout</td>
<td>map.jsp</td>
<td>Loads the map and controls the HTML layout of the widgets.</td>
</tr>
</tbody>
</table>
<p>NOTE: By default, the first time Metacat is restarted, it generates a
“spatial cache” containing geographic information about documents in its
repository. This default behavior is specified in lib/metacat.properties,
where the regenerateCacheOnRestart parameter is set to true. The information
in the spatial cache is stored in a GIS-compatible format (the ESRI Shapefile)
and consists of the document name and its geographic coverage. When documents
are inserted, deleted, and updated in the Metacat repository, Metacat
automatically syncs the spatial cache to reflect the changes. Because
generating the cache can take a considerable amount of time (several minutes
in the case of a few thousand documents), Metacat resets the
regenerateCacheOnRestart property to false after the spatial cache has been
generated. Note that if you upgrade or reinstall Metacat, the spatial cache
will be regenerated again.</p>
<div class="section" id="adding-a-map-to-a-web-page-or-skin">
<h3>11.1.1. Adding a Map to a Web Page or Skin<a class="headerlink" href="#adding-a-map-to-a-web-page-or-skin" title="Permalink to this headline">¶</a></h3>
<p>To add a map to a Web page, simply include the map interface using an iframe:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">iframe</span> <span class="n">scrolling</span><span class="o">=</span><span class="s2">&quot;no&quot;</span> <span class="n">frameborder</span><span class="o">=</span><span class="s2">&quot;0&quot;</span> <span class="n">width</span><span class="o">=</span><span class="s2">&quot;780&quot;</span> <span class="n">height</span><span class="o">=</span><span class="s2">&quot;420&quot;</span>
        <span class="n">src</span><span class="o">=</span><span class="s2">&quot;/metacat/style/common/spatial/map.jsp&quot;</span><span class="o">&gt;</span>
<span class="o">&lt;/</span><span class="n">iframe</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>The map URL, <code class="docutils literal"><span class="pre">/metacat/style/common/spatial/map.jsp</span></code>, is
the default map interface. If you plan to customize the map interface, copy
the map.jsp file into your skin’s directory (either the default or
customized skin directory).</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">cp</span> <span class="o">-</span><span class="n">r</span> <span class="n">style</span><span class="o">/</span><span class="n">common</span><span class="o">/</span><span class="n">spatial</span><span class="o">/</span><span class="nb">map</span><span class="o">.</span><span class="n">jsp</span> <span class="o">/</span><span class="n">style</span><span class="o">/</span><span class="n">skins</span><span class="o">/&lt;</span><span class="n">myskin</span><span class="o">&gt;/</span><span class="n">spatial</span>
</pre></div>
</div>
<p>You can access the customized map with the URL: <code class="docutils literal"><span class="pre">/metacat/style/skins/&lt;myskin&gt;/spatial/map.jsp</span></code></p>
</div>
<div class="section" id="configuring-the-size-and-initial-extent-of-the-map">
<h3>11.1.2. Configuring the Size and Initial Extent of the Map<a class="headerlink" href="#configuring-the-size-and-initial-extent-of-the-map" title="Permalink to this headline">¶</a></h3>
<p>Before you configure the size and initial extent of the map, make sure that you
have copied the map layout page into your skin’s directory (See
<a class="reference internal" href="configuration.html"><span class="doc">Configuring Metacat</span></a> for directions). Once the file has been copied, you can
modify the map’s initial extent in: <code class="docutils literal"><span class="pre">${skin.dir}/spatial/map.jsp</span></code>.</p>
<p>To change the map’s initial extent, edit the bounding box. The default is to
show the entire globe. The <code class="docutils literal"><span class="pre">initMap()</span></code> function should also be given the skin
name so that spatial search results can be correctly styled.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">script</span> <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;text/javascript&quot;</span><span class="o">&gt;</span>
    <span class="n">function</span> <span class="n">init</span><span class="p">()</span> <span class="p">{</span>
       <span class="n">var</span> <span class="n">bounds</span> <span class="o">=</span> <span class="n">new</span> <span class="n">OpenLayers</span><span class="o">.</span><span class="n">Bounds</span><span class="p">(</span><span class="o">-</span><span class="mi">180</span><span class="p">,</span><span class="o">-</span><span class="mi">90</span><span class="p">,</span><span class="mi">180</span><span class="p">,</span><span class="mi">90</span><span class="p">);</span>
       <span class="o">//</span> <span class="n">make</span> <span class="n">the</span> <span class="nb">map</span> <span class="k">for</span> <span class="n">this</span> <span class="n">skin</span>
       <span class="n">initMap</span><span class="p">(</span><span class="s2">&quot;&lt;%=GEOSERVER_URL%&gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;&lt;%=SERVLET_URL%&gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;default&quot;</span><span class="p">,</span> <span class="n">bounds</span><span class="p">);</span>
    <span class="p">}</span>
<span class="o">&lt;/</span><span class="n">script</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>The size (height/width) of the map can be controlled by the <code class="docutils literal"><span class="pre">#map</span></code> CSS entry
included in the <code class="docutils literal"><span class="pre">map.jsp</span></code> page.</p>
</div>
<div class="section" id="configuring-the-layout-of-the-html-mapping-interface">
<h3>11.1.3. Configuring the Layout of the HTML Mapping Interface<a class="headerlink" href="#configuring-the-layout-of-the-html-mapping-interface" title="Permalink to this headline">¶</a></h3>
<p>The size and initial extent of the map can be edited in : ${skin.dir}/spatial/map.jsp.</p>
<p>The map.jsp is a simple container that can be included in other more complex
pages if desired. It contains the map, widgets and location dropdown list.</p>
</div>
<div class="section" id="configuring-the-select-location-drop-down-menu">
<h3>11.1.4. Configuring the “Select Location” Drop-down Menu<a class="headerlink" href="#configuring-the-select-location-drop-down-menu" title="Permalink to this headline">¶</a></h3>
<p>The locations that appear in the “Select Location” drop-down menu are specified
in the <code class="docutils literal"><span class="pre">locations.jsp</span></code> file. The locations.jsp can be copied from the common
spatial template into your skin directory. Each location is defined as an
HTML <code class="docutils literal"><span class="pre">&lt;option/&gt;</span></code> tag. Edit the value and label to edit or add new locations.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">option</span> <span class="n">value</span><span class="o">=</span><span class="s2">&quot;-149.725,68.475 -149.3254,68.725&quot;</span><span class="o">&gt;</span> <span class="n">Arctic</span> <span class="n">LTER</span> <span class="p">(</span><span class="n">ARC</span><span class="p">)</span><span class="o">&lt;/</span><span class="n">option</span><span class="o">&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="configuring-the-visual-portrayal-of-geospatial-data-e-g-symbology-and-color">
<h3>11.1.5. Configuring the Visual Portrayal of Geospatial Data (e.g., symbology and color)<a class="headerlink" href="#configuring-the-visual-portrayal-of-geospatial-data-e-g-symbology-and-color" title="Permalink to this headline">¶</a></h3>
<p>Geospatial data sets are styled through the use of Styled Layer Descriptors
(SLD). The default SLDs used for the data points and data bounding boxes are in
<code class="docutils literal"><span class="pre">/lib/spatial/geoserver/data/styles/</span></code> and are named data_points_style.sld and
data_bounds_style.sld, respectively.</p>
<p>You can find a more detailed tutorial on using SLD with GeoServer in the GeoServer documentation:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">docs</span><span class="o">.</span><span class="n">geoserver</span><span class="o">.</span><span class="n">org</span><span class="o">/</span>
</pre></div>
</div>
</div>
<div class="section" id="adding-other-spatial-datasets-to-the-web-map">
<h3>11.1.6. Adding Other Spatial Datasets to the Web Map<a class="headerlink" href="#adding-other-spatial-datasets-to-the-web-map" title="Permalink to this headline">¶</a></h3>
<p>If you have vector GIS data sets, such as weather or topographical information,
on your server that you’d like to include in the interactive map, you must
first register the data set with GeoServer. After the data set has been
registered, you can add the layer to the map. You can also add spatial layers
that have been made publically available through WMS (There are hundreds of
spatial data sets available. Check out wms-sites.com for good catalog).
Instructions for adding publically available layers are included at the end
of this section.</p>
<p>To register the data set and add it to the map:</p>
<ol class="arabic simple">
<li>Point your browser to <code class="docutils literal"><span class="pre">http://your.server/geoserver</span></code>, log in to GeoServer,
and navigate to the “Data Stores” configuration page under <code class="docutils literal"><span class="pre">Data</span> <span class="pre">&gt;</span> <span class="pre">Stores</span></code>.</li>
<li>Create a new vector data source from a Shapefile in the “metacat” workspace.</li>
</ol>
<div class="figure align-center" id="id3">
<img alt="_images/image055.png" src="_images/image055.png" />
<p class="caption"><span class="caption-text">Creating a new shapefile using GeoServers web-based administrative interface.</span></p>
</div>
<ol class="arabic simple" start="3">
<li>The Description, if specified, is mostly used internally to provide other
administrators with information about the DataStore. Click Submit.</li>
<li>Navigate to the “Layers” configuration page under Data &gt; Layers.
Add a new Layer from your new data source.</li>
<li>You should also define a spatial reference system (SRS) number for the new
layer. Most lat/long data is “4326”. If your data is in another projection,
determine its spatial reference system using the help links provided.</li>
</ol>
<div class="figure align-center" id="id4">
<img alt="_images/image057.png" src="_images/image057.png" />
<p class="caption"><span class="caption-text">GeoServer’s FeatureType configuration. The SRS settings discussed in step 5 are highlighted.</span></p>
</div>
<ol class="arabic simple" start="6">
<li>Style the layer using a style from the drop-down menu on the Publishing tab,
or create a new SLD to create a new style object and corresponding SLD
(this option provides more control over the style).</li>
<li>Try out the styled data set as a WMS layer using a the Layer Preview.</li>
</ol>
<div class="figure align-center" id="id5">
<img alt="_images/image058.png" src="_images/image058.png" />
<p class="caption"><span class="caption-text">GeoServer’s Layer Preview allows you to see an OpenLayer rendering of the new layer.</span></p>
</div>
<ol class="arabic simple" start="8">
<li>Copy the default <code class="docutils literal"><span class="pre">map.js</span></code> file that assembles the map in OpenLayers
(<code class="docutils literal"><span class="pre">style/common/spatial/map.js</span></code>) to your skin’s spatial directory.</li>
<li>Edit the init() method to include your new layer in the map - either as an
overlay or as a base layer.</li>
<li>Point your browser to the map interface. Your new layer should appear with
the existing ones.</li>
</ol>
</div>
<div class="section" id="adding-external-spatial-data-made-publically-available-through-wms">
<h3>11.1.7. Adding External Spatial Data Made Publically Available through WMS<a class="headerlink" href="#adding-external-spatial-data-made-publically-available-through-wms" title="Permalink to this headline">¶</a></h3>
<p>There are hundreds of sources of spatial data made publically available
through WMS (check out <a class="reference external" href="http://wms-sites.com">http://wms-sites.com</a> for a good catalog). To add these
data sources to your map, add the layers in your skin’s <code class="docutils literal"><span class="pre">spatial/map.js</span></code> file.</p>
</div>
</div>
<div class="section" id="spatial-queries">
<h2>11.2. Spatial Queries<a class="headerlink" href="#spatial-queries" title="Permalink to this headline">¶</a></h2>
<p>To find out which documents in the Metacat repository lie in a specified
geographic region, query the spatial cache using Metacat’s spatial_query action.
Metacat can perform any query supported by the WFS/WMS standards.</p>
<p>An example of a spatial query string is:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>http://localhost/metacat/metacat?action=spatial_query&amp;xmin=-117.5&amp;xmax=-64&amp;ymin=3&amp;ymax=46&amp;skin=default
</pre></div>
</div>
<p>Where <code class="docutils literal"><span class="pre">xmin</span></code>, <code class="docutils literal"><span class="pre">xmax</span></code>, <code class="docutils literal"><span class="pre">ymin</span></code> and <code class="docutils literal"><span class="pre">ymax</span></code> represent the western, eastern,
southern and northern bounding coordinates (the “bounding box”), respectively.
The spatial query action returns all documents that overlap or that are
contained inside the specified spatial coordinates. The result set is returned
as HTML using the style of the specified skin (in this example, default).</p>
</div>
</div>


	          </div>
	        </div>
      	</div>

	
	      <div class="clearer"></div>
	    </div>
	    <div class="footer">
	    	<div class="footerNav">
				
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right">
        <span id="searchbox" style="display: none;">
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" />
              <input type="submit" value="Go" class="icon-search"/>
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </span>
        </li>
        <script type="text/javascript">$('#searchbox').show(0);</script>
        <li class="right">
          <a href="genindex.html" title="General Index"
             >index</a>
           </li>
        <li class="right">
          <a href="replication.html" title="12. Replication"
             >next</a>
           </li>
        <li class="right">
          <a href="authinterface.html" title="10. Metacat Authentication Mechanism"
             >previous</a>
           </li>
        <li class="breadcrumb first"><a href="index.html">Metacat 2.19.0 documentation</a> &raquo;</li> 
      </ul>
      
    </div>
			</div>
	    	<div class="small-print">
			      &copy; Copyright 2012, Regents of the University of California.
			      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.6.7.
			</div>
	    </div>
	</div>
  </body>
</html>