[OpenLayers-Users] Clip WMS layers

Polet Guillaume guillaume.polet at trasys.be
Fri Feb 12 09:18:33 EST 2010


Hi Christopher,

Thanks for your quick response. I have not put my code because it is a
GWT code (combined with GWT-openlayers library), however it is pretty
straightforward to go from to another. The only problem is that it
requires a much heavier environment to make it run.
Anyway, here is a snippet of what I did, maybe somebody can immediately
spot my error. If not, I will try to set up a complete example.

		// This is the base layers that shows a basic world map
(it goes on a simple MapServer hosted locally)
		WMSParams params = new WMSParams();
		params.setMaxExtent(new Bounds(-180, -90, 180, 90));
		params.setFormat("image/png");
		params.setLayers("world");
		WMS layer = new WMS("Basic",
	
"http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/tutorial/mapfiles/W
orldMap.map",
				params);

		// This is the second layer I would like to clip to the
extent of Africa
		WMSParams p2 = new WMSParams();
		Bounds extent = new Bounds(-25, -38, 52, 35);
		p2.setMaxExtent(extent);
		p2.setFormat("image/png");
		p2.setLayers("Bathymetry,Topography,Hillshading,Builtup
areas,Cities,Borders,Coastlines");
		WMS resLayer = new WMS("Result",
	
"http://www2.demis.nl/wms/wms.asp?wms=WorldMap",
				p2);
		resLayer.setIsBaseLayer(false);
		resLayer.setIsVisible(true); 
		getMap().addLayers(new Layer[]{layer, resLayer});
		getMap().addControl(new LayerSwitcher());
		getMap().addControl(new PanZoomBar());
		getMap().addControl(new Navigation());
		getMap().setCenter(new LonLat(0, 0),1);

With that code, the second layer takes the whole extent and therefore
hides the rest of the map.


Guillaume Polet



-----Original Message-----
From: Christopher Schmidt [mailto:crschmidt at metacarta.com] 
Sent: 12 February 2010 14:58
To: Polet Guillaume
Cc: users at openlayers.org
Subject: Re: [OpenLayers-Users] Clip WMS layers

On Fri, Feb 12, 2010 at 11:03:47AM +0100, Polet Guillaume wrote:
> Hi,
>  
> I wondered if it was possible to have a Basic WMS layer (displaying
for
> example the whole world) and on top of that have a non-basic layer
> clipped to a specific extent. The purpose of this is to display the
> results of a catalogue of images clipped to the selected area of
> interest selected by a user.

I believe this is possible, so long as the overlaid datasource
is not a tiled datasource with extents that are different than the
data extent.

> I tried to use two WMS layers with different extents but this does not
> work (but maybe I have miscoded something).

If you tried something and it didn't work, providing that code will
always
help actually understand the problem.

Regards,
-- 
Christopher Schmidt
MetaCarta
 



More information about the Users mailing list