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
  </table>
110
111
  <h4><a name="overview">Overview Of the Major Components<a/></h4>
112
113
114
        <h5> <a name="spatial_harvester"> Spatial Harvester </a> </h5>
115
116
117
118
119
   <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>
120
   <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>
121
   <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>
122
   <ul>
123
    <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>
124
    <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>
125
    <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>
126
    <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>
127
   </ul>
128
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"></p>
129
   <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>
130
131
<pre>
132
westBoundingCoordinatePath=geographicCoverage/boundingCoordinates/westBoundingCoordinate
133
eastBoundingCoordinatePath=geographicCoverage/boundingCoordinates/eastBoundingCoordinate
134
southBoundingCoordinatePath=geographicCoverage/boundingCoordinates/southBoundingCoordinate
135
northBoundingCoordinatePath=geographicCoverage/boundingCoordinates/northBoundingCoordinate
136
</pre>
137
138
   <p dir="ltr" style="text-align:left;margin-bottom:12pt;margin-left:0.1250in;text-indent:0in"></p>
139
   <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>
140
   <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>
141
   <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>
142
   <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>
143
   <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>
144
   <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>
145
   <ul>
146
    <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>
147
    <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>
148
   </ul>
149
   <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>
150
151
152
        <h5> <a name="wms"> Web Mapping Service </a> </h5>
153
154
155
156
157
   <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>
158
   <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>
159
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Integration with Metacat Context</span></p>
160
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Configuration</span></p>
161
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Web Interface</span></p>
162
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Supports many vector data formats</span></p>
163
   <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>
164
   <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>
165
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"></p>
166
167
168
169
170
        <h5> <a name="spatial_query"> Spatial Query </a> </h5>
171
172
173
   <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>
174
   <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>
175
   <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>
176
   <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>
177
   <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>
178
179
180
181
182
183
184
        <h5> <a name="html_client"> HTML Mapping Client</a> </h5>
185
186
187
   <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>
188
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Consumes WMS services, defined through WMC</span></p>
189
   <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>
190
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Widget Architecture, Metacat config files, html divs</span></p>
191
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	AOIMetacat Query</span></p>
192
   <p style="margin-bottom:12pt;margin-left:0pt;text-indent:0in"><span lang="en-US">	Integration with skins</span></p>
193
194
195
196
197
198
<h4> <a name="install">Installing and Configuring the Spatial Option</a> </h4>
199
200
 <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>
201
202
   <p style="margin-bottom:12pt">How do I configure the layout of the html mapping interface?</p>
203
   <p style="margin-bottom:12pt">How can I configure the initial extent of the map?</p>
204
   <p style="margin-bottom:12pt">How do I configure the "select location" dropdown to contain different predefined locations?</p>
205
   <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>
206
   <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>
207
   <p style="margin-bottom:12pt">How can I upgrade/change the version of geoserver?</p>
208
   <p style="margin-bottom:12pt">What versions of tomcat are supported?</p>
209
   <p style="margin-bottom:12pt">The spatial functionality has only been tested on tomcat 5. </p>
210
   <p style="margin-bottom:12pt">How do I add the spatial functionality to a metacat skin?</p>
211
212
213
214
<h4> <a name="adding_data">Adding Other Spatial Datasets to the Web Map</a> </h4>
215
216
  <h5> WMS data </h5>
217
  <h5> Spatial datasets already registered with metacat </h5>
218
  <h5> Raster Images </h5>
219
220
221
222
<h4> <a name="dev">Developers Notes</a></h4>
223
224
<h5>web.xml</h5>
225
<h5>upgrading geoserver</h5>
226
<h5>tomcat</h5>
227
<h5>geotools versions</h5>
228
229
230
231
<h4> <a name="future">Future Directions</a> </h4>
232
233
   <h5>Automatically handle spatial datasets</h5>
234
   <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>
235
   <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>
236
   <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>
237
   <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>
238
239
   <h5>WMS bypass</h5>
240
   <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>
241
242
   <h5>SLD factory</h5>
243
   <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>
244
245
   <h5>Map configuration interface </h5>
246
   <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>
247
   <ul>
248
    <li style="margin-bottom:12pt"><span lang="en-US">	D</span>efine the available datasets (ie editing the geoserver xml config files)</li>
249
    <li style="margin-bottom:12pt"><span lang="en-US">	Define</span> classification and styling (ie editing the SLDs)</li>
250
    <li style="margin-bottom:12pt"><span lang="en-US">	Define which layers get displayed in which map (ie editing the Mapbuilder WMCs)</span></li>
251
    <li style="margin-bottom:12pt"><span lang="en-US">	Picking a layout ( from a list of pre-configure mapbuilder templates)</span>    </li>
252
   </ul>
253
   <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>
254
255
256
257
258
</BODY>
259
</HTML>