Project

General

Profile

1 3032 perry
/**
2
3
 * Build a Web Map Context (WMC) from a Web Map Server getCapabilities response.
4
5
 * This tool will replace the identified targetModel as opposed to editing
6
7
 * the target model which the EditContext tool will do.
8
9
 * @constructor
10
11
 * @base ToolBase
12
13
 * @param toolNode The tools's XML object node from the configuration document.
14
15
 * @param model    The model that this tool belongs to
16
17
 */
18
19
function Caps2Context(toolNode, model) {
20
21
  ToolBase.apply(this, new Array(toolNode, model));
22
23
24
25
  var styleUrl = baseDir+"/tool/xsl/Caps2Context.xsl";
26
27
  this.stylesheet = new XslProcessor(styleUrl,model.namespace);
28
29
30
31
  // Set stylesheet parameters for all the child nodes from the config file
32
33
  for (var j=0;j<toolNode.childNodes.length;j++) {
34
35
    if (toolNode.childNodes[j].firstChild && toolNode.childNodes[j].firstChild.nodeValue) {
36
37
      this.stylesheet.setParameter(toolNode.childNodes[j].nodeName,toolNode.childNodes[j].firstChild.nodeValue);
38
39
    }
40
41
  }
42
43
44
45
  /**
46
47
   * Listener function which does the transformation and loads the target model
48
49
   * @param requestName the name of the web service operation to execute
50
51
   * @param featureNodeId the id of the node in the doc to be processed by the stylesheet
52
53
   */
54
55
  this.mapAllLayers = function(objRef) {
56
57
    objRef.stylesheet.setParameter("selectedLayer",'');
58
59
    var newContext = objRef.stylesheet.transformNodeToObject(objRef.model.doc);
60
61
    objRef.targetModel.setParam("newModel", null);
62
63
    objRef.targetModel.url = '';
64
65
    objRef.targetModel.doc = newContext;
66
67
    objRef.targetModel.finishLoading();
68
69
  }
70
71
  this.model.addListener("mapAllLayers", this.mapAllLayers, this);
72
73
74
75
  /**
76
77
   * Listener function which does the transformation and loads the target model.
78
79
   * this wersion will convert a single layer from the Capabilities doc into a
80
81
   * context doc.
82
83
   * @param requestName the name of the web service operation to execute
84
85
   * @param featureNodeId the id of the node in the doc to be processed by the stylesheet
86
87
   */
88
89
  this.mapSingleLayer = function(objRef, layerName) {
90
91
    objRef.stylesheet.setParameter("selectedLayer",layerName);
92
93
    var newContext = objRef.stylesheet.transformNodeToObject(objRef.model.doc);
94
95
    objRef.targetModel.setParam("newModel", null);
96
97
    objRef.targetModel.url = '';
98
99
    objRef.targetModel.doc = newContext;
100
101
    objRef.targetModel.finishLoading();
102
103
  }
104
105
  this.model.addListener("mapLayer", this.mapSingleLayer, this);
106
107
108
109
}