Tag: WMS

Beware of decimal pixel values in OpenLayers

Posted by – Wednesday 2012-12-19

So you are programming an OpenLayers based map viewer and attempt to make a WMS GetFeatureInfo request, whose response will later be pretty-formatted and shown to the user. To accomplish it you create JavaScript code like the following:

var parameters = {
    srs: map.getProjection(),
    bbox: map.getExtent().toBBOX(6),
    width: map.getSize().w,
    height: map.getSize().h,
    x: evt.xy.x,
    y: evt.xy.y,
    layers: 'municipalities',
    query_layers: 'municipalities'
};

OpenLayers.Request.issue({
    method: 'get',
    url: this.getFeatureInfoUrl,
    async: false,
    params: parameters,
    success: function(data) {
       var responseText = data.responseText;
       // ...
    }
});

where evt (lines 6 and 7) represents the mouse click event that triggered the GetFeatureInfo request.

More…

GeoServer SQL views

Posted by – Monday 2012-08-20

In this post we will see a simple example of how GeoServer’s SQL views [note 1] can be used to derive multiple layers from a SQL table.

1. The arena.

I had a table in a PostGIS database – named roads – that stores the geometries of all roads in the province of Lugo. Each road, besides a geometry, also has attributes which are stored in the table. One of them is the owner of the road, that can be a municipality, the province, the regional government o the central government. The name of this attribute is ‘owner’.

I needed to generate four WMS layers from the data in this table: one containing the roads belonging to municipalities, another one containing the roads belonging to the the province, and so on.

More…

Annotation layers in GeoServer

Posted by – Saturday 2012-07-21

Currently I am in the process of switching from MapServer to GeoServer. As a newcomer to the latter, one of the things I miss is MapServer’s annotation layers. An annotation layer is one that just shows labels, for instance names of towns or countries. In this post we will see how annotation layers can be implemented using GeoServer.

1. The arena.

In our example there is already an existing WMS layer named ‘municipalities’, that contains the borders of some municipalities of Galicia and whose geometry type is multipolygon. The data source is a shapefile. The following screenshot – taken from GeoServer’s administration application – shows the attributes the municipalities have.

GeoServer screenshot

Our goal is showing the municipalities names in a different WMS layer, so an user of the WMS service can toggle the visibility of this annotation layer, that is, being able to show or hide, in every moment, the municipalities’ names. The names of the municipalities are stored in the attribute ‘NOMBRE’.

More…

Custom legend icons in MapServer

Posted by – Thursday 2012-07-05

As seen in a recent post in this blog, MapServer implements the optional WMS request GetLegendGraphic.

You can find that the generated icons do not fit your needs, and prefer that MapServer returns custom legend icons provided by you. Let’s see how can it be accomplished.

First, is convenient that in your LEGEND object you supply the icons size; in our example, it will be 20×20 pixels.

LEGEND
    ...
    KEYSIZE 20 20
END # end of legend object

More…

WMS cascading with MapServer

Posted by – Saturday 2012-06-30

MapServer supports WMS cascading. Recently I have used this feature to serve an ortophoto layer which was already being served from an old WMS service. This feature has allowed me to avoid copying the ortophoto to the new server. Given that orthopotos usually demand lots of hard disk space – even when they are compressed in formats like ECW or MrSID -, I have saved time and storage capacity.

Cascading WMS is easy with MapServer. Just edit the mapfile and add a new layer like the one shown below:

More…