GeoTools 2 Web Map Server

If you can see a map in the area below this text then you have correctly installed the GT2WMS.

The URL used to generated the map was:
' servlet/gt2wms?request=getMap&layers=USA&bbox=-140,20,-60,60&width=400&height=200&srs=EPSG:4326&styles=green&Format=image/png'

As you can see, a lot of information is passed to your servlet installation to generate the map. For full details of what all the parts of the URL mean, take a look through the OpenGIS Web Map Server specification.

The map is derived from a shapefile in the maps folder using the green style document.

The styling language is the OpenGIS Styled Layer Descriptor (SLD). The one used to make the above map is a very basic one. The most important part of the file is:

<FeatureTypeName>feature</FeatureTypeName>
<Rule>
    <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#66FF66</CssParameter>
        </Fill>   
        <Stroke/>       
    </PolygonSymbolizer>
</Rule>
The FeatureTypeName says what sort of features the style applies to. In this case, it is the rather generic name 'feature' as this is what all shapes generated by the Shapefile datasource are called.

The next block is a Rule. For now it is just a wrapper around a symbolizer though, as you will see in later examples, rules can be used to select which features should be styled.

The next block says that the features should be styled using a PolygonSymbolizer which is handy as the shapes are indeed polygons. Inside that you will find a Fill with its colour set to a rather nice shade of green and a Stroke with no colour set, so it will default to black. If you read the SLD spec you will find out about other options that you can set for fills and strokes, including opacity, patterns and widths.

The following map uses a more advanced style document to shade the states based on their population:

That map was generated using :
' servlet/gt2wms?request=getMap&layers=USA&bbox=-140,20,-60,60&width=400&height=200&srs=EPSG:4326&styles=population&Format=image/png'
using the popshade style document. The legend is drawn using the GetLegendGraphics request servlet/gt2wms?request=getLegendGraphic&layers=USA&styles=population&width=250&height=100&Format=image/png

This style document adds filters to the rules so that different states are shaded in different colours. For example:

<Rule>
    <Filter xmlns:gml="http://www.opengis.net/gml">
      <PropertyIsBetween>
        <PropertyName>PERSONS</PropertyName>
        <LowerBoundary>
          <Literal>2000000</Literal>
        </LowerBoundary>
        <UpperBoundary>
          <Literal>4000000</Literal>
        </UpperBoundary>
      </PropertyIsBetween>
    </Filter>
    <PolygonSymbolizer>
       <Fill>
          <CssParameter name="fill">#FF0000</CssParameter>
       </Fill>     
    </PolygonSymbolizer>
</Rule>

This checks the value of the PERSONS attribute (a column in the shapefile's dbf) to see if it is between 2000000 and 4000000. If it is, then the polygon is filled in red (#ff0000 is the hex value for red).
The filters are very powerful and can include spatial operations as well as mathematical calculations. For full details see the OpenGIS Filter Encoding Specification. The following shows an example of a spatial operation being embedded in the style document:


This image was generated using the following URL

' servlet/gt2wms?request=getMap&layers=USA,USA&bbox=-140,20,-60,60&width=400&height=200&srs=EPSG:4326&styles=normal,bbox&Format=image/png '
which uses the normal and usa_central style documents.
The interesting part is the following filter in the usa_central document:

<Filter  xmlns:gml="http://www.opengis.net/gml">
    <Not>
       <Disjoint>
            <PropertyName>Polygons</PropertyName>
            <gml:Box srsName="http://www.epsg.com">
                <gml:coordinates>-110,37 -95,40</gml:coordinates>
            </gml:Box>
        </Disjoint>
   </Not>
</Filter>
<PolygonSymbolizer>
   <Fill>
      <CssParameter name="fill">#00ff00</CssParameter>
      <CssParameter name="opacity">.5</CssParameter>
   </Fill>     
</PolygonSymbolizer>
which shades only the polygons which are not disjoint from the specified bounding box with a green fill that is 50% transparent.

Expressions can also be used inside the symbolizers to control their parameters. For example, line width can be derived from a roads attributes or, as in the following map, the opacity can be determined from a ratio.

The URL for this map is: ' servlet/gt2wms?request=getMap&layers=USA,USA&bbox=-140,20,-60,60&width=400&height=200&srs=EPSG:4326&styles=manualVsWorkers&Format=image/png'
and the style document is usa_math

This time the important information is in the symbolizer:

<PolygonSymbolizer>
   <Fill>
      <CssParameter name="fill">#000000</CssParameter>
      <CssParameter name="opacity">
        <Div>
            <PropertyName>MANUAL</PropertyName>
            <PropertyName>WORKERS</PropertyName>
        </Div>
      </CssParameter>
   </Fill>
   <stroke/>     
</PolygonSymbolizer>
Note that because the map is semi-transparent it can be combined with another map to produce a combined effect. For example, the following map uses the same style as above as well as another where the colour is determined by the male/female ratio:

The URL for this map is: ' servlet/gt2wms?request=getMap&layers=USA,USA&bbox=-140,20,-60,60&width=400&height=200&srs=EPSG:4326&styles=manualVsWorkers,maleVsFemale'
and male vs female style document is usa_ratio

By using filters to the full and by using expressions within symbolizers, you should be able to define almost any map you like. The remainder of this page looks at how you configure the web map server to show your own maps.

Inside the web application you will find a number of key files. The most important is the layers.xml document. If you take a look you will see that it defines layers, giving their names and a list of styles.
The format of this document is still under development, but from the examples you should see how to set up a shapefile datasource and a postgis datasource. Other datasources, including GML2, will be supported in a future release.

The capabilities.xml document is a template and you should not need to edit it, except to change some contact details if you want to.

The maps shown in this page are not interactive even though they are generated dynamically by the web map server. You will need a Web Map Client if you want to pan, zoom or query the maps interactively. Two good examples, which are known to work with the GT2WMS, are the cubewerx client and the intergraph client.