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

Revision 76, 2.9 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 = LayerRecord
12 *  base_link = `Ext.data.Record <http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Record>`_
13 */
14Ext.namespace("GeoExt.data");
15
16/** api: constructor
17 *  .. class:: LayerRecord
18 * 
19 *      A record that represents an ``OpenLayers.Layer``. This record
20 *      will always have at least the following fields:
21 *
22 *      * title ``String``
23 */
24GeoExt.data.LayerRecord = Ext.data.Record.create([
25    {name: "layer"},
26    {name: "title", type: "string", mapping: "name"}
27]);
28
29/** api: method[getLayer]
30 *  :return: ``OpenLayers.Layer``
31 *
32 *  Gets the layer for this record.
33 */
34GeoExt.data.LayerRecord.prototype.getLayer = function() {
35    return this.get("layer");
36};
37
38/** api: method[setLayer]
39 *  :param layer: ``OpenLayers.Layer``
40 *
41 *  Sets the layer for this record.
42 */
43GeoExt.data.LayerRecord.prototype.setLayer = function(layer) {
44    if (layer !== this.data.layer) {
45        this.dirty = true;
46        if(!this.modified) {
47            this.modified = {};
48        }
49        if(this.modified.layer === undefined) {
50            this.modified.layer = this.data.layer;
51        }
52        this.data.layer = layer;
53        if(!this.editing) {
54            this.afterEdit();
55        }
56    }
57};
58
59/** api: method[clone]
60 *  :param id: ``String`` (optional) A new Record id.
61 *  :return: class:`GeoExt.data.LayerRecord` A new layer record.
62 * 
63 *  Creates a clone of this LayerRecord.
64 */
65GeoExt.data.LayerRecord.prototype.clone = function(id) { 
66    var layer = this.getLayer() && this.getLayer().clone(); 
67    return new this.constructor( 
68        Ext.applyIf({layer: layer}, this.data), 
69        id || layer.id
70    );
71}; 
72
73/** api: classmethod[create]
74 *  :param o: ``Array`` Field definition as in ``Ext.data.Record.create``. Can
75 *      be omitted if no additional fields are required.
76 *  :return: ``Function`` A specialized :class:`GeoExt.data.LayerRecord`
77 *      constructor.
78 * 
79 *  Creates a constructor for a :class:`GeoExt.data.LayerRecord`, optionally
80 *  with additional fields.
81 */
82GeoExt.data.LayerRecord.create = function(o) {
83    var f = Ext.extend(GeoExt.data.LayerRecord, {});
84    var p = f.prototype;
85
86    p.fields = new Ext.util.MixedCollection(false, function(field) {
87        return field.name;
88    });
89
90    GeoExt.data.LayerRecord.prototype.fields.each(function(f) {
91        p.fields.add(f);
92    });
93
94    if(o) {
95        for(var i = 0, len = o.length; i < len; i++){
96            p.fields.add(new Ext.data.Field(o[i]));
97        }
98    }
99
100    f.getField = function(name) {
101        return p.fields.get(name);
102    };
103
104    return f;
105};
Note: See TracBrowser for help on using the repository browser.