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/SLD.js @ 76

Revision 76, 3.9 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/XML.js
8 * @requires OpenLayers/Style.js
9 * @requires OpenLayers/Rule.js
10 * @requires OpenLayers/Filter/FeatureId.js
11 * @requires OpenLayers/Filter/Logical.js
12 * @requires OpenLayers/Filter/Comparison.js
13 * @requires OpenLayers/Filter/Spatial.js
14 */
15
16/**
17 * Class: OpenLayers.Format.SLD
18 * Read/Wite SLD. Create a new instance with the <OpenLayers.Format.SLD>
19 *     constructor.
20 *
21 * Inherits from:
22 *  - <OpenLayers.Format.XML>
23 */
24OpenLayers.Format.SLD = OpenLayers.Class(OpenLayers.Format.XML, {
25   
26    /**
27     * APIProperty: defaultVersion
28     * {String} Version number to assume if none found.  Default is "1.0.0".
29     */
30    defaultVersion: "1.0.0",
31   
32    /**
33     * APIProperty: version
34     * {String} Specify a version string if one is known.
35     */
36    version: null,
37   
38    /**
39     * APIProperty: namedLayersAsArray
40     * {Boolean} Generate a namedLayers array.  If false, the namedLayers
41     *     property value will be an object keyed by layer name. Default is
42     *     false.
43     */
44    namedLayersAsArray: false,
45   
46    /**
47     * Property: parser
48     * {Object} Instance of the versioned parser.  Cached for multiple read and
49     *     write calls of the same version.
50     */
51    parser: null,
52
53    /**
54     * Constructor: OpenLayers.Format.SLD
55     * Create a new parser for SLD.
56     *
57     * Parameters:
58     * options - {Object} An optional object whose properties will be set on
59     *     this instance.
60     */
61    initialize: function(options) {
62        OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
63    },
64
65    /**
66     * APIMethod: write
67     * Write a SLD document given a list of styles.
68     *
69     * Parameters:
70     * sld - {Object} An object representing the SLD.
71     * options - {Object} Optional configuration object.
72     *
73     * Returns:
74     * {String} An SLD document string.
75     */
76    write: function(sld, options) {
77        var version = (options && options.version) ||
78                      this.version || this.defaultVersion;
79        if(!this.parser || this.parser.VERSION != version) {
80            var format = OpenLayers.Format.SLD[
81                "v" + version.replace(/\./g, "_")
82            ];
83            if(!format) {
84                throw "Can't find a SLD parser for version " +
85                      version;
86            }
87            this.parser = new format(this.options);
88        }
89        var root = this.parser.write(sld);
90        return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
91    },
92   
93    /**
94     * APIMethod: read
95     * Read and SLD doc and return an object representing the SLD.
96     *
97     * Parameters:
98     * data - {String | DOMElement} Data to read.
99     * options - {Object} Options for the reader.
100     *
101     * Returns:
102     * {Object} An object representing the SLD.
103     */
104    read: function(data, options) {
105        if(typeof data == "string") {
106            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
107        }
108        var root = data.documentElement;
109        var version = this.version;
110        if(!version) {
111            version = root.getAttribute("version");
112            if(!version) {
113                version = this.defaultVersion;
114            }
115        }
116        if(!this.parser || this.parser.VERSION != version) {
117            var format = OpenLayers.Format.SLD[
118                "v" + version.replace(/\./g, "_")
119            ];
120            if(!format) {
121                throw "Can't find a SLD parser for version " +
122                      version;
123            }
124            this.parser = new format(this.options);
125        }
126        var sld = this.parser.read(data, options);
127        return sld;
128    },
129
130    CLASS_NAME: "OpenLayers.Format.SLD" 
131});
Note: See TracBrowser for help on using the repository browser.