Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/GeoExt/lib/GeoExt/data/WMSDescribeLayerReader.js @ 76

Revision 76, 3.2 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/**
2 * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
3 *
4 * Published under the BSD license.
5 * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
6 * of the license.
7 */
8
9/** api: (define)
10 *  module = GeoExt.data
11 *  class = WMSDescribeLayerReader
12 *  base_link = `Ext.data.DataReader <http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.DataReader>`_
13 */
14Ext.namespace("GeoExt.data");
15
16/** api: constructor
17 *  .. class:: WMSDescribeLayerReader(meta, recordType)
18 * 
19 *      :param meta: ``Object`` Reader configuration.
20 *      :param recordType: ``Array | Ext.data.Record`` An array of field
21 *          configuration objects or a record object.  Default has
22 *          fields for owsType, owsURL, and typeName.
23 *   
24 *      Data reader class to create an array of
25 *      layer description objects from a WMS DescribeLayer
26 *      response.
27 */
28GeoExt.data.WMSDescribeLayerReader = function(meta, recordType) {
29    meta = meta || {};
30    if(!meta.format) {
31        meta.format = new OpenLayers.Format.WMSDescribeLayer();
32    }
33    if(!(typeof recordType === "function")) {
34        recordType = Ext.data.Record.create(
35            recordType || meta.fields || [
36                {name: "owsType", type: "string"},
37                {name: "owsURL", type: "string"},
38                {name: "typeName", type: "string"}
39            ]
40        );
41    }
42    GeoExt.data.WMSDescribeLayerReader.superclass.constructor.call(
43        this, meta, recordType
44    );
45};
46
47Ext.extend(GeoExt.data.WMSDescribeLayerReader, Ext.data.DataReader, {
48
49    /** private: method[read]
50     *  :param request: ``Object`` The XHR object which contains the parsed XML
51     *      document.
52     *  :return: ``Object`` A data block which is used by an ``Ext.data.Store``
53     *      as a cache of ``Ext.data.Record`` objects.
54     */
55    read: function(request) {
56        var data = request.responseXML;
57        if(!data || !data.documentElement) {
58            data = request.responseText;
59        }
60        return this.readRecords(data);
61    },
62
63    /** private: method[readRecords]
64     *  :param data: ``DOMElement | Strint | Object`` A document element or XHR
65     *      response string.  As an alternative to fetching layer description data
66     *      from a remote source, an object representing the layer descriptions can
67     *      be provided given that the structure mirrors that returned from the
68     *      layer description parser.
69     *  :return: ``Object`` A data block which is used by an ``Ext.data.Store``
70     *      as a cache of ``Ext.data.Record`` objects.
71     * 
72     *  Create a data block containing Ext.data.Records from an XML document.
73     */
74    readRecords: function(data) {
75       
76        if(typeof data === "string" || data.nodeType) {
77            data = this.meta.format.read(data);
78        }
79        var records = [], description;       
80        for(var i=0, len=data.length; i<len; i++){
81            description = data[i];
82            if(description) {
83                records.push(new this.recordType(description));
84            }
85        }
86
87        return {
88            totalRecords: records.length,
89            success: true,
90            records: records
91        };
92
93    }
94});
Note: See TracBrowser for help on using the repository browser.