1 |
6147
|
jones
|
Metacat's Use of Geoserver
|
2 |
|
|
==========================
|
3 |
|
|
|
4 |
6870
|
jones
|
GeoServer 2.0.2, an open source Web Mapping Service (WMS) written in Java, is
|
5 |
6844
|
jones
|
bundled with Metacat and can be used to render spatial data as web-deliverable
|
6 |
6870
|
jones
|
maps. Metacat uses OpenLayers (http://openlayers.org/) to provide a web-based
|
7 |
|
|
user interface for interacting with the generated maps. You can use any
|
8 |
|
|
WMS-compatible client (e.g., ArcGIS, QGIS, JUMP, UDig, OpenLayers, Mapbender,
|
9 |
|
|
Map Builder).
|
10 |
6147
|
jones
|
|
11 |
6844
|
jones
|
IMPORTANT: Regardless of whether you plan on using the mapping functionality
|
12 |
|
|
you should, for security purposes, configure GeoServer so that it doesn't
|
13 |
|
|
use the default password. For instructions, please see
|
14 |
6870
|
jones
|
Geoserver Configuration.
|
15 |
6147
|
jones
|
|
16 |
6844
|
jones
|
.. figure:: images/screenshots/image051.jpg
|
17 |
|
|
:align: center
|
18 |
|
|
|
19 |
|
|
A map generated by Metacat's GeoServer. Points and "bounding boxes"
|
20 |
|
|
represent the geographic extent of datasets stored in the KNB Metacat repository.
|
21 |
6147
|
jones
|
|
22 |
6844
|
jones
|
GeoServer supports a wide variety of vector GIS data sources, which can be
|
23 |
|
|
styled using Styled Layer Descriptors (SLDs) and output as images (the default)
|
24 |
|
|
or raw vector data (GML or KML).
|
25 |
|
|
|
26 |
|
|
Currently, GeoServer can be used with the following limitations:
|
27 |
|
|
|
28 |
6870
|
jones
|
* GeoServer will only map documents that are publicly available. This is
|
29 |
6844
|
jones
|
because the mapping server's support for permissions control is not as
|
30 |
|
|
fine-grained as Metacat's.
|
31 |
|
|
|
32 |
|
|
Metacat developers plan to continue extending and improving Metacat's mapping
|
33 |
|
|
capabilities. If you are interested in contributing to those efforts, or if
|
34 |
|
|
you are interested in learning more about the architecture and future plans for
|
35 |
6870
|
jones
|
the mapping software, please contact the Metacat development
|
36 |
|
|
team (metacat-dev@ecoinformatics.org).
|
37 |
6844
|
jones
|
|
38 |
|
|
Installing and Configuring
|
39 |
|
|
--------------------------
|
40 |
6870
|
jones
|
The GeoServer webapp should be installed as a sibling of Metacat. If you do
|
41 |
|
|
NOT wish to run GeoServer, the deployment can be skipped, but any skins that
|
42 |
|
|
use maps will not render correctly. (NOTE: Geoserver recommends using a PermGen
|
43 |
|
|
space setting of at least 128MB.).
|
44 |
6844
|
jones
|
|
45 |
6870
|
jones
|
Metacat comes with a pre-configured data directory to be used by GeoServer.
|
46 |
|
|
This includes a world-countries base layer and a default configuration that
|
47 |
|
|
is already aware of Metacat's spatial cache. The Metacat configuration interface
|
48 |
|
|
is used to configure GeoServer to use this shared data directory. To further
|
49 |
|
|
configure GeoServer, use the Web-based configuration utility,
|
50 |
8397
|
leinfelder
|
which is available at: http://your.server.com/<geoserver_context>
|
51 |
|
|
(e.g., http://knb.ecoinformatics.org/geoserver).
|
52 |
6844
|
jones
|
|
53 |
|
|
Common configuration tasks include:
|
54 |
|
|
|
55 |
|
|
* Adding a Map to a Web Page or Skin
|
56 |
|
|
* Configuring the Size and Initial Extent of the Map
|
57 |
|
|
* Configuring the Layout of the HTML Mapping Interface
|
58 |
|
|
* Configuring the "Select Location Drop-down Menu
|
59 |
|
|
* Configuring the Visual Portrayal of Geospatial Data (e.g., symbology and color)
|
60 |
|
|
* Adding Other Spatial Datasets to the Web Map
|
61 |
|
|
|
62 |
6870
|
jones
|
.. figure:: images/screenshots/image053.png
|
63 |
6844
|
jones
|
:align: center
|
64 |
|
|
|
65 |
|
|
GeoServer's Web-based administrative interface.
|
66 |
|
|
|
67 |
|
|
Note: Some configurations may need to be made to the XML files as well.
|
68 |
|
|
|
69 |
6870
|
jones
|
OpenLayers, which Metacat uses as the front-end for GeoServer's WMS service,
|
70 |
|
|
provides interface components or "widgets" (e.g., the map, a box zoom, layer
|
71 |
|
|
list, "Select Location" drop-down menu, scale bar, lat/long coordinates, and
|
72 |
|
|
a query form) that make it easy to deploy web-based mapping applications with
|
73 |
|
|
minimal coding.
|
74 |
6844
|
jones
|
|
75 |
6870
|
jones
|
OpenLayers has three main configuration files used to customize the map interface.
|
76 |
|
|
Default configurations are in::
|
77 |
6844
|
jones
|
|
78 |
6870
|
jones
|
$METACAT/lib/style/common/spatial/
|
79 |
|
|
|
80 |
|
|
+----------------------------------+---------------+-------------------------------------------------------------+
|
81 |
|
|
| Document | Location | Description |
|
82 |
|
|
+==================================+===============+=============================================================+
|
83 |
|
|
| The named location file | locations.jsp | The list of pre-defined locations (name and lat/lon bounds) |
|
84 |
|
|
+----------------------------------+---------------+-------------------------------------------------------------+
|
85 |
|
|
| Main map rendering functions | maps.js | Defines the map, widgets and their behavior |
|
86 |
|
|
+----------------------------------+---------------+-------------------------------------------------------------+
|
87 |
|
|
| The rendered map and page layout | map.jsp | Loads the map and controls the HTML layout of the widgets. |
|
88 |
|
|
+----------------------------------+---------------+-------------------------------------------------------------+
|
89 |
6844
|
jones
|
|
90 |
|
|
NOTE: By default, the first time Metacat is restarted, it generates a
|
91 |
|
|
"spatial cache" containing geographic information about documents in its
|
92 |
|
|
repository. This default behavior is specified in lib/metacat.properties,
|
93 |
|
|
where the regenerateCacheOnRestart parameter is set to true. The information
|
94 |
|
|
in the spatial cache is stored in a GIS-compatible format (the ESRI Shapefile)
|
95 |
|
|
and consists of the document name and its geographic coverage. When documents
|
96 |
|
|
are inserted, deleted, and updated in the Metacat repository, Metacat
|
97 |
|
|
automatically syncs the spatial cache to reflect the changes. Because
|
98 |
|
|
generating the cache can take a considerable amount of time (several minutes
|
99 |
|
|
in the case of a few thousand documents), Metacat resets the
|
100 |
|
|
regenerateCacheOnRestart property to false after the spatial cache has been
|
101 |
|
|
generated. Note that if you upgrade or reinstall Metacat, the spatial cache
|
102 |
|
|
will be regenerated again.
|
103 |
|
|
|
104 |
|
|
Adding a Map to a Web Page or Skin
|
105 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
106 |
|
|
To add a map to a Web page, simply include the map interface using an iframe::
|
107 |
|
|
|
108 |
6870
|
jones
|
<iframe scrolling="no" frameborder="0" width="780" height="420"
|
109 |
8265
|
leinfelder
|
src="/metacat/style/common/spatial/map.jsp">
|
110 |
6844
|
jones
|
</iframe>
|
111 |
|
|
|
112 |
8265
|
leinfelder
|
The map URL, ``/metacat/style/common/spatial/map.jsp``, is
|
113 |
6870
|
jones
|
the default map interface. If you plan to customize the map interface, copy
|
114 |
|
|
the map.jsp file into your skin's directory (either the default or
|
115 |
6844
|
jones
|
customized skin directory).
|
116 |
|
|
|
117 |
|
|
::
|
118 |
|
|
|
119 |
6870
|
jones
|
cp -r style/common/spatial/map.jsp /style/skins/<myskin>/spatial
|
120 |
6844
|
jones
|
|
121 |
8265
|
leinfelder
|
You can access the customized map with the URL: ``/metacat/style/skins/<myskin>/spatial/map.jsp``
|
122 |
6844
|
jones
|
|
123 |
|
|
Configuring the Size and Initial Extent of the Map
|
124 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
125 |
|
|
Before you configure the size and initial extent of the map, make sure that you
|
126 |
6870
|
jones
|
have copied the map layout page into your skin's directory (See
|
127 |
|
|
:doc:`configuration` for directions). Once the file has been copied, you can
|
128 |
|
|
modify the map's initial extent in: ``${skin.dir}/spatial/map.jsp``.
|
129 |
6844
|
jones
|
|
130 |
8265
|
leinfelder
|
To change the map's initial extent, edit the bounding box. The default is to
|
131 |
6870
|
jones
|
show the entire globe. The ``initMap()`` function should also be given the skin
|
132 |
|
|
name so that spatial search results can be correctly styled.
|
133 |
6844
|
jones
|
|
134 |
6870
|
jones
|
::
|
135 |
6844
|
jones
|
|
136 |
6870
|
jones
|
<script type="text/javascript">
|
137 |
|
|
function init() {
|
138 |
|
|
var bounds = new OpenLayers.Bounds(-180,-90,180,90);
|
139 |
|
|
// make the map for this skin
|
140 |
|
|
initMap("<%=GEOSERVER_URL%>", "<%=SERVLET_URL%>", "default", bounds);
|
141 |
|
|
}
|
142 |
|
|
</script>
|
143 |
6844
|
jones
|
|
144 |
6870
|
jones
|
The size (height/width) of the map can be controlled by the ``#map`` CSS entry
|
145 |
|
|
included in the ``map.jsp`` page.
|
146 |
|
|
|
147 |
6844
|
jones
|
Configuring the Layout of the HTML Mapping Interface
|
148 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
149 |
6870
|
jones
|
The size and initial extent of the map can be edited in : ${skin.dir}/spatial/map.jsp.
|
150 |
6844
|
jones
|
|
151 |
6870
|
jones
|
The map.jsp is a simple container that can be included in other more complex
|
152 |
|
|
pages if desired. It contains the map, widgets and location dropdown list.
|
153 |
6844
|
jones
|
|
154 |
|
|
Configuring the "Select Location" Drop-down Menu
|
155 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
156 |
|
|
The locations that appear in the "Select Location" drop-down menu are specified
|
157 |
6870
|
jones
|
in the ``locations.jsp`` file. The locations.jsp can be copied from the common
|
158 |
|
|
spatial template into your skin directory. Each location is defined as an
|
159 |
|
|
HTML ``<option/>`` tag. Edit the value and label to edit or add new locations.
|
160 |
6844
|
jones
|
|
161 |
|
|
::
|
162 |
|
|
|
163 |
8265
|
leinfelder
|
<option value="-149.725,68.475 -149.3254,68.725"> Arctic LTER (ARC)</option>
|
164 |
6844
|
jones
|
|
165 |
|
|
Configuring the Visual Portrayal of Geospatial Data (e.g., symbology and color)
|
166 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
167 |
|
|
Geospatial data sets are styled through the use of Styled Layer Descriptors
|
168 |
|
|
(SLD). The default SLDs used for the data points and data bounding boxes are in
|
169 |
|
|
``/lib/spatial/geoserver/data/styles/`` and are named data_points_style.sld and
|
170 |
|
|
data_bounds_style.sld, respectively.
|
171 |
|
|
|
172 |
6870
|
jones
|
You can find a more detailed tutorial on using SLD with GeoServer in the GeoServer documentation::
|
173 |
6844
|
jones
|
|
174 |
6870
|
jones
|
http://docs.geoserver.org/
|
175 |
6844
|
jones
|
|
176 |
|
|
Adding Other Spatial Datasets to the Web Map
|
177 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
178 |
|
|
If you have vector GIS data sets, such as weather or topographical information,
|
179 |
|
|
on your server that you'd like to include in the interactive map, you must
|
180 |
|
|
first register the data set with GeoServer. After the data set has been
|
181 |
|
|
registered, you can add the layer to the map. You can also add spatial layers
|
182 |
|
|
that have been made publically available through WMS (There are hundreds of
|
183 |
|
|
spatial data sets available. Check out wms-sites.com for good catalog).
|
184 |
|
|
Instructions for adding publically available layers are included at the end
|
185 |
|
|
of this section.
|
186 |
|
|
|
187 |
|
|
To register the data set and add it to the map:
|
188 |
|
|
|
189 |
6870
|
jones
|
1. Point your browser to ``http://your.server/geoserver``, log in to GeoServer,
|
190 |
|
|
and navigate to the "Data Stores" configuration page under ``Data > Stores``.
|
191 |
8265
|
leinfelder
|
2. Create a new vector data source from a Shapefile in the "metacat" workspace.
|
192 |
6844
|
jones
|
|
193 |
6870
|
jones
|
.. figure:: images/screenshots/image055.png
|
194 |
6844
|
jones
|
:align: center
|
195 |
|
|
|
196 |
|
|
Creating a new shapefile using GeoServers web-based administrative interface.
|
197 |
|
|
|
198 |
6870
|
jones
|
3. The Description, if specified, is mostly used internally to provide other
|
199 |
6844
|
jones
|
administrators with information about the DataStore. Click Submit.
|
200 |
6870
|
jones
|
4. Navigate to the "Layers" configuration page under Data > Layers.
|
201 |
|
|
Add a new Layer from your new data source.
|
202 |
|
|
5. You should also define a spatial reference system (SRS) number for the new
|
203 |
|
|
layer. Most lat/long data is "4326". If your data is in another projection,
|
204 |
|
|
determine its spatial reference system using the help links provided.
|
205 |
6844
|
jones
|
|
206 |
6870
|
jones
|
.. figure:: images/screenshots/image057.png
|
207 |
6844
|
jones
|
:align: center
|
208 |
|
|
|
209 |
6870
|
jones
|
GeoServer's FeatureType configuration. The SRS settings discussed in step 5 are highlighted.
|
210 |
6844
|
jones
|
|
211 |
6870
|
jones
|
6. Style the layer using a style from the drop-down menu on the Publishing tab,
|
212 |
|
|
or create a new SLD to create a new style object and corresponding SLD
|
213 |
|
|
(this option provides more control over the style).
|
214 |
|
|
7. Try out the styled data set as a WMS layer using a the Layer Preview.
|
215 |
6844
|
jones
|
|
216 |
6870
|
jones
|
.. figure:: images/screenshots/image058.png
|
217 |
|
|
:align: center
|
218 |
|
|
|
219 |
|
|
GeoServer's Layer Preview allows you to see an OpenLayer rendering of the new layer.
|
220 |
6844
|
jones
|
|
221 |
6870
|
jones
|
8. Copy the default ``map.js`` file that assembles the map in OpenLayers
|
222 |
8265
|
leinfelder
|
(``style/common/spatial/map.js``) to your skin's spatial directory.
|
223 |
|
|
9. Edit the init() method to include your new layer in the map - either as an
|
224 |
6870
|
jones
|
overlay or as a base layer.
|
225 |
|
|
10. Point your browser to the map interface. Your new layer should appear with
|
226 |
6844
|
jones
|
the existing ones.
|
227 |
|
|
|
228 |
|
|
Adding External Spatial Data Made Publically Available through WMS
|
229 |
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
230 |
|
|
There are hundreds of sources of spatial data made publically available
|
231 |
6870
|
jones
|
through WMS (check out http://wms-sites.com for a good catalog). To add these
|
232 |
8265
|
leinfelder
|
data sources to your map, add the layers in your skin's ``spatial/map.js`` file.
|
233 |
6844
|
jones
|
|
234 |
|
|
Spatial Queries
|
235 |
|
|
---------------
|
236 |
|
|
To find out which documents in the Metacat repository lie in a specified
|
237 |
|
|
geographic region, query the spatial cache using Metacat's spatial_query action.
|
238 |
|
|
Metacat can perform any query supported by the WFS/WMS standards.
|
239 |
|
|
|
240 |
|
|
An example of a spatial query string is::
|
241 |
|
|
|
242 |
8265
|
leinfelder
|
http://localhost/metacat/metacat?action=spatial_query&xmin=-117.5&xmax=-64&ymin=3&ymax=46&skin=default
|
243 |
6844
|
jones
|
|
244 |
|
|
Where ``xmin``, ``xmax``, ``ymin`` and ``ymax`` represent the western, eastern,
|
245 |
|
|
southern and northern bounding coordinates (the "bounding box"), respectively.
|
246 |
|
|
The spatial query action returns all documents that overlap or that are
|
247 |
|
|
contained inside the specified spatial coordinates. The result set is returned
|
248 |
|
|
as HTML using the style of the specified skin (in this example, default).
|