Project

General

Profile

1
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
2
<html>
3
<head>
4
<title>
5
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
6
</title>
7
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
8
<script>
9
function asd() {
10
	
11
		parent.document.title="FeatureCollection.js Overview";
12
	
13
}
14
</script>
15
</head>
16
<body bgcolor="white" onload="asd();">
17

    
18
<!-- ========== START OF NAVBAR ========== -->
19
<a name="navbar_top"><!-- --></a>
20
<table border="0" width="100%" cellpadding="1" cellspacing="0">
21
<tr>
22
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
23
<a name="navbar_top_firstrow"><!-- --></a>
24
<table border="0" cellpadding="0" cellspacing="3">
25
  <tr align="center" valign="top">
26
  
27
  
28
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
29
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
30
  
31

    
32
  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
33
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
34
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
35
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
36
  </tr>
37
</table>
38
</td>
39
<td bgcolor="#EEEEFF" align="right" valign="top">
40
<em>
41
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
42
</td>
43
</tr>
44

    
45
<tr>
46
<td bgcolor="white" class="NavBarCell2"><font size="-2">
47
&nbsp;PREV&nbsp;
48
&nbsp;NEXT</font></td>
49
<td bgcolor="white" class="NavBarCell2"><font size="-2">
50
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
51
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
52
&nbsp;&nbsp;
53
<script>
54
  <!--
55
  if(window==top) {
56
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
57
  }
58
  //-->
59
</script>
60
<noscript>
61
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
62
</noscript>
63
</font></td>
64
</tr>
65
</table>
66
<!-- =========== END OF NAVBAR =========== -->
67

    
68
<hr>
69
<center>
70
	
71
	   <h2>FeatureCollection.js</h2>
72
	
73
</center>
74

    
75
	
76

    
77

    
78
<h4>Summary</h4>
79
<p>
80
	
81
		No overview generated for 'FeatureCollection.js'<BR/><BR/>
82
	
83
</p>
84

    
85
<hr>
86

    
87

    
88
    <table border="1" cellpadding="3" cellspacing="0" width="100%">
89
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
90
    <td colspan=2><font size="+2">
91
    
92
        <b>Class Summary</b>
93
    
94
    </font></td>
95
    </tr>
96
    
97
    <tr bgcolor="white" class="TableRowColor">
98
    <td width="15%"><b><a href="FeatureCollection.html">FeatureCollection</a></b></td>
99
    <td>&nbsp;</td>
100
    </tr>
101
    
102
    </table>
103
    <hr/> 
104

    
105

    
106
<!-- ========== METHOD SUMMARY =========== -->
107

    
108
<!-- ========== END METHOD SUMMARY =========== -->
109

    
110

    
111
        <pre class="sourceview"><span class="comment">/*
112
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
113
$Id: FeatureCollection.js 3882 2008-02-27 15:41:33Z gjvoosten $
114
*/</span>
115
<span class="comment">
116
// Ensure this object's dependancies are loaded.</span>
117
mapbuilder.loadScript(baseDir+<span class="literal">"/model/ModelBase.js"</span>);
118

    
119
<span class="comment">/**
120
 * Stores a GML Feature or FeatureCollection as defined by the
121
 * Open Geospatial Consortium (http://www.opengeospatial.org/).
122
 *
123
 * <span class="attrib">@constructor</span>
124
 * <span class="attrib">@base</span> ModelBase
125
 * <span class="attrib">@author</span> Cameron Shorter
126
 * <span class="attrib">@requires</span> Sarissa
127
 * <span class="attrib">@param</span> modelNode The model's XML object node from the configuration document.
128
 * <span class="attrib">@param</span> parent    The parent model for the object.
129
  */</span>
