Project

General

Profile

1 3074 perry
<!--
2
  * harvester.html
3
  *
4
  *      Authors: Duane Costa
5
  *    Copyright: 2004 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis,
7
  *               and the University of New Mexico.
8
  *  For Details: http://www.nceas.ucsb.edu/
9
  *      Created: 2004 April 9
10
  *      Version:
11
  *    File Info: '$ '
12
  *
13
  *
14
-->
15
<HTML>
16
<HEAD>
17
<TITLE>Metacat Spatial Option</TITLE>
18
<link rel="stylesheet" type="text/css" href="./default.css">
19
</HEAD>
20
<BODY>
21
  <table width="100%">
22
    <tr>
23
      <td class="tablehead" colspan="2">
24
        <p class="label">Metacat Spatial Option</p>
25
      </td>
26
      <td class="tablehead" colspan="2" align="right">
27
        <a href="./properties.html">Back</a> |
28
        <a href="./metacattour.html">Home</a> |
29
        <a href="./unimplem.html">Next</a>
30
      </td>
31
    </tr>
32
  </table>
33
  <h4>Introduction</h4>
34
The Metacat spatial option enables you to query and visualize the geographic coverage of metacat documents.
35
This document is intended to provide a high-level overview of the Metacat spatial functionality. It is primarily a resource for users and developers who want to understand the architecture before digging into the code to extend the existing functionality.
36
<P>
37
Although the spatial option is included with a Metacat installation (beginning with
38
Metacat version 1.7.0), it is an extention to Metacat's functionality
39
that may be used optionally.
40
</P>
41
  <h4>Outline</h4>
42
 <ul>
43
   <li> <a href="#definitions">Defintion of Terms</a> </li>
44
   <li> <a href="#overview"> Overview of the major components </a>
45
      <ul>
46
        <li> <a href="#spatial_harvester"> Spatial Harvester </a> </li>
47
        <li> <a href="#wms"> Web Mapping Service </a> </li>
48
        <li> <a href="#spatial_query"> Spatial Query </a> </li>
49
        <li> <a href="#html_client"> HTML Mapping Client</a> </li>
50
      </ul>
51
   </li>
52
   <li> <a href="#install">Installing and Configuring the Spatial Option</a> </li>
53
   <li> <a href="#adding_data">Adding Other Spatial Datasets to the Web Map</a> </li>
54
   <li> <a href="#dev">Developers Notes</a> </li>
55
   <li> <a href="#future">Future Directions</a> </li>
56
57
 </ul>
58
59
  <h4> <a name="definitions">Definitions</a></h4>
60
The following table defines a number of terms that are useful in discussing
61
Harvester and its features.
62
  <br><br>
63
  <table border="1">
64
    <tr>
65
      <td><b>Term</b></td>
66
      <td><b>Definition</b></td>
67
    </tr>
68
    <tr>
69
      <td>Spatial Cache</td>
70
      <td>
71
          A cached version of the metacat documents representing their geographic coverages in a GIS-compatible data format; the ESRI Shapefile.
72
      </td>
73
    </tr>
74
    <tr>
75
      <td>Web Mapping Service (WMS)</td>
76
      <td>
77
         A standard interface specification for requesting spatial data as a web-deliverable map image. WMS servers accept a common set of parameters via http, render the spatial dataset into an appropriate image and deliver it back to the client. The <a href="http://www.opengeospatial.org/standards/wms">WMS spec</a> was developed by the <a href="http://www.opengeospatial.org/">Open Geospatial Consortium</a>.
78
    </tr>
79
    <tr>
80
      <td>Bounding Box (BBOX)</td>
81
      <td>
82
          A Bounding Box is two sets of geographic coordinates representing the full geographic extent of an entity; the minimum lat/long (the lower-left) and the maximum lat/long (the upper-right).
83
      </td>
84
    </tr>
85
    <tr>
86
      <td>Spatial Dataset</td>
87
      <td>
88
        A collection of <em>spatial features</em> in a common datastore.
89
      </td>
90
    </tr>
91
    <tr>
92
      <td>Spatial Features</td>
93
      <td>
94
        Analagous to a "row" in a tabular dataset, a feature is an entity comprised of both tabular attributes and a <em>spatial geometry</em>.
95
      </td>
96
    </tr>
97
    <tr>
98
      <td>Spatial Geometry</td>
99
      <td>
