The Symaptic Smallworld scripts which export the Smallworld data into Postgres also automatically generate and configure the map layer and style information in GeoServer.
The scripts use Smallworld style “0” for each of the extracted layers. It is likely that you may require more sophisticated styles, or perhaps just want to tweak the styles that have been generated.
To begin editing the styles:
- Log into the GeoServer services (see Checking the Map Server for more details on this)
- Select the Styles option under the Data section:
- Select the style that you would like to edit, for example pub_rest
- You will now see the style definition for pub_rest. You will see that there is a box called Style Editor that contains an SLD (styled layer descriptor) style definition. SLDs are an OGC (Open Geospatial Consortium) standard for style definitions. Lots of great details about SLDs can be found on the OGC website or on the GeoServer website.
- If you read through the SLD for the pub_rest layer, you will see the details for when the zoom scales at which the layer becomes visible, as well as what icons it uses to display this particular feature. Here we can see that the icon used at the 7,000 to 75,000 is pub_rest_329307_normal.png. The location of that icon in our Symaptic directory is symaptic\geoserver\data_dir\www\styles
- In fact, if we look in that directory we see all the SLD files and image files making up our point styles:
- If we wanted to make our pub_rest layer style a darker colour of orange, open the related png files with your favourite graphic editor (eg. Gimp) and edit them as required (note the slightly darker orange of the pub_rest images below):
- Or for something a little more tricky we may want to make the pub_rest images a bright green when the parking attribute value of the pub_rest feature is Easy. To do this you first need to create the green icon using your favourite image editor:
- Then update the SLD file pub_rest.sld (in the same directory) as follows:
<?xml version='1.0' encoding='ISO-8859-1'?> <StyledLayerDescriptor version='1.0.0' xsi:schemaLocation='http://www.opengis.net/sld StyledLayerDescriptor.xsd' xmlns='http://www.opengis.net/sld' xmlns:ogc='http://www.opengis.net/ogc' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <NamedLayer> <Name>pub_rest</Name><UserStyle><Title>pub_rest</Title> <FeatureTypeStyle> <Rule> <Name>location (10000)</Name> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:PropertyName>parking</ogc:PropertyName> <ogc:Literal>Easy</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> <MinScaleDenominator>7000.00000000</MinScaleDenominator><MaxScaleDenominator>75000.0000000</MaxScaleDenominator> <PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel"> <Geometry><ogc:PropertyName>location</ogc:PropertyName></Geometry> <Graphic> <ExternalGraphic> <OnlineResource xlink:type='simple' xlink:href='http://localhost:9103/geoserver/www/styles/pub_rest_easy_parking_normal.png'/> <Format>image/png</Format> </ExternalGraphic> <Size>50.0000000000</Size> </Graphic> </PointSymbolizer> </Rule> <Rule> <Name>location (10000)</Name> <MinScaleDenominator>7000.00000000</MinScaleDenominator><MaxScaleDenominator>75000.0000000</MaxScaleDenominator> <PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel"> <Geometry><ogc:PropertyName>location</ogc:PropertyName></Geometry> <Graphic> <ExternalGraphic> <OnlineResource xlink:type='simple' xlink:href='http://localhost:9103/geoserver/www/styles/pub_rest_329307_normal.png'/> <Format>image/png</Format> </ExternalGraphic> <Size>50.0000000000</Size> </Graphic> </PointSymbolizer> </Rule> <Rule> <Name>location (1250)</Name> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:PropertyName>parking</ogc:PropertyName> <ogc:Literal>Easy</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> <MinScaleDenominator>500.000000000</MinScaleDenominator><MaxScaleDenominator>7000.00000000</MaxScaleDenominator> <PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel"> <Geometry><ogc:PropertyName>location</ogc:PropertyName></Geometry> <Graphic> <ExternalGraphic> <OnlineResource xlink:type='simple' xlink:href='http://localhost:9103/geoserver/www/styles/pub_rest_easy_parking_normal.png'/> <Format>image/png</Format> </ExternalGraphic> <Size>50.0000000000</Size> </Graphic> </PointSymbolizer> </Rule> <Rule> <Name>location (1250)</Name> <MinScaleDenominator>500.000000000</MinScaleDenominator><MaxScaleDenominator>7000.00000000</MaxScaleDenominator> <PointSymbolizer uom="http://www.opengeospatial.org/se/units/pixel"> <Geometry><ogc:PropertyName>location</ogc:PropertyName></Geometry> <Graphic> <ExternalGraphic> <OnlineResource xlink:type='simple' xlink:href='http://localhost:9103/geoserver/www/styles/pub_rest_329306_normal.png'/> <Format>image/png</Format> </ExternalGraphic> <Size>50.0000000000</Size> </Graphic> </PointSymbolizer> </Rule> </FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>
- Now in GeoServer, upload the new SLD and submit the uploaded result. If you refresh the Symaptic Web GIS Client you will now see the different styles being used:
- SLDs are very flexible and where necessary and the right approach can achieve similar levels of style complexity to that of Smallworld. For more examples and options for styling, have a look at the examples on the GeoServer website.