130
<span class="reserved">function</span> FeatureCollection(modelNode, parent) {
131
<span class="comment">  // Inherit the ModelBase functions and parameters</span>
132
  ModelBase.apply(<span class="reserved">this</span>, new Array(modelNode, parent));
133

    
134
  <span class="reserved">this</span>.featureTagName = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:featureTagName"</span>, <span class="literal">"topp:CITY_NAME"</span>);
135
  <span class="reserved">this</span>.coordsTagName = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:coordsTagName"</span>, <span class="literal">"//gml:coordinates"</span>);
136
  <span class="reserved">this</span>.nodeSelectXpath = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:nodeSelectXpath"</span>);
137
  <span class="reserved">this</span>.coordSelectXpath = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:coordSelectXpath"</span>, <span class="literal">"topp:the_geom/gml:MultiPoint/gml:pointMember/gml:Point/gml:coordinates"</span>);
138
<span class="comment">
139
  // Namespace to use when doing Xpath queries, usually set in config file.</span>
140
<span class="comment">  //if (!this.namespace){</span>
141
<span class="comment">  //  this.namespace = "xmlns:gml='http://www.opengis.net/gml' xmlns:wfs='http://www.opengis.net/wfs'";</span>
142
<span class="comment">  //}</span>
143

    
144
  <span class="comment">/**
145
   * convert coordinates in the GML document to the SRS of the map container, 
146
   * if required.  The coordinate values are replaced in the GML document.
147
   * <span class="attrib">@param</span> objRef Pointer to this object.
148
   */</span>
149
  <span class="reserved">this</span>.convertCoords = <span class="reserved">function</span>(objRef) {
150
  
151
    <span class="reserved">if</span>( objRef.doc &amp;&amp; objRef.containerModel &amp;&amp; objRef.containerModel.doc ) {
152
		  var coordNodes = objRef.doc.selectNodes( objRef.coordsTagName );
153
		  <span class="reserved">if</span> (coordNodes.length&gt;0 &amp;&amp; objRef.containerModel) {
154
		    var srsNode = coordNodes[0].selectSingleNode(<span class="literal">"ancestor-or-self::*/@srsName"</span>);
155
		    <span class="reserved">if</span>( srsNode &amp;&amp; (srsNode.nodeValue.toUpperCase() != objRef.containerModel.getSRS().toUpperCase()) ) {
156
		      var sourceProj = new OpenLayers.Projection(srsNode.nodeValue);
157
		      objRef.setParam(<span class="literal">"modelStatus"</span>,mbGetMessage(<span class="literal">"convertingCoords"</span>));
158
		      var containerProj = new OpenLayers.Projection(objRef.containerModel.getSRS());
159
		      <span class="reserved">for</span> (var i=0; i&lt;coordNodes.length; ++i) {
160
		        var coords = getNodeValue(coordNodes[i]);
161
		        var coordsArray = coords.split(<span class="literal">' '</span>);
162
		        var newCoords = <span class="literal">''</span>;
163
		        <span class="reserved">for</span> (var j=0; j&lt;coordsArray.length; ++j) {
164
		          var xy = coordsArray[j].split(<span class="literal">','</span>);
165
		          <span class="reserved">if</span> (xy.length==2) {
166
		            var pt=new OpenLayers.Geometry.Point(xy[0],xy[1]);
167
                pt.transform(sourceProj,containerProj);
168
		            newCoords += pt.x + <span class="literal">','</span> + pt.y + <span class="literal">' '</span>;
169
		          }
170
		        }
171
		        coordNodes[i].firstChild.nodeValue=newCoords;
172
		      }
173
		    }
174
      }
175
    }
176
  }
177
  
178
  <span class="comment">/**
179
    * Called when the OWSContext gets loaded
180
    */</span>
181
  <span class="reserved">this</span>.loadWfsRequests = <span class="reserved">function</span>(objRef) {
182
<span class="comment">    //alert( "FeatureCollection loadModel:"+(new XMLSerializer()).serializeToString(objRef.containerModel.doc))</span>
183
<span class="comment">    // we need to retrieve all the features</span>
184
    <span class="reserved">if</span>( objRef.containerModel.doc != null) {
185
<span class="comment">      //alert( "FeatureCollection loadModel:"+(new XMLSerializer()).serializeToString(objRef.containerModel.doc))</span>
186
      var featureTypes = objRef.containerModel.doc.selectNodes(<span class="literal">"/wmc:OWSContext/wmc:ResourceList/wmc:FeatureType"</span>);
187
      <span class="reserved">if</span>( featureTypes.length &gt; 0 ) {
188
        <span class="reserved">for</span>( var i=0; i&lt;featureTypes.length; i++) {
189
          var httpPayload = new Object();        
190
        
191
          var wfsFeature = featureTypes[i]
192
<span class="comment">          //alert( "feature:"+ (new XMLSerializer()).serializeToString(wfsFeature) )</span>
193
          
194
          var server = wfsFeature.selectSingleNode(<span class="literal">"wmc:Server"</span>)
195
<span class="comment">          //alert( "server:"+ (new XMLSerializer()).serializeToString(server) )</span>
196
          var onlineResource = server.selectSingleNode(<span class="literal">"wmc:OnlineResource"</span>)
197
<span class="comment">          //alert( "onlineResource:"+ (new XMLSerializer()).serializeToString(onlineResource) )</span>
198
          httpPayload.method = onlineResource.getAttribute(<span class="literal">"method"</span>)
199
          httpPayload.url = onlineResource.getAttribute(<span class="literal">"xlink:href"</span>)
200
<span class="comment">          //alert( "server:"+ httpPayload.method + " " + httpPayload.url )</span>
201
          
202
          var query = wfsFeature.selectSingleNode(<span class="literal">"wfs:GetFeature"</span>)
203
<span class="comment">          //alert( "query2:"+ (new XMLSerializer()).serializeToString( query ))</span>
204
          httpPayload.postData = (new XMLSerializer()).serializeToString( query )
205
<span class="comment">          
206
          // This does not work on IE for some reaso</span>
207
<span class="comment">          // wfsFeature.model = objRef;</span>
208
          objRef.wfsFeature = wfsFeature
209
          objRef.newRequest(objRef,httpPayload);
210
<span class="comment">
211
          //objRef.containerModel.setParam('addLayer', wfsFeature);</span>
212
<span class="comment">          //var sld = wfsFeature.selectSingleNode("wmc:StyleList")</span>
213
        }
214
      }
215
    }
216
  }
217
  
218
  <span class="reserved">this</span>.addFirstListener(<span class="literal">"loadModel"</span>,<span class="reserved">this</span>.convertCoords,<span class="reserved">this</span>);
219
  
220
  <span class="reserved">if</span>( <span class="reserved">this</span>.containerModel ) <span class="reserved">this</span>.containerModel.addListener(<span class="literal">"loadModel"</span>,<span class="reserved">this</span>.loadWfsRequests,<span class="reserved">this</span>);
221

    
222
  <span class="comment">/**
223
   * Change a feature's visibility.
224
   * <span class="attrib">@param</span> featureName The name of the feature to set the hidden value for
225
   * <span class="attrib">@param</span> hidden, 1=hidden, 0=not hidden.
226
   */</span>
227
  <span class="reserved">this</span>.setHidden=<span class="reserved">function</span>(featureName, hidden){
228
    <span class="reserved">this</span>.hidden = hidden;
229
    <span class="reserved">this</span>.callListeners(<span class="literal">"hidden"</span>, featureName);
230
  }
231

    
232
  <span class="comment">/**
233
   * Geta feature's visibility.
234
   * <span class="attrib">@param</span> featureName The name of the feature to set the hidden value for
235
   * <span class="attrib">@return</span> hidden value, true=hidden, false=not hidden.
236
   */</span>
237
  <span class="reserved">this</span>.getHidden=<span class="reserved">function</span>(layerName){
238
    <span class="reserved">return</span> <span class="reserved">this</span>.hidden;
239
  }
240
  <span class="reserved">this</span>.hidden = false;
241

    
242
  <span class="comment">/**
243
   * Returns the list of nodes selected by the nodeSelectpath.  These nodes
244
   * will be the individual feature members from the collection.
245
   * <span class="attrib">@return</span> list of nodes selected 
246
   */</span>
247
  <span class="reserved">this</span>.getFeatureNodes = <span class="reserved">function</span>() {
248
    <span class="reserved">return</span> <span class="reserved">this</span>.doc.selectNodes(<span class="reserved">this</span>.nodeSelectXpath);
249
  }
250

    
251
  <span class="comment">/**
252
   * Returns a label for a node in the feature list
253
   * <span class="attrib">@param</span> featureNode the feature node to selectfrom
254
   * <span class="attrib">@return</span> a label for this feature
255
   */</span>
256
  <span class="reserved">this</span>.getFeatureName = <span class="reserved">function</span>(featureNode) {
257
    var labelNode = featureNode.selectSingleNode(<span class="reserved">this</span>.featureTagName);   //TBD: set <span class="reserved">this</span> dynamically
258
    <span class="reserved">return</span> labelNode?getNodeValue(labelNode):mbGetMessage(<span class="literal">"noRssTitle"</span>);
259
  }
260

    
261
  <span class="comment">/**
262
   * Returns an ID value for a node in the feature list
263
   * <span class="attrib">@param</span> featureNode the feature node to selectfrom
264
   * <span class="attrib">@return</span> ID for this feature
265
   */</span>
266
  <span class="reserved">this</span>.getFeatureId = <span class="reserved">function</span>(featureNode) {
267
    <span class="reserved">return</span> featureNode.getAttribute(<span class="literal">"fid"</span>)?featureNode.getAttribute(<span class="literal">"fid"</span>):<span class="literal">"no_id"</span>;
268
  }
269

    
270
  <span class="comment">/**
271
   * Returns a point geometry for the feature
272
   * <span class="attrib">@param</span> featureNode the feature node to select from
273
   * <span class="attrib">@return</span> the geometric point for the node
274
   */</span>
275
  <span class="reserved">this</span>.getFeaturePoint = <span class="reserved">function</span>(featureNode) {
276
    var coords = featureNode.selectSingleNode(<span class="reserved">this</span>.coordSelectXpath);
277
    <span class="reserved">if</span> (coords) {
278
      var point = getNodeValue(coords).split(<span class="literal">','</span>);
279
      <span class="reserved">return</span> point
280
    } <span class="reserved">else</span> {
281
      <span class="reserved">return</span> new Array(0,0);  //or some other error to <span class="reserved">return</span>?
282
    }
283
  }
284
  
285
 <span class="comment">/**
286
   * Returns a GML geometry for the feature
287
   * <span class="attrib">@param</span> featureNode the feature node to select from
288
   * <span class="attrib">@return</span> the GML for the node
289
   */</span>
290
  <span class="reserved">this</span>.getFeatureGeometry = <span class="reserved">function</span>(featureNode) {
291
    var geometryTag = featureNode.selectSingleNode(<span class="reserved">this</span>.coordsTagName);
292
    <span class="reserved">if</span>( geometryTag != null )
293
      <span class="reserved">return</span> geometryTag.firstChild;
294
    <span class="reserved">else</span> {
295
      alert(mbGetMessage(<span class="literal">"invalidGeom"</span>, (new XMLSerializer()).serializeToString(featureNode)));
296
    }
297
  }
298
}
299
</pre>
300
	<hr>
