Book Image

GeoServer Cookbook

By : Stefano Iacovella
Book Image

GeoServer Cookbook

By: Stefano Iacovella

Overview of this book

Table of Contents (17 chapters)
GeoServer Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

WMS versus the mapping service


As an ESRI user, you surely know how to publish some data in a map service. This lets you create a web service that can be used by a client who wants to show the map and data. This is the proprietary equivalent of exposing data through a WMS service.

With WMS, you can inquire the server for its capabilities with an HTTP request:

$ curl -XGET -H 'Accept: text/xml' 'http://localhost:8080/geoserver/wms?service=WMS&version=1.1.1&request=GetCapabilities' -o capabilitiesWMS.xml

Browsing through the XML document, you'll know which data is published and how this can be represented.

If you're using the proprietary way of exposing map services with ESRI, you can perform a similar query that starts from the root:

$ curl -XGET 'http://localhost/arcgis/rest/services?f=pjson' -o capabilitiesArcGIS.json

The output, in this case formatted as a JSON file, is a text file containing the first of the services and folders available to an anonymous user. It looks like the following code snippet:

{
 "currentVersion": 10.22,
 "folders": [
  "Geology",
  "Cultural data",
…
  "Hydrography"
 ],
 "services": [
  {
   "name": "SampleWorldCities",
   "type": "MapServer"
  }
 ]
}

At a glance, you can recognize two big differences here. Firstly, there are logical items, which are the folders that work only as a container for services. Secondly, there is no complete definition of items, just a list of elements contained at a certain level of a publishing tree.

To obtain specific information about an element, you can perform another request pointing to the item:

$ curl -XGET 'http://localhost/arcgis/rest/services/SampleWorldCities/MapServer?f=pjson' -o SampleWorldCities.json

Tip

Setting up an ArcGIS site is out of the scope of this book; besides, this appendix assumes that you are familiar with the software and its terminology. Anyway, all the examples use the SampleWorldCities service, which is a default service created by the standard installation.

In the new JSON file, you'll find a lot of information about the specific service:

{
 "currentVersion": 10.22,
 "serviceDescription": "A sample service just for demonstation.",
 "mapName": "World Cities Population",
 "description": "",
 "copyrightText": "",
 "supportsDynamicLayers": false,
 "layers": [
  {
   "id": 0,
   "name": "Cities",
   "parentLayerId": -1,
   "defaultVisibility": true,
   "subLayerIds": null,
   "minScale": 0,
   "maxScale": 0
  },
…
"supportedImageFormatTypes": "PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP","capabilities": "Map,Query,Data",
 "supportedQueryFormats": "JSON, AMF",
 "exportTilesAllowed": false,
 "maxRecordCount": 1000,
 "maxImageHeight": 4096,
 "maxImageWidth": 4096,
 "supportedExtensions": "KmlServer"
}

Please note the information about the image format supported. We're, in fact, dealing with a map service. As for the operation supported, this one shows three different operations: Map, Query, and Data. For the first two, you can probably recognize the equivalent of the GetMap and GetFeatureinfo operations of WMS, while the third one is little bit more mysterious. In fact, it is not relevant to map services and we'll explore it in the next paragraph.

If you're familiar with the GeoServer REST interface, you can see the similarities in the way you can retrieve information.

We don't want to explore the ArcGIS for Server interface in detail and how to handle it. What is important to understand is the huge difference with the standard WMS capabilities document. If you're going to create a client to interact with maps produced by a mix of ArcGIS for Server and GeoServer, you should create different interfaces for both. In one case, you can interact with the proprietary REST interface and use the standard WMS for GeoServer.

However, there is good news for you. ESRI also supports standards. If you go to the map service parameters page, you can change the way the data is published.

The situation shown in the previous screenshot is the default capabilities configuration. As you can see, there are options for WMS, WFS, and WCS, so you can expose your data with ArcGIS for Server according to the OGC standards.

If you enable the WMS option, you can now perform this query:

$ curl -XGET 'http://localhost/arcgis/services/SampleWorldCities/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities'-o capabilitiesArcGISWMS.xml

The information contained is very similar to that of the GeoServer capabilities. A point of attention is about fundamental differences in data publishing with the two software. In ArcGIS for Server, you always start from a map project. A map project is a collection of datasets, containing vector or raster data, with a drawing order, a coordinate reference system, and rules to draw.

It is, in fact, very similar to a map project you can prepare with a GIS desktop application. Actually, in the ESRI world, you should use ArcGIS for desktop to prepare the map project and then publish it on the server.

In GeoServer, the map concept doesn't exist. You publish data, setting several parameters, and the map composition is totally demanded to the client. You can only mimic a map, server side, using the group layer for a logical merge of several layers in a single entity.

In ArcGIS for Server, the map is central to the publication process; also, if you just want to publish a single dataset, you have to create a map project, containing just that dataset, and publish it.

Always remember this different approach; when using WMS, you can use the same operation on both servers. A GetMap request on the previous map service will look like this:

$ curl -XGET 'http://localhost/arcgis/services/SampleWorldCities/MapServer/WMSServer?service=WMS&version=1.1.0&request=GetMap&layers=fields&styles=&bbox=47.130647,8.931116,48.604188,29.54223&srs=EPSG:4326&height=445&width=1073&format=img/png' -o map.png

Please note that you can filter what layers will be drawn in the map. By default, all the layers contained in the map service definition will be drawn.