Project

General

Profile

1
/*
2
Author:   
3
License:      LGPL as per: http://www.gnu.org/copyleft/lesser.html
4

    
5
$Id: Caps2Context.js 3881 2008-02-27 15:41:07Z gjvoosten $
6
*/
7

    
8
// Ensure this object's dependancies are loaded.
9
mapbuilder.loadScript(baseDir+"/tool/ToolBase.js");
10

    
11
/**
12

    
13
 * Build a Web Map Context (WMC) from a Web Map Server getCapabilities response.
14

    
15
 * This tool will replace the identified targetModel as opposed to editing
16

    
17
 * the target model which the EditContext tool will do. 
18

    
19
 * @constructor
20

    
21
 * @base ToolBase
22

    
23
 * @param toolNode The tools's XML object node from the configuration document.
24

    
25
 * @param model    The model that this tool belongs to
26

    
27
 */
28

    
29
function Caps2Context(toolNode, model) {
30

    
31
  ToolBase.apply(this, new Array(toolNode, model));
32

    
33
  
34

    
35
  var styleUrl = baseDir+"/tool/xsl/Caps2Context.xsl";
36

    
37
  this.stylesheet = new XslProcessor(styleUrl,model.namespace);
38

    
39

    
40

    
41
  // Set stylesheet parameters for all the child nodes from the config file
42

    
43
  for (var j=0;j<toolNode.childNodes.length;j++) {
44

    
45
    if (getNodeValue(toolNode.childNodes[j])) {
46

    
47
      this.stylesheet.setParameter(toolNode.childNodes[j].nodeName,getNodeValue(toolNode.childNodes[j]));
48

    
49
    }
50

    
51
  }
52

    
53

    
54

    
55
  /**
56

    
57
   * Listener function which does the transformation and loads the target model
58

    
59
   * @param requestName the name of the web service operation to execute
60

    
61
   * @param featureNodeId the id of the node in the doc to be processed by the stylesheet
62

    
63
   */
64

    
65
  this.mapAllLayers = function(objRef) {
66

    
67
    objRef.stylesheet.setParameter("selectedLayer",'');
68

    
69
    var newContext = objRef.stylesheet.transformNodeToObject(objRef.model.doc);
70

    
71
    objRef.targetModel.setParam("newModel", null);
72

    
73
    objRef.targetModel.url = '';
74

    
75
    objRef.targetModel.doc = newContext;
76

    
77
    objRef.targetModel.finishLoading();
78

    
79
  }
80

    
81
  this.model.addListener("mapAllLayers", this.mapAllLayers, this);
82

    
83

    
84

    
85
  /**
86

    
87
   * Listener function which does the transformation and loads the target model.
88

    
89
   * this wersion will convert a single layer from the Capabilities doc into a
90

    
91
   * context doc.
92

    
93
   * @param requestName the name of the web service operation to execute
94

    
95
   * @param featureNodeId the id of the node in the doc to be processed by the stylesheet
96

    
97
   */
98

    
99
  this.mapSingleLayer = function(objRef, layerName) {
100

    
101
    objRef.stylesheet.setParameter("selectedLayer",layerName);
102

    
103
    var newContext = objRef.stylesheet.transformNodeToObject(objRef.model.doc);
104

    
105
    objRef.targetModel.setParam("newModel", null);
106

    
107
    objRef.targetModel.url = '';
108

    
109
    objRef.targetModel.doc = newContext;
110

    
111
    objRef.targetModel.finishLoading();
112

    
113
  }
114

    
115
  this.model.addListener("mapLayer", this.mapSingleLayer, this);
116

    
117

    
118

    
119
}
120

    
(2-2/15)