Revision 6844
Added by Matt Jones over 12 years ago
geoserver.rst | ||
---|---|---|
1 | 1 |
Metacat's Use of Geoserver |
2 | 2 |
========================== |
3 | 3 |
|
4 |
Under construction! |
|
4 |
GeoServer 1.4.0, an open source Web Mapping Service (WMS) written in Java, is |
|
5 |
bundled with Metacat and can be used to render spatial data as web-deliverable |
|
6 |
maps (see figure). Metacat uses Community MapBuilder (a pure HTML and JavaScript |
|
7 |
application that uses AJAX and XSLT) to provide a web-based user interface for |
|
8 |
interacting with the generated maps. You can use any WMS-compatible client |
|
9 |
(e.g., ArcGIS, QGIS, JUMP, UDig, OpenLayers, Mapbender, Map Builder). Please |
|
10 |
note the mapping functionality is only supported for Metacat servlets running |
|
11 |
under Tomcat 6 or later. |
|
5 | 12 |
|
6 |
Heading 1 |
|
7 |
------------ |
|
13 |
IMPORTANT: Regardless of whether you plan on using the mapping functionality |
|
14 |
you should, for security purposes, configure GeoServer so that it doesn't |
|
15 |
use the default password. For instructions, please see |
|
16 |
Geoserver Password Configuration. |
|
8 | 17 |
|
9 |
Heading 2 |
|
10 |
------------ |
|
18 |
.. figure:: images/screenshots/image051.jpg |
|
19 |
:align: center |
|
20 |
|
|
21 |
A map generated by Metacat's GeoServer. Points and "bounding boxes" |
|
22 |
represent the geographic extent of datasets stored in the KNB Metacat repository. |
|
11 | 23 |
|
24 |
GeoServer supports a wide variety of vector GIS data sources, which can be |
|
25 |
styled using Styled Layer Descriptors (SLDs) and output as images (the default) |
|
26 |
or raw vector data (GML or KML). |
|
27 |
|
|
28 |
Currently, GeoServer can be used with the following limitations: |
|
29 |
|
|
30 |
* The GeoServer will only map documents that are publicly available. This is |
|
31 |
because the mapping server's support for permissions control is not as |
|
32 |
fine-grained as Metacat's. |
|
33 |
* The GeoServer can only access documents that conform to one chosen schema. |
|
34 |
This is because only one set of xpaths can be defined in the Metacat properties. |
|
35 |
* GeoServer 1.4, the version bundled with Metacat, does not support raster |
|
36 |
input (e.g., satellite imagery or digital elevation models). We suggest |
|
37 |
setting up UMN Mapserver if you aim to serve raster data. |
|
38 |
|
|
39 |
Metacat developers plan to continue extending and improving Metacat's mapping |
|
40 |
capabilities. If you are interested in contributing to those efforts, or if |
|
41 |
you are interested in learning more about the architecture and future plans for |
|
42 |
the mapping software. |
|
43 |
|
|
44 |
Installing and Configuring |
|
45 |
-------------------------- |
|
46 |
Metacat's GeoServer is automatically installed when Metacat is installed. If |
|
47 |
you do NOT wish to run GeoServer, set the runSpatialOption property in the |
|
48 |
``metacat.properties`` file (found in the source code's lib directory) to |
|
49 |
false before building and deploying Metacat. |
|
50 |
|
|
51 |
The GeoServer bundled with Metacat comes with a world-countries base layer |
|
52 |
and a default configuration that is already aware of Metacat's spatial cache. |
|
53 |
To further configure GeoServer, use its Web-based configuration utility, |
|
54 |
which is available at: http://your.server.com/context/geoserver.jsp |
|
55 |
(e.g., http://knb.ecoinformatics.org/knb/geoserver.jsp). |
|
56 |
|
|
57 |
Common configuration tasks include: |
|
58 |
|
|
59 |
* Adding a Map to a Web Page or Skin |
|
60 |
* Configuring the Size and Initial Extent of the Map |
|
61 |
* Configuring the Layout of the HTML Mapping Interface |
|
62 |
* Changing the Lat/Long Display to Degree-Minutes-Seconds |
|
63 |
* Configuring the "Select Location Drop-down Menu |
|
64 |
* Configuring the Visual Portrayal of Geospatial Data (e.g., symbology and color) |
|
65 |
* Adding Other Spatial Datasets to the Web Map |
|
66 |
|
|
67 |
.. figure:: images/screenshots/image053.jpg |
|
68 |
:align: center |
|
69 |
|
|
70 |
GeoServer's Web-based administrative interface. |
|
71 |
|
|
72 |
Note: Some configurations may need to be made to the XML files as well. |
|
73 |
|
|
74 |
Community Mabuilder, which Metacat uses as the front-end for GeoServer's WMS |
|
75 |
service, provides interface components or "widgets" (e.g., the map, a box zoom, |
|
76 |
layer list, "Select Location" drop-down menu, scale bar, lat/long coordinates, |
|
77 |
and a query form) that make it easy to deploy highly-functional Web mapping |
|
78 |
applications with minimal coding. The WMS layers are configured through a Web |
|
79 |
Map Context (WMC) document. This context document can be edited to customize |
|
80 |
the initial extent of the map, the ordering and visibility of layers and, of |
|
81 |
course, the source and name of the WMS layer. |
|
82 |
|
|
83 |
Mapbuilder has three main configuration files used to customize the map |
|
84 |
interface (Table 5.1). If you plan to customize the map interface, you must |
|
85 |
use a source code distribution of Metacat. Default configurations are in:: |
|
86 |
|
|
87 |
$METACAT/lib/style/common/spatial_templates/spatial1/ |
|
88 |
|
|
89 |
+--------------------------------+-------------+---------------------------------------------------------------------+ |
|
90 |
| Document | Location | Description | |
|
91 |
+--------------------------------+-------------+---------------------------------------------------------------------+ |
|
92 |
| Web map context document (WMC) | context.xml | The WMC is used to customize the initial extent of the map, | |
|
93 |
| | | the order of the map layers, and the source and name of each layer. | |
|
94 |
+--------------------------------+-------------+---------------------------------------------------------------------+ |
|
95 |
| Mapbuilder configuration file | context.xml | Defines the Mapbuilder widgets and their behavior | |
|
96 |
+--------------------------------+-------------+---------------------------------------------------------------------+ |
|
97 |
| The Map file | map.html | Loads the Mapbuilder JavaScript library and controls the | |
|
98 |
| | | HTML layout of the widgets. | |
|
99 |
+--------------------------------+-------------+---------------------------------------------------------------------+ |
|
100 |
|
|
101 |
NOTE: By default, the first time Metacat is restarted, it generates a |
|
102 |
"spatial cache" containing geographic information about documents in its |
|
103 |
repository. This default behavior is specified in lib/metacat.properties, |
|
104 |
where the regenerateCacheOnRestart parameter is set to true. The information |
|
105 |
in the spatial cache is stored in a GIS-compatible format (the ESRI Shapefile) |
|
106 |
and consists of the document name and its geographic coverage. When documents |
|
107 |
are inserted, deleted, and updated in the Metacat repository, Metacat |
|
108 |
automatically syncs the spatial cache to reflect the changes. Because |
|
109 |
generating the cache can take a considerable amount of time (several minutes |
|
110 |
in the case of a few thousand documents), Metacat resets the |
|
111 |
regenerateCacheOnRestart property to false after the spatial cache has been |
|
112 |
generated. Note that if you upgrade or reinstall Metacat, the spatial cache |
|
113 |
will be regenerated again. |
|
114 |
|
|
115 |
Adding a Map to a Web Page or Skin |
|
116 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
117 |
To add a map to a Web page, simply include the map interface using an iframe:: |
|
118 |
|
|
119 |
<iframe scrolling="no" frameborder="0" width="736" height="520" |
|
120 |
src="/knb/style/common/spatial_templates/spatial1/map.html"> |
|
121 |
</iframe> |
|
122 |
|
|
123 |
The map URL, ``/knb/style/common/spatial_templates/spatial1/map.html``, is |
|
124 |
the default map interface. If you plan to customize the map interface, copy |
|
125 |
the spatial1 directory into your skin's directory (either the default or |
|
126 |
customized skin directory). |
|
127 |
|
|
128 |
:: |
|
129 |
|
|
130 |
cp -r style/common/spatial_templates/spatial1 /style/skins/<myskin>/spatial |
|
131 |
|
|
132 |
You can access the customized map with the URL: ``/knb/style/skins/<myskin>/spatial/map.html`` |
|
133 |
|
|
134 |
Configuring the Size and Initial Extent of the Map |
|
135 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
136 |
Before you configure the size and initial extent of the map, make sure that you |
|
137 |
have copied the default spatial settings into your skin's directory (see :doc:`configuration`). |
|
138 |
Once the settings have been copied, you can modify the map's initial extent in |
|
139 |
the context settings: ``${skin.dir}/spatial/context.xml``. |
|
140 |
|
|
141 |
To change the map size and/or initial extent, edit the following lines:: |
|
142 |
|
|
143 |
<Window width="720" height="360" /> |
|
144 |
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-90" maxx="180" maxy="90" /> |
|
145 |
|
|
146 |
Where ``width`` and ``height`` specify the map size in pixels, ``minx/maxx`` |
|
147 |
represent the range of longitudes and ``miny/maxy`` represent the range of latitudes. |
|
148 |
|
|
149 |
Configuring the Layout of the HTML Mapping Interface |
|
150 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
151 |
Before you configure the size and initial extent of the map, make sure that |
|
152 |
you have copied the default spatial settings into your skin's directory. |
|
153 |
Once the settings have been copied, you can modify the layout here: |
|
154 |
``${skin.dir}/spatial/map.html``. |
|
155 |
|
|
156 |
``Map.html`` is a simple HTML file with a tabular layout. Map components are |
|
157 |
abstracted into "widgets", blocks with a specific id (e.g., locationsSelect |
|
158 |
and mainButtonBar), which can be reorganized within the table. |
|
159 |
To customize the map extent and appearance, modify the Web map context |
|
160 |
document (``context.xml``) and/or Mapbuilder's configuration file (``config.xml``). |
|
161 |
Both files are in the spatial directory inside the skins folder. |
|
162 |
|
|
163 |
Changing the Lat/Long Display to Degree-Minutes-Seconds |
|
164 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
165 |
By default, the map display shows the cursor's position in decimal degrees |
|
166 |
(the preferred format for many GPS/GIS applications). To report coordinates as |
|
167 |
degrees minutes-seconds, edit the spatial configuration file: |
|
168 |
|
|
169 |
1. If you have not already copied the default spatial settings into your skin's |
|
170 |
directory, do so now |
|
171 |
2. Open the ${skin.dir}/spatial/config.xml file. |
|
172 |
3. Edit the CursorTrack widget so that the content is the following: |
|
173 |
|
|
174 |
:: |
|
175 |
|
|
176 |
<CursorTrack id="cursorTrack"> |
|
177 |
<mouseHandler>mainMap</mouseHandler> |
|
178 |
<showDMS>true</showDMS> |
|
179 |
<showLatLong>true</showLatLong> |
|
180 |
</CursorTrack> |
|
181 |
|
|
182 |
4. Save and close the configuration file. |
|
183 |
|
|
184 |
Configuring the "Select Location" Drop-down Menu |
|
185 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
186 |
Before you configure the menu items, make sure that you have copied the default |
|
187 |
spatial settings into your skin's directory. |
|
188 |
|
|
189 |
The locations that appear in the "Select Location" drop-down menu are specified |
|
190 |
in the ``${skin.dir}/spatial/named_locations.xml`` file. Each location is |
|
191 |
defined as a ``gml:featureMember``. Edit the featureMember's ``gml:name`` and |
|
192 |
``gml:coordinates`` fields to edit or add new locations. |
|
193 |
|
|
194 |
:: |
|
195 |
|
|
196 |
<gml:featureMember> |
|
197 |
<locationDef> |
|
198 |
<gml:name>ACM Wilderness Field Station</gml:name> |
|
199 |
<spatialKeyword> |
|
200 |
<gml:location> |
|
201 |
<gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> |
|
202 |
<gml:coordinates>-91.956,47.87 -91.706,48.12</gml:coordinates> |
|
203 |
</gml:Envelope> |
|
204 |
</gml:location> |
|
205 |
</spatialKeyword> |
|
206 |
</locationDef> |
|
207 |
</gml:featureMember> |
|
208 |
|
|
209 |
Configuring the Visual Portrayal of Geospatial Data (e.g., symbology and color) |
|
210 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
211 |
Geospatial data sets are styled through the use of Styled Layer Descriptors |
|
212 |
(SLD). The default SLDs used for the data points and data bounding boxes are in |
|
213 |
``/lib/spatial/geoserver/data/styles/`` and are named data_points_style.sld and |
|
214 |
data_bounds_style.sld, respectively. |
|
215 |
|
|
216 |
You can find a more detailed tutorial on using SLD with GeoServer at:: |
|
217 |
|
|
218 |
http://geoserver.org/display/GEOSDOC/SLD+Intro+Tutorial. |
|
219 |
|
|
220 |
Adding Other Spatial Datasets to the Web Map |
|
221 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
222 |
If you have vector GIS data sets, such as weather or topographical information, |
|
223 |
on your server that you'd like to include in the interactive map, you must |
|
224 |
first register the data set with GeoServer. After the data set has been |
|
225 |
registered, you can add the layer to the map. You can also add spatial layers |
|
226 |
that have been made publically available through WMS (There are hundreds of |
|
227 |
spatial data sets available. Check out wms-sites.com for good catalog). |
|
228 |
Instructions for adding publically available layers are included at the end |
|
229 |
of this section. |
|
230 |
|
|
231 |
To register the data set and add it to the map: |
|
232 |
|
|
233 |
1. Point your browser to http://your.server/context/geoserver.jsp, log in to |
|
234 |
GeoServer, and navigate to the "Data Stores" configuration page |
|
235 |
under Config > Data > Stores. |
|
236 |
2. Create a new Shapefile and assign it a DataStore ID. The DataStore ID can |
|
237 |
contain letters and numbers. It is just used internally, and should be |
|
238 |
unique. Click New. |
|
239 |
|
|
240 |
.. figure:: images/screenshots/image055.jpg |
|
241 |
:align: center |
|
242 |
|
|
243 |
Creating a new shapefile using GeoServers web-based administrative interface. |
|
244 |
|
|
245 |
3. On the next screen, select the "metacat" namespace from the drop-down menu |
|
246 |
and point to the GIS data file on the file system, relative to: |
|
247 |
|
|
248 |
:: |
|
249 |
|
|
250 |
{tomcat.dir}/webapps/{context}/ |
|
251 |
|
|
252 |
The Description, if specified, is mostly used internally to provide other |
|
253 |
administrators with information about the DataStore. Click Submit. |
|
254 |
|
|
255 |
4. Navigate to the "Feature Type" configuration page under |
|
256 |
Config > Data > Feature Type. Select your new data store from the |
|
257 |
drop-down menu. Click New. |
|
258 |
5. Style the layer using a style from the drop-down style menu, or click |
|
259 |
"Create new SLD" to create a new Style object and corresponding SLD |
|
260 |
(this option provides more control over the style). You should also define a |
|
261 |
spatial reference system (SRS) number for the new layer. |
|
262 |
Most lat/long data is "4326". If your data is in another projection, |
|
263 |
determine its spatial reference system using the help links provided. |
|
264 |
|
|
265 |
.. figure:: images/screenshots/image057.jpg |
|
266 |
:align: center |
|
267 |
|
|
268 |
GeoServer's FeatureType Editor. The Style and SRS settings discussed in step 5 are highlighted. |
|
269 |
|
|
270 |
6. Click "Apply" and "Save" |
|
271 |
7. Try out the styled data set as a WMS layer using a URL like: |
|
272 |
|
|
273 |
:: |
|
274 |
|
|
275 |
http://your.server/context/wms?VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=metacat:newLayer&SRS=EPSG:4326&BBOX=-180,-90,180,90&WIDTH=720&HEIGHT=360&FORMAT=image/gif&STYLES=&TRANSPARENT=TRUE&UNIQUEID= |
|
276 |
|
|
277 |
Where your.server/context is the name of your server and context (e.g., |
|
278 |
http://knb.ecoinformatics.org/knb) and newLayer is the name of the new layer. |
|
279 |
The other parameters control which part of the layer is displayed. |
|
280 |
|
|
281 |
If data is properly displayed, add the map to your map context document (Step 8). |
|
282 |
|
|
283 |
8. Locate the Web map context document (usually {skin}/spatial/context.xml) and |
|
284 |
open the file in a text editor. |
|
285 |
9. Locate the Layer entry for an existing layer next to which you wish to stack |
|
286 |
your layer (the first layers in the context are rendered at the bottom). |
|
287 |
|
|
288 |
10. Create a new Layer entry, by copying and pasting the existing entry for the |
|
289 |
metacat data_points layer and editing the Layer Name and Title. The title |
|
290 |
is displayed in the map legend. Note: if you'd like to use transparency, |
|
291 |
leave the image format set to image/gif (IE pre-7 has trouble with PNG |
|
292 |
transparency). |
|
293 |
|
|
294 |
:: |
|
295 |
|
|
296 |
<Layer queryable="0" hidden="0"> |
|
297 |
<Server service="OGC:WMS" version="1.1.1" |
|
298 |
title="DatasetPoints"> |
|
299 |
<OnlineResource xlink:type="simple" xlink:href="../../../../wms" /> |
|
300 |
</Server> |
|
301 |
<Name>metacat:data_points</Name> |
|
302 |
<Title>Dataset Points</Title> |
|
303 |
<SRS>EPSG:4326</SRS> |
|
304 |
<FormatList> |
|
305 |
<Format current="1">image/gif</Format> |
|
306 |
</FormatList> |
|
307 |
</Layer> |
|
308 |
|
|
309 |
11. Point your browser to the map interface. Your new layer should appear with |
|
310 |
the existing ones. |
|
311 |
|
|
312 |
Adding External Spatial Data Made Publically Available through WMS |
|
313 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
314 |
There are hundreds of sources of spatial data made publically available |
|
315 |
through WMS. (check out http://wms-sites.com for good catalog). To add these |
|
316 |
data sources to your map, locate your skin's context file |
|
317 |
(``${skin.dir}/spatial/context.xml``) and add a new Layer by copying and |
|
318 |
pasting an existing Layer and modifying as appropriate: modify the |
|
319 |
OnlineResourceURL, Name, Title and Style to match the WMS layer you'd like to |
|
320 |
use. See the mapbuilder Add WMS Tutorial for further details. |
|
321 |
|
|
322 |
Spatial Queries |
|
323 |
--------------- |
|
324 |
To find out which documents in the Metacat repository lie in a specified |
|
325 |
geographic region, query the spatial cache using Metacat's spatial_query action. |
|
326 |
Metacat can perform any query supported by the WFS/WMS standards. |
|
327 |
|
|
328 |
An example of a spatial query string is:: |
|
329 |
|
|
330 |
http://localhost/knb/metacat?action=spatial_query&xmin=-117.5&xmax=-64&ymin=3&ymax=46&skin=default |
|
331 |
|
|
332 |
Where ``xmin``, ``xmax``, ``ymin`` and ``ymax`` represent the western, eastern, |
|
333 |
southern and northern bounding coordinates (the "bounding box"), respectively. |
|
334 |
The spatial query action returns all documents that overlap or that are |
|
335 |
contained inside the specified spatial coordinates. The result set is returned |
|
336 |
as HTML using the style of the specified skin (in this example, default). |
|
337 |
|
Also available in: Unified diff
Completed 'Submission' page conversion, and also converted GeoServer docs to
RST format.