Project

General

Profile

1
/*
2
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
3
Dependancies: Context
4
$Id$
5
*/
6

    
7
// Ensure this object's dependancies are loaded.
8
mapbuilder.loadScript(baseDir+"/tool/ButtonBase.js");
9
/**
10
 * Builds then sends a WFS GetFeature GET request based on the WMC
11
 * coordinates and click point.
12
 * @constructor
13
 * @base ButtonBase
14
 * @author Cameron Shorter
15
 * @param widgetNode The XML node in the Config file referencing this object.
16
 * @param model The Context object which this tool is associated with.
17
 */
18
function WfsGetFeature(widgetNode, model) {
19
  // Extend ButtonBase
20
  ButtonBase.apply(this, new Array(widgetNode, model));
21
  this.tolerance= widgetNode.selectSingleNode('mb:tolerance').firstChild.nodeValue;
22
  this.typeName= widgetNode.selectSingleNode('mb:typeName').firstChild.nodeValue;
23
  this.webServiceUrl= widgetNode.selectSingleNode('mb:webServiceUrl').firstChild.nodeValue;
24
  this.httpPayload=new Object();
25
  this.httpPayload.method="get";
26
  this.httpPayload.postData=null;
27
  this.trm=widgetNode.selectSingleNode("mb:transactionResponseModel").firstChild.nodeValue;
28

    
29
  // override default cursor by user
30
  // cursor can be changed by spefying a new cursor in config file
31
  this.cursor = "pointer"; 
32

    
33
  /**
34
   * Open window with query info.
35
   * This function is called when user clicks map with Query tool.
36
   * @param objRef      Pointer to this GetFeatureInfo object.
37
   * @param targetNode  The node for the enclosing HTML tag for this widget.
38
   */
39
  this.doAction = function(objRef,targetNode) {
40
    if (objRef.enabled) {
41
      extent=objRef.targetModel.extent;
42
      point=extent.getXY(targetNode.evpl);
43
      xPixel=extent.res[0]*objRef.tolerance;
44
      yPixel=extent.res[1]*objRef.tolerance;
45
      bbox=(point[0]-xPixel)+","+(point[1]-yPixel)+","+(point[0]+xPixel)+","+(point[1]+yPixel);
46
      objRef.httpPayload.url=objRef.webServiceUrl+"?request=GetFeature&typeName="+objRef.typeName+"&bbox="+bbox;
47

    
48
      // Model that will be populated with the WFS response.
49
      if (!objRef.transactionResponseModel){
50
        objRef.transactionResponseModel=eval("config.objects."+objRef.trm);
51
        //objRef.transactionResponseModel.addListener("loadModel",objRef.handleResponse, objRef);
52
      }
53
      objRef.transactionResponseModel.newRequest(objRef.transactionResponseModel,objRef.httpPayload);
54
    }
55
  }
56
  
57

    
58
  /**
59
   * Register for mouseUp events.
60
   * @param objRef  Pointer to this object.
61
   */
62
  this.setMouseListener = function(objRef) {
63
    if (objRef.mouseHandler) {
64
      objRef.mouseHandler.model.addListener('mouseup',objRef.doAction,objRef);
65
    }
66
    objRef.context=objRef.widgetNode.selectSingleNode("mb:context");
67
    if (objRef.context){
68
      objRef.context=eval("config.objects."+objRef.context.firstChild.nodeValue);
69
    }
70
  }
71
  config.addListener( "loadModel", this.setMouseListener, this );
72
}
(98-98/111)