301

    
302

    
303

    
304
<!-- ========== START OF NAVBAR ========== -->
305
<a name="navbar_top"><!-- --></a>
306
<table border="0" width="100%" cellpadding="1" cellspacing="0">
307
<tr>
308
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
309
<a name="navbar_top_firstrow"><!-- --></a>
310
<table border="0" cellpadding="0" cellspacing="3">
311
  <tr align="center" valign="top">
312
  
313
  
314
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
315
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
316
  
317

    
318
  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
319
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
320
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
321
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
322
  </tr>
323
</table>
324
</td>
325
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
326
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
327
</td>
328
</tr>
329

    
330
<tr>
331
<td bgcolor="white" class="NavBarCell2"><font size="-2">
332
&nbsp;PREV&nbsp;
333
&nbsp;NEXT</font></td>
334
<td bgcolor="white" class="NavBarCell2"><font size="-2">
335
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
336
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
337
&nbsp;&nbsp;
338
<script>
339
  <!--
340
  if(window==top) {
341
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
342
  }
343
  //-->
344
</script>
345
<noscript>
346
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
347
</noscript>
348
</font></td>
349
</tr>
350
</table>
351
<!-- =========== END OF NAVBAR =========== -->
352

    
353
<hr>
354
<font size="-1">
355

    
356
</font>
357
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
358
</body>
359
</html>
(235-235/316)