100
        The geometry is a vector representation of an entities' geographic location. This can be a point (a single vertex), line (a series of vertices) or polygon (a series of vertices forming a closed area).
101
      </td>
102
    </tr>
103
    <tr>
104
      <td>Multi-Geometry</td>
105
      <td>
106
       A <em> Spatial geometry </em> represented by one or more geometry primitives (points,lines and polygons). For example a single species census (the <em> spatial feature </em>) might have mutltiple sample sites and could be represented as a multi-point geometry.
107
      </td>
108
    </tr>
109 3104 perry
    <tr>
110
      <td>Styled Layer Descriptor (SLD)</td>
111
      <td>
112
       Styled Layer Descriptors are an OGC standard for defining the filtering, classification and styling of datasets. They are essentially the configuration file which describes how to convert your raw spatial dataset into a cartographic product.
113
      </td>
114
    </tr>
115
    <tr>
116
      <td>Web Map Context (WMC)</td>
117
      <td>
118
       Web Map Context documents are an OGC standard for combining various WMS layers into a coherent map. WMC describes which wms servers and layers comprise the map, the layer order, the initial map extent, the requested image formats, etc. This is used by the HTML web map client to construct the interactive map.
119
      </td>
120
    </tr>
121 3074 perry
  </table>
122
123
  <h4><a name="overview">Overview Of the Major Components<a/></h4>
124
125
126
        <h5> <a name="spatial_harvester"> Spatial Harvester </a> </h5>
