Project

General

Profile

1
/*
2
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
3
$Id: WfsCapabilities.js 3657 2007-11-29 09:04:26Z gjvoosten $
4
*/
5

    
6
// Ensure this object's dependancies are loaded.
7
mapbuilder.loadScript(baseDir+"/model/ModelBase.js");
8

    
9
/**
10
 * Stores a Web Feature (WFS) Capabilities document as defined by the 
11
 * Open Geospatial Consortium (http://www.opengeospatial.org/).
12
 *
13
 * @constructor
14
 * @base ModelBase
15
 * @author Mike Adair
16
 * @param modelNode   The model's XML object node from the configuration document.
17
 * @param parent The model object that this widget belongs to.
18
 */
19
function WfsCapabilities(modelNode, parent) {
20
  // Inherit the ModelBase functions and parameters
21
  ModelBase.apply(this, new Array(modelNode, parent));
22

    
23
  this.namespace = "xmlns:wfs='http://www.opengis.net/wfs'";
24

    
25
  /**
26
   * Returns the serverUrl for the WFS request passed in with the specified
27
   * HTTP method from the capabilities doc.
28
   * @param requestName the WFS request to get the URL for
29
   * @param method http method for the request
30
   * @param feature ignored for WFS docs
31
   * @return URL for the specified request with the specified method
32
   */
33
  this.getServerUrl = function(requestName, method, feature) {
34
    var xpath = "/wfs:WFS_Capabilities/wfs:Capability/wfs:Request/"+requestName;
35
    if (method.toLowerCase() == "post") {
36
      xpath += "/wfs:DCPType/wfs:HTTP/wfs:Post";
37
    } else {
38
      xpath += "/wfs:DCPType/wfs:HTTP/wfs:Get";
39
    }
40
    return this.doc.selectSingleNode(xpath).getAttribute("onlineResource");
41
  }
42

    
43
  /**
44
   * Returns the version for the WFS
45
   * @return the WFS version
46
   */
47
  this.getVersion = function() {
48
    var xpath = "/wfs:WFS_Capabilities";
49
    return this.doc.selectSingleNode(xpath).getAttribute("version");
50
  }
51

    
52
  /**
53
   * Get HTTP method used to retreive this model
54
   * @return the HTTP method 
55
   */
56
  this.getMethod = function() {
57
    return this.method;
58
  }
59

    
60
  /**
61
   * Returns the featureType node with the specified name from the list of nodes
62
   * selected by the nodeSelectXpath from the capabilities doc.
63
   * @param featureName name of the featureType to look up
64
   * @return the featureType node with the specified name.
65
   */
66
  this.getFeatureNode = function(featureName) {
67
    return this.doc.selectSingleNode(this.nodeSelectXpath+"[wfs:Name='"+featureName+"']");
68
  }
69

    
70
}
71

    
(16-16/19)