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/OpenLayers/lib/OpenLayers/Format/WMTSCapabilities/v1_0_0.js @ 76

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

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
2 * full list of contributors). Published under the Clear BSD license. 
3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
4 * full text of the license. */
5
6/**
7 * @requires OpenLayers/Format/WMTSCapabilities.js
8 * @requires OpenLayers/Format/OWSCommon/v1_1_0.js
9 */
10
11/**
12 * Class: OpenLayers.Format.WMTSCapabilities.v1_0_0
13 * Read WMTS Capabilities version 1.0.0.
14 *
15 * Inherits from:
16 *  - <OpenLayers.Format.WMTSCapabilities>
17 */
18OpenLayers.Format.WMTSCapabilities.v1_0_0 = OpenLayers.Class(
19    OpenLayers.Format.OWSCommon.v1_1_0, {
20       
21    /**
22     * Property: version
23     * {String} The parser version ("1.0.0").
24     */
25    version: "1.0.0",
26
27    /**
28     * Property: namespaces
29     * {Object} Mapping of namespace aliases to namespace URIs.
30     */
31    namespaces: {
32        ows: "http://www.opengis.net/ows/1.1",
33        wmts: "http://www.opengis.net/wmts/1.0",
34        xlink: "http://www.w3.org/1999/xlink"
35    },   
36   
37    /**
38     * Property: yx
39     * {Object} Members in the yx object are used to determine if a CRS URN
40     *     corresponds to a CRS with y,x axis order.  Member names are CRS URNs
41     *     and values are boolean.  Defaults come from the
42     *     <OpenLayers.Format.WMTSCapabilities> prototype.
43     */
44    yx: null,
45
46    /**
47     * Property: defaultPrefix
48     * {String} The default namespace alias for creating element nodes.
49     */
50    defaultPrefix: "wmts",
51
52    /**
53     * Constructor: OpenLayers.Format.WMTSCapabilities.v1_0_0
54     * Create a new parser for WMTS capabilities version 1.0.0.
55     *
56     * Parameters:
57     * options - {Object} An optional object whose properties will be set on
58     *     this instance.
59     */
60    initialize: function(options) {
61        OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
62        this.options = options;
63        var yx = OpenLayers.Util.extend(
64            {}, OpenLayers.Format.WMTSCapabilities.prototype.yx
65        );
66        this.yx = OpenLayers.Util.extend(yx, this.yx);
67    },
68
69    /**
70     * APIMethod: read
71     * Read capabilities data from a string, and return info about the WMTS.
72     *
73     * Parameters:
74     * data - {String} or {DOMElement} data to read/parse.
75     *
76     * Returns:
77     * {Object} Information about the SOS service.
78     */
79    read: function(data) {
80        if(typeof data == "string") {
81            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
82        }
83        if(data && data.nodeType == 9) {
84            data = data.documentElement;
85        }
86        var capabilities = {};
87        this.readNode(data, capabilities);
88        capabilities.version = this.version;
89        return capabilities;
90    },
91
92    /**
93     * Property: readers
94     * Contains public functions, grouped by namespace prefix, that will
95     *     be applied when a namespaced node is found matching the function
96     *     name.  The function will be applied in the scope of this parser
97     *     with two arguments: the node being read and a context object passed
98     *     from the parent.
99     */
100    readers: {       
101        "wmts": {
102            "Capabilities": function(node, obj) {
103                this.readChildNodes(node, obj);
104            },
105            "Contents": function(node, obj) {
106                obj.contents = {};               
107                obj.contents.layers = [];
108                obj.contents.tileMatrixSets = {};               
109                this.readChildNodes(node, obj.contents);
110            },
111            "Layer": function(node, obj) {
112                var layer = {
113                    styles: [],
114                    formats: [],
115                    tileMatrixSetLinks: []
116                };
117                layer.layers = [];
118                this.readChildNodes(node, layer);
119                obj.layers.push(layer);
120            },
121            "Style": function(node, obj) {
122                var style = {};
123                style.isDefault = (node.getAttribute("isDefault") === "true");
124                this.readChildNodes(node, style);
125                obj.styles.push(style);
126            },
127            "Format": function(node, obj) {
128                obj.formats.push(this.getChildValue(node)); 
129            },
130            "TileMatrixSetLink": function(node, obj) {
131                var tileMatrixSetLink = {};
132                this.readChildNodes(node, tileMatrixSetLink);
133                obj.tileMatrixSetLinks.push(tileMatrixSetLink);
134            },
135            "TileMatrixSet": function(node, obj) {
136                // node could be child of wmts:Contents or wmts:TileMatrixSetLink
137                // duck type wmts:Contents by looking for layers
138                if (obj.layers) {
139                    // TileMatrixSet as object type in schema
140                    var tileMatrixSet = {
141                        matrixIds: []
142                    };
143                    this.readChildNodes(node, tileMatrixSet);
144                    obj.tileMatrixSets[tileMatrixSet.identifier] = tileMatrixSet;
145                } else {
146                    // TileMatrixSet as string type in schema
147                    obj.tileMatrixSet = this.getChildValue(node);
148                }
149            },
150            "TileMatrix": function(node, obj) {
151                var tileMatrix = {
152                    supportedCRS: obj.supportedCRS
153                };
154                this.readChildNodes(node, tileMatrix);
155                obj.matrixIds.push(tileMatrix);
156            },
157            "ScaleDenominator": function(node, obj) {
158                obj.scaleDenominator = parseFloat(this.getChildValue(node)); 
159            },
160            "TopLeftCorner": function(node, obj) {               
161                var topLeftCorner = this.getChildValue(node);
162                var coords = topLeftCorner.split(" ");
163                // decide on axis order for the given CRS
164                var yx;
165                if (obj.supportedCRS) {
166                    // extract out version from URN
167                    var crs = obj.supportedCRS.replace(
168                        /urn:ogc:def:crs:(\w+):.+:(\w+)$/, 
169                        "urn:ogc:def:crs:$1::$2"
170                    );
171                    yx = !!this.yx[crs];
172                }
173                if (yx) {
174                    obj.topLeftCorner = new OpenLayers.LonLat(
175                        coords[1], coords[0]
176                    );
177                } else {
178                    obj.topLeftCorner = new OpenLayers.LonLat(
179                        coords[0], coords[1]
180                    );
181                }
182            },
183            "TileWidth": function(node, obj) {
184                obj.tileWidth = parseInt(this.getChildValue(node)); 
185            },
186            "TileHeight": function(node, obj) {
187                obj.tileHeight = parseInt(this.getChildValue(node)); 
188            },
189            "MatrixWidth": function(node, obj) {
190                obj.matrixWidth = parseInt(this.getChildValue(node)); 
191            },
192            "MatrixHeight": function(node, obj) {
193                obj.matrixHeight = parseInt(this.getChildValue(node)); 
194            },       
195            // not used for now, can be added in the future though
196            /*"Themes": function(node, obj) {
197                obj.themes = [];
198                this.readChildNodes(node, obj.themes);
199            },
200            "Theme": function(node, obj) {
201                var theme = {};               
202                this.readChildNodes(node, theme);
203                obj.push(theme);
204            },*/
205            "WSDL": function(node, obj) {
206                obj.wsdl = {};
207                obj.wsdl.href = node.getAttribute("xlink:href");
208                // TODO: other attributes of <WSDL> element               
209            },
210            "ServiceMetadataURL": function(node, obj) {
211                obj.serviceMetadataUrl = {};
212                obj.serviceMetadataUrl.href = node.getAttribute("xlink:href");
213                // TODO: other attributes of <ServiceMetadataURL> element               
214            }           
215        },
216        "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
217    },   
218   
219    CLASS_NAME: "OpenLayers.Format.WMTSCapabilities.v1_0_0" 
220
221});
Note: See TracBrowser for help on using the repository browser.