127
128
129
130
131
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The Spatial Harvester component syncs the metacat database with the spatial cache (an ESRI shapefile which contains the geographic coverages of the documents). </span></p>
132
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The Spatial Harvester is implemented entirely in Java using the Geotools library which allows manipulation of spatial datasets. In rough terms, a spatial dataset is a collection of Features which are comprised of a geometry (i.e. the geographic coverage) and associated attributes (i.e. the document's title).</span></p>
133
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	There are a number of Java classes which, collectively, make up the spatial harvester functionality. They are found in the </span><span style="font-style:italic" lang="en-US">edu.ucsb.nceas.metacat.spatial</span><span lang="en-US"> package:</span></p>
134
   <ul>
135
    <li style="margin-bottom:12pt"><span lang="en-US">&nbsp;</span><span style="font-weight:bold" lang="en-US">SpatialDataset</span><span lang="en-US"> : Provides read/write access to the spatial cache.</span></li>
136
    <li style="margin-bottom:12pt"><span lang="en-US">&nbsp;</span><span style="font-weight:bold" lang="en-US">SpatialDocument</span><span lang="en-US"> : Represents the geographic coverage of a document as a Geotools Feature. </span></li>
137
    <li style="margin-bottom:12pt"><span lang="en-US">&nbsp;</span><span style="font-weight:bold" lang="en-US">SpatialFeatureSchema</span><span lang="en-US"> : A class of static memebers defining the properties of the spatial cache (location on the file system, attribute and geometry schemas, etc.)</span></li>
138
    <li style="margin-bottom:12pt"><span lang="en-US">&nbsp;</span><span style="font-weight:bold" lang="en-US">SpatialHarvester</span><span lang="en-US"> : The high-level interface for manipulating the spatial cache and initiating the harvesting process.</span>    </li>
139
   </ul>
140
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"></p>
141
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The spatial cache currently represents the geographic coverage of XML documents based on a bounding box. The four bounding coordinates (either latitudes or longitudes) can be specified in the metacat.properties file by their xpaths. For example, the geographic coverage of EML documents is defined as:</span></p>
142
143
<pre>
144
westBoundingCoordinatePath=geographicCoverage/boundingCoordinates/westBoundingCoordinate
145
eastBoundingCoordinatePath=geographicCoverage/boundingCoordinates/eastBoundingCoordinate
146
southBoundingCoordinatePath=geographicCoverage/boundingCoordinates/southBoundingCoordinate
147
northBoundingCoordinatePath=geographicCoverage/boundingCoordinates/northBoundingCoordinate
148
</pre>
149
150
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0.1250in;text-indent:0in"></p>
151
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	&nbsp;It is important to note that, at the moment, only one set of xpaths are defined in metacat.properties meaning only documents of the chosen schema can be accessed by the spatial harvester. Also note that, for performance reasons, the xpaths to the bounding coordinates must also appear in your indexPath (defined in build.properties).</span></p>
152
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The bounding coordinates are spatially cached in two ways: t</span><span lang="en-US">he centroid(s) of the bounding box(s) and the actual bounding box(es). These are stored as two seperate shapefiles with multi-point and multi-polygon geometry types respectively. By default, </span><span style="font-size:8pt;font-family:'Courier New'" lang="en-US">${tomcat_webapps_directory}/${context}/data/metacat_shps/</span><span style="font-size:8pt;font-family:'Courier New'" lang="en-US">data_points.shp</span><span lang="en-US"> is the storage location of the point cache while </span><span style="font-size:8pt;font-family:'Courier New'" lang="en-US">data_bounds.shp</span><span lang="en-US"> represents the polygon cache. </span></p>
153
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The bounding polygon is not relevant to every document as bounding coordinates are allowed to be of zero-area (ie west = = east and north = = south). In this case they are represented only as a point. In cases where no bounding coordinates are defined, the document is not represented at all in the spatial cache. Note that special care has been taken to account for cases where the bounding box crosses the international dateline or polar regions (at which point Cartesian calculations are invalid).</span></p>
154
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Because documents may have more than one geographic coverage, it is necessary to define the two spatial caches as </span><span style="font-style:italic" lang="en-US">multi</span><span lang="en-US">-point and </span><span style="font-style:italic" lang="en-US">multi</span><span lang="en-US">-polygon geometry types. This means that each feature's geometry field can contain a collection of one </span><span style="font-style:italic" lang="en-US">or more </span><span lang="en-US">primitive geometries.</span></p>
155
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	&nbsp;With the spatial option properly installed, the default metacat.properties setting is to set </span><span style="font-style:italic" lang="en-US">regenerateCacheOnRestart=true.</span><span lang="en-US"> This is very useful the first time you install metacat since it will generate the spatial cache from scratch when your servlet container is restarted. Depending on how many documents you have in your metacat database, this can take a considerable amount of time; several minutes in the case of a few thousand documents. For this reason, Metacat sets this property to <em>false</em> after the spatial cache has been generated the first time. This prevents the regeneration of the spatial cache every time you restart your servlet container. Note that if you upgrade or reinstall metacat, the spatial cache will be regenerated again.  </span></p>
156
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Once the spatial cache has been generated, the Metacat servlet will keep the spatial cache in sync with the metacat database by triggering the spatial harvester on every insert, update or delete. This does not regenerate the whole spatial cache, instead simply updating features in the cache as needed. It is fairly quick and should not add more than 1/2 second to any given transaction. As mentioned earlier, all high-level interactions with the spatial cache are handled through the SpatialHarvester class. </span></p>
157
   <ul>
158
    <li style="margin-bottom:12pt"><span lang="en-US">	W</span><span lang="en-US">hen a document is deleted, the SpatialHarvester.addToDeleteQue() method is called directly from the Metacat Servlet. </span></li>
159
    <li style="margin-bottom:12pt"><span lang="en-US">	Inserts and updates are handled during the indexing process; after BuildIndex for a document has completed successfully (see </span><span style="font-style:italic" lang="en-US">DocumentImpl.java </span><span lang="en-US">) the SpatialHarvester.addToUpdateQue() method is invoked. The document is purged from the spatial cache (if updating) and the new document (or document revision) is added.</span>    </li>
160
   </ul>
161
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	There is one very important note about document authentication. While metacat provides very fine-grained permissions control at the document level, the Web Mapping Server component does not. For this reason, only documents that are publicly readable (i.e. documents which match the following SQL query : </span><span style="font-size:9pt;font-family:'Courier New'" lang="en-US">select distinct docid from xml_access where principal_name = 'public' and perm_type = 'allow')</span><span lang="en-US">will be added to the spatial cache. </span><span lang="en-US">In the Future Directions section of this document, the potential for adding feature-level permissions to the WMS server are discussed.</span></p>
162
163
164
        <h5> <a name="wms"> Web Mapping Service </a> </h5>
165
166
167
168
169
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The primary function of the Web Mapping Server component is to render the spatial cache as a web-deliverable map image. It is also responsible for rendering other geographic data to provide base maps or other auxillary map layers.</span></p>
170
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The OpenGIS consortium has defined a standard for requesting maps, the Web Mapping Service or WMS standard. WMS servers accept a common set of parameters via http, render the spatial dataset into an appropriate image and deliver it back to the client. For Metacat, we chose to go with GeoServer, a WMS-capable application written in Java. </span></p>
171
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Integration with Metacat Context</span></p>
172
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Configuration</span></p>
173
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Web Interface</span></p>
174
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Supports many vector data formats</span></p>
175
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US"> &nbsp;Outputs Images (mainly) but can be used to output GML and KML.</span></p>
176
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Known issues (rasters, startup procedure, difficult for novice to configure, maven build, size)</span></p>
177
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"></p>
178
179
180
181
182
        <h5> <a name="spatial_query"> Spatial Query </a> </h5>
183
184
185
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Displaying the spatial cache as a map is important but users also need to query the spatial cache in order to answer the question "What documents lie in this geographic region?". The functionality is invoked through the metacat servlet itself; there is a </span><span style="font-style:italic" lang="en-US">spatial_query </span><span lang="en-US">action for this purpose. An example spatial query would be:</span></p>
186
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span style="font-size:8pt;font-family:'Courier New'" lang="en-US">http://localhost/knb/metacat?action=spatial_query&amp;xmin=-117.5&amp;xmax=-64&amp;ymin=3&amp;ymax=46&amp;skin=default</span></p>
187
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">Where xmin, xmax, ymin and ymax represent the west, east, south and northern bounding coordinates respectively. This will return an html document listing (in the style of the specified skin) all documents whose geographic coverage intersect the given bounding box.</span></p>
188
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	The core functionality of the spatial query mechanism is found in the </span><span style="font-style:italic" lang="en-US">edu.ucsb.nceas.metacat.spatial.SpatialQuery</span><span lang="en-US"> class and, like the spatial harvester, relies heavily on the Geotools library. This class has a single method,</span><span style="font-style:italic" lang="en-US"> filterByBbox()</span><span lang="en-US">, which compares the bounding box to both the point and polygon cache. For each shapefile, the process requires two steps: First, filter the spatial cache for features whose bounding box overlaps the specified bounding coordinates; Second, iterate through the remaining features and perform an an actual geometric intersection. The second step, though more costly than comparing the bbox, is necessary because the feature's geometry may be a multi-geometry whose bounding box is large but whose component primitive geometries are scattered over that area. The end result is a vector of docids matching the spatial query.</span></p>
189
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	This docid list is then sent to DBQuery. Using a special constructor that takes a vector of docids, the DBQuery class is able to use the Docid override mechanism to perform an optimized query (for cases where the list of docids is already known).</span></p>
190
191
192
193
194
195
196
        <h5> <a name="html_client"> HTML Mapping Client</a> </h5>
197
198
199
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	In order to provide a web-based user interface to the WMS and the spatial query functionality, Metacat relies on Community Mapbuilder. Mapbuilder is a pure HTML/javascript application which uses AJAX and XSLT on the client side to create a desktop-GIS-like environment for interacting with geographic data through a web browser.</span></p>
200
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Consumes WMS services, defined through WMC</span></p>
201
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Map interface components (map, box zooms, layer list, "select location" dropdown, scalebar, coordinates, info query)</span></p>
202
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Widget Architecture, Metacat config files, html divs</span></p>
203
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	AOIMetacat Query</span></p>
204
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Integration with skins</span></p>
205
206
207
208
209
210
<h4> <a name="install">Installing and Configuring the Spatial Option</a> </h4>
211
212
 <p style="margin-bottom:12pt"><span lang="en-US">When first installing a version of metacat with the spatial option, you'll want to ensure that </span><span style="font-style:italic" lang="en-US">install.spatial</span><span lang="en-US"> is </span><span style="font-style:italic" lang="en-US">true</span><span lang="en-US"> in build.properties. You'll also want to ensure that </span><span style="font-style:italic" lang="en-US">runSpatialOption </span><span lang="en-US">is </span><span style="font-style:italic" lang="en-US">true</span><span lang="en-US"> in metacat.properties. Both of these values are the default so, unless you explicitly set them to be false, the spatial option should install and run automatically.</span></p>
213
214
   <p style="margin-bottom:12pt">How do I configure the layout of the html mapping interface?</p>
215
   <p style="margin-bottom:12pt">How can I configure the initial extent of the map?</p>
216
   <p style="margin-bottom:12pt">How do I configure the "select location" dropdown to contain different predefined locations?</p>
217
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-top:0.0000in;margin-right:0.0000in">Can I use a different web mapping interface?</span></p>
218
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-top:0.0000in;margin-right:0.0000in">How do I configure the styling and classification of the data?</p>
219
   <p style="margin-bottom:12pt">How can I upgrade/change the version of geoserver?</p>
220
   <p style="margin-bottom:12pt">What versions of tomcat are supported?</p>
221
   <p style="margin-bottom:12pt">The spatial functionality has only been tested on tomcat 5. </p>
222
   <p style="margin-bottom:12pt">How do I add the spatial functionality to a metacat skin?</p>
223
224
225
226
<h4> <a name="adding_data">Adding Other Spatial Datasets to the Web Map</a> </h4>
227
228
  <h5> WMS data </h5>
229
  <h5> Spatial datasets already registered with metacat </h5>
230
  <h5> Raster Images </h5>
231
232
233
234
<h4> <a name="dev">Developers Notes</a></h4>
235
236
<h5>web.xml</h5>
237
<h5>upgrading geoserver</h5>
238
<h5>tomcat</h5>
239
<h5>geotools versions</h5>
240
241
242
243
<h4> <a name="future">Future Directions</a> </h4>
244
245
   <h5>Automatically handle spatial datasets</h5>
246
   <p style="margin-bottom:12pt">When users put spatial data into the Morpho system, it would be nice if we could automatically pull all the avialable metadata from the spatial dataset itself. </p>
247
   <p style="margin-bottom:12pt">On the metacat side, it might be worth trying to auto-detect spatial datasets and add them to the WMS service do that they could be displayed along with the metadata coverages. This is tricky since the styling of spatial data is intentionally seperated from the data itself; we'd have to have some sort of easy way to prompt the user for the classification and styling info and construct the appropriate SLDs. </p>
248
   <p style="margin-bottom:12pt">It's worth noting that, currently, one could do this manually. There is nothing, aside from editing a few configuration files, to prevent any Geotools-supported dataset from being displayed through the WMS map interface.</p>
249
   <p style="margin-bottom:12pt">For vector datasets, it would be possible to store the data directly in the database itself (This is a logical extension of the future work to put tabular data directly in a relational database). Postgresql has the PostGIS extensions to handle this so we would have to require postgresql if we went this route.</p>
250
251
   <h5>WMS bypass</h5>
252
   <p style="margin-bottom:12pt"> Filter which spatial cache features are displayed by access contraints, skin constraints and the current non-spatial query set. This would involve intercepting incoming WMS requests and appending a styled layer descriptor (SLD) with an OGC filter to prevent/allow certain docids. </p>
253
254
   <h5>SLD factory</h5>
255
   <p style="margin-bottom:12pt">Closely related to the WMS bypass implemetation, the SLD factory would be in charge of constructing the filter based on on the contraints mentioned above. Because it would have to generate this list of docids on every wms request, performance is a big concern. Likely we'll need to cache docid lists as session variables.</p>
256
257
   <h5>Map configuration interface </h5>
258
   <p style="margin-bottom:12pt">Geoserver currently offers a nice web-based configuration but it is lacking a few key features and may be difficult for a novice GIS user. We may want to reinvent a custom geoserver configuration interface to</p>
259
   <ul>
260
    <li style="margin-bottom:12pt"><span lang="en-US">	D</span>efine the available datasets (ie editing the geoserver xml config files)</li>
261
    <li style="margin-bottom:12pt"><span lang="en-US">	Define</span> classification and styling (ie editing the SLDs)</li>
262
    <li style="margin-bottom:12pt"><span lang="en-US">	Define which layers get displayed in which map (ie editing the Mapbuilder WMCs)</span></li>
263
    <li style="margin-bottom:12pt"><span lang="en-US">	Picking a layout ( from a list of pre-configure mapbuilder templates)</span>    </li>
264
   </ul>
265
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"> Ideally we could pull as much information as possible from the metadata and make the UI very intuitive. This does bring up issues of web-based admin access constraints and developing a subsytem to handle who has edit access to the map configuration.</p>
266
267
268
269 3104 perry
   <table> <tr>
270
      <td align="right">
271
        <a href="./properties.html">Back</a> |
272
        <a href="./metacattour.html">Home</a> |
273
        <a href="./unimplem.html">Next</a>
274
      </td>
275
   </tr> </table>
276 3074 perry
277
</BODY>
278
</HTML>