Changeset 10248


Ignore:
Timestamp:
Apr 22, 2010 12:57:54 AM (6 years ago)
Author:
bartvde
Message:

use enumeration constant for serviceType

Location:
sandbox/bartvde/owc/openlayers/lib/OpenLayers/Format
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/bartvde/owc/openlayers/lib/OpenLayers/Format/Context.js

    r10241 r10248  
    176176
    177177        var layer = null;
    178         if (layerContext.service == 'urn:ogc:serviceType:WFS') {
     178        var service = layerContext.service;
     179        if (service == OpenLayers.Format.Context.serviceTypes.WFS) {
    179180            options.strategies = [new OpenLayers.Strategy.BBOX()];
    180181            options.protocol = new OpenLayers.Protocol.WFS({
     
    189190                options
    190191            );
    191         } else if (layerContext.service == 'urn:ogc:serviceType:KML') {
     192        } else if (service == OpenLayers.Format.Context.serviceTypes.KML) {
    192193            // use a vector layer with an HTTP Protcol and a Fixed strategy
    193194            options.strategies = [new OpenLayers.Strategy.Fixed()];
     
    200201                options
    201202            );
    202         } else if (layerContext.service == 'urn:ogc:serviceType:GML') {
     203        } else if (service == OpenLayers.Format.Context.serviceTypes.GML) {
    203204            // use a vector layer with a HTTP Protocol and a Fixed strategy
    204205            options.strategies = [new OpenLayers.Strategy.Fixed()];
     
    312313    CLASS_NAME: "OpenLayers.Format.Context"
    313314});
     315
     316/**
     317 * Constant: OpenLayers.Format.Context.serviceTypes
     318 * Enumeration for service types
     319 */
     320OpenLayers.Format.Context.serviceTypes = {
     321    "WMS": "urn:ogc:serviceType:WMS",
     322    "WFS": "urn:ogc:serviceType:WFS",
     323    "WCS": "urn:ogc:serviceType:WCS",
     324    "GML": "urn:ogc:serviceType:GML",
     325    "SLD": "urn:ogc:serviceType:SLD",
     326    "FES": "urn:ogc:serviceType:FES",
     327    "KML": "urn:ogc:serviceType:KML"
     328};
  • sandbox/bartvde/owc/openlayers/lib/OpenLayers/Format/OWSContext/v0_3_1.js

    r10247 r10248  
    100100    /**
    101101     * Property: nestingLayerLookup
    102      * {Object} Hashtable lookup for nesting layer nodes. Used while writing the OWS context document.
    103      * It is necessary to keep track of the nestingPaths for which nesting layer nodes are already created,
    104      * so nesting layer nodes and layer nodes are added to these nodes.
     102     * {Object} Hashtable lookup for nesting layer nodes. Used while writing
     103     *     the OWS context document. It is necessary to keep track of the
     104     *     nestingPaths for which nesting layer nodes have already been
     105     *     created, so (nesting) layer nodes are added to those nodes.
    105106     *
    106107     * For example:
    107      * If there are three layers with nestingPaths:
    108      *  layer1.metadata.nestingPath = "a/b/"
    109      *  layer2.metadata.nestingPath = "a/b/"
    110      *  layer2.metadata.nestingPath = "a/c"
    111      * then a nesting layer node "a" should be created once and added to the resource list, a nesting layer
    112      * node "b" should be created once and added under "a", and a nesting layer node "c" should be created
    113      * and added under "a". The lookup paths for these nodes will be "a", "a/b", and "a/c" respectively.
    114      */
    115     nestingLayerLookup : null,
     108     *
     109     *     If there are three layers with nestingPaths:
     110     *         layer1.metadata.nestingPath = "a/b/"
     111     *         layer2.metadata.nestingPath = "a/b/"
     112     *         layer2.metadata.nestingPath = "a/c"
     113     *
     114     *     then a nesting layer node "a" should be created once and added
     115     *     to the resource list, a nesting layer node "b" should be created
     116     *     once and added under "a", and a nesting layer node "c" should be
     117     *     created and added under "a". The lookup paths for these nodes
     118     *     will be "a", "a/b", and "a/c" respectively.
     119     */
     120    nestingLayerLookup: null,
    116121
    117122    /**
     
    130135
    131136    /**
     137     * Method: setNestingPath
     138     * Set the nestingPath property of the layer depending on the position
     139     *     of the layer in hierarchy of layers.
     140     *
    132141     * Parameters:
    133      * l - {Object} that may have a layersContext array property.
     142     * l - {Object} An object that may have a layersContext array property.
    134143     *
    135144     */
    136145    setNestingPath : function(l){
    137146        if(l.layersContext){
    138             for (var i = 0, max = l.layersContext.length; i < max; i++) {
     147            for (var i = 0, len = l.layersContext.length; i < len; i++) {
    139148                var layerContext = l.layersContext[i];
    140149                var nPath = "";
     
    157166
    158167    /**
    159      * Method: decomposeNestingPath
     168     * Function: decomposeNestingPath
    160169     * Takes a nestingPath like "a/b/c" and decomposes it into subpaths:
    161170     * "a", "a/b", "a/b/c"
    162171     *
     172     * Parameters:
     173     * nPath  - {String} the nesting path
     174     *
    163175     * Returns:
    164      * Array({String}) Array with subpaths, or emty array if there is nothing to decompose
     176     * Array({String}) Array with subpaths, or empty array if there is nothing
     177     *     to decompose
    165178     */
    166179    decomposeNestingPath: function(nPath){
    167180        var a = [];
    168         if(nPath){
     181        if (nPath) {
    169182            //try to ensure a clean nPath
    170183            nPath = nPath.replace(/^\s+/,"").replace(/\s+$/,"")
    171             if(nPath[0] === "/"){nPath = nPath.substr(1);}
     184            if (nPath[0] === "/") {
     185                nPath = nPath.substr(1);
     186            }
    172187            var len = nPath.length;
    173             if(nPath[len - 1] === "/"){nPath = nPath.substring(0, len - 1)}
     188            if (nPath[len - 1] === "/") {
     189                nPath = nPath.substring(0, len - 1);
     190            }
    174191            //decompose
    175192            a[0] = nPath;
     
    186203
    187204    /**
    188      * Method: read
    189      * Read OWS context data from a string, and return a list of layers.
     205     * APIMethod: read
     206     * Read OWS context data from a string or DOMElement, and return a list
     207     *     of layers.
    190208     *
    191209     * Parameters:
     
    193211     *
    194212     * Returns:
    195      * {Array} List of named layers.
     213     * {Object} The context object with a flat layer list as a property named
     214     *     layersContext.
    196215     */
    197216    read: function(data) {
     
    207226        // structure recursively     
    208227        this.setNestingPath({layersContext : context.layersContext});
    209         // after nesting path has been set, create a flat list
     228        // after nesting path has been set, create a flat list of layers
    210229        var layers = [];
    211230        this.processLayer(layers, context);
     
    237256
    238257    /**
    239      * Method: write
     258     * APIMethod: write
    240259     *
    241260     * Parameters:
     
    291310                    visibility: (node.getAttribute("hidden") != "1"),
    292311                    queryable: (node.getAttribute("queryable") == "1"),
    293                     opacity: ((node.getAttribute("opacity") != null) ? parseFloat(node.getAttribute("opacity")) : null),
     312                    opacity: ((node.getAttribute("opacity") != null) ?
     313                        parseFloat(node.getAttribute("opacity")) : null),
    294314                    name: node.getAttribute("name"),
    295315                    formats: [],
     
    322342                // when having multiple Server types, we prefer WMS
    323343                if ((!obj.service && !obj.version) ||
    324                     (obj.service != 'urn:ogc:serviceType:WMS')) {
    325                         obj.service = node.getAttribute("service");
    326                         obj.version = node.getAttribute("version");
    327                         this.readChildNodes(node, obj);
     344                    (obj.service !=
     345                        OpenLayers.Format.Context.serviceTypes.WMS)) {
     346                            obj.service = node.getAttribute("service");
     347                            obj.version = node.getAttribute("version");
     348                            this.readChildNodes(node, obj);
    328349                }
    329350            },
     
    503524                this.writeNode("ows:Title", layer.name, node);
    504525                this.writeNode("ows:OutputFormat", layer.params.FORMAT, node);
    505                 this.writeNode("Server", {service: 'urn:ogc:serviceType:WMS',
     526                this.writeNode("Server", {service:
     527                    OpenLayers.Format.Context.serviceTypes.WMS,
    506528                    version: layer.params.VERSION, url: layer.url}, node);
    507529                if (layer.metadata.styles && layer.metadata.styles.length > 0) {
     
    565587                });
    566588                this.writeNode("ows:Title", layer.name, node);
    567                 this.writeNode("Server", {service: 'urn:ogc:serviceType:WFS',
     589                this.writeNode("Server", {service:
     590                    OpenLayers.Format.Context.serviceTypes.WFS,
    568591                    version: layer.protocol.version,
    569592                    url: layer.protocol.url}, node);
     
    583606                var node = this.createElementNSPlus("Layer");
    584607                this.writeNode("ows:Title", layer.name, node);
    585                 this.writeNode("Server", {service: 'urn:ogc:serviceType:GML',
    586                   url: layer.protocol.url, version: layer.protocol.format.version}, node);
     608                this.writeNode("Server", {service:
     609                    OpenLayers.Format.Context.serviceTypes.GML,
     610                    url: layer.protocol.url, version:
     611                    layer.protocol.format.version}, node);
    587612                this.writeLayerScaleInfo(layer.options, node);
    588613                return node;
     
    591616                var node = this.createElementNSPlus("Layer");
    592617                this.writeNode("ows:Title", layer.name, node);
    593                 // TODO: Format.KML should advertize its version
    594                 this.writeNode("Server", {service: 'urn:ogc:serviceType:KML',
    595                     version: layer.protocol.format.version, url: layer.protocol.url}, node);
     618                this.writeNode("Server", {service:
     619                    OpenLayers.Format.Context.serviceTypes.KML,
     620                    version: layer.protocol.format.version, url:
     621                    layer.protocol.url}, node);
    596622                this.writeLayerScaleInfo(layer.options, node);
    597623                return node;
Note: See TracChangeset for help on using the changeset viewer.