Project

General

Profile

1 4307 leinfelder
 /*
2
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
3
$Id: StyledLayerDescriptor.js 3947 2008-03-27 18:13:25Z ahocevar $
4
*/
5
6
// Ensure this object's dependancies are loaded.
7
mapbuilder.loadScript(baseDir+"/model/ModelBase.js");
8
9
/**
10
 * Stores a SLD file  as defined by the
11
 * Open Geospatial Consortium (http://www.opengeospatial.org/).
12
 *
13
 * @constructor
14
 * @base ModelBase
15
 * @author Olivier Terral
16
 * @requires Sarissa
17
 * @param modelNode The model's XML object node from the configuration document.
18
 * @param parent    The parent model for the object.
19
 */
20
function StyledLayerDescriptor(modelNode, parent) {
21
  // Inherit the ModelBase functions and parameters
22
  ModelBase.apply(this, new Array(modelNode, parent));
23
24
  this.sld = null;
25
  this.namespace = "xmlns:sld='http://www.opengis.net/sld' xmlns:mb='http://mapbuilder.sourceforge.net/mapbuilder' xmlns:wmc='http://www.opengis.net/context' xmlns:wms='http://www.opengis.net/wms' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:ogc='http://www.opengis.net/ogc' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:wfs='http://www.opengis.net/wfs'";
26
  this.sldXPath = this.getProperty("mb:sldXPath", "/sld:StyledLayerDescriptor");
27
28
  this.getSldNode=function() {
29
  	return this.doc.selectSingleNode(this.sldXPath);
30
  }
31
32
  /**
33
   * loads the sld into an OpenLayers hash representing the sld.
34
   * @param objRef reference to this model.
35
   */
36
  this.loadSLD = function(objRef) {
37
    var format = new OpenLayers.Format.SLD();
38
    var sldNode = objRef.doc.selectSingleNode(objRef.sldXPath);
39
    objRef.sld = format.read(new XMLSerializer().serializeToString(sldNode));
40
  }
41
  this.addFirstListener("loadModel", this.loadSLD, this);
42
43
}