[OpenLayers-Dev] "design pattern" question

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Mon Apr 7 07:38:05 EDT 2008


Hi list,

I've been wresting with the following use case for quite some time now, so I
am seeking advice here.

My use case is the following:

1) I have a layer which is of type OpenLayers.Layer.WMS
2) to get the WFS associated with this layer, I perform an SLD WMS
DescribeLayer request, this gives me back the location of the WFS and the
name of the typename
3) using the info from step 2), I perform a WFS DescribeFeatureType request
and parse the result in order to get a list of attributes for this layer.

I've got this code working using a sequence of OpenLayers.LoadURL calls, but
now I want to create a utility function which wraps the above functionality
into 1 function. Can this be done without reverting to a synchronous call? I
need the response from 2) in order to do 3).

I.e. this is what I have now:

var url =  layer.getFullRequestString({REQUEST: "DescribeLayer"});
OpenLayers.loadURL(url, '', this, this.parseDescribeLayer);

..

parseDescribeLayer: function(response) {
  // parse the result and call a DescribeFeatureType on the WFS
  ..
  OpenLayers.loadURL(url, '', this, this.parseAttributes);
}

..

parseAttributes: function(response) {
  var descfeaturetype = new  OpenLayers.Format.WFSDescribeFeatureType();
  var attributes = descfeaturetype.read(response.responseText);
  this.layer.attributes = attributes;
}

What I would want to do is:

OpenLayers.Util.getAttributes(layer)

which performs all of the above and only returns when it has finished all
operations.

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl








More information about the Dev mailing list