OpenLayers OpenLayers

Ticket #1543: ticket1543.patch

File ticket1543.patch, 6.3 kB (added by bartvde, 4 months ago)

patch implementing spatial filters and writing them in SLD

  • lib/OpenLayers/Filter/Spatial.js

    old new  
     1/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
     2 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the 
     3  * full text of the license. */ 
     4 
     5/** 
     6 * @requires OpenLayers/Filter.js 
     7 */ 
     8 
     9/** 
     10 * Class: OpenLayers.Filter.Spatial 
     11 * This class represents a spatial filter. 
     12 * Currently implemented: BBOX, DWithin and Intersects 
     13 *  
     14 * Inherits from 
     15 * - <OpenLayers.Filter> 
     16 */ 
     17OpenLayers.Filter.Spatial = OpenLayers.Class(OpenLayers.Filter, { 
     18 
     19    /** 
     20     * APIProperty: type 
     21     * {String} type: type of spatial filter. This is one of 
     22     * - OpenLayers.Filter.Spatial.BBOX                 = "BBOX"; 
     23     * - OpenLayers.Filter.Spatial.INTERSECTS             = "INTERSECTS"; 
     24     * - OpenLayers.Filter.Spatial.DWITHIN                = "DWITHIN"; 
     25     */ 
     26    type: null, 
     27     
     28    /** 
     29     * APIProperty: property 
     30     * {String} 
     31     * name of the context property to compare 
     32     */ 
     33    property: null, 
     34     
     35    /** 
     36     * APIProperty: value 
     37     * {<OpenLayers.Geometry>} 
     38     * The geometry to pass into the spatial filter 
     39     */ 
     40    value: null, 
     41 
     42    /** 
     43     * APIProperty: distance 
     44     * {Number} 
     45     * The distance to use in a DWithin spatial filter 
     46     */ 
     47    distance: null, 
     48 
     49    /** 
     50     * APIProperty: distanceUnits 
     51     * {String} 
     52     * The units to use for the distance, e.g. m 
     53     */ 
     54    distanceUnits: null, 
     55 
     56     
     57    /**  
     58     * Constructor: OpenLayers.Filter.Spatial 
     59     * Creates a spatial filter. 
     60     * 
     61     * Parameters: 
     62     * options - {Object} An optional object with properties to set on the 
     63     *           filter 
     64     *  
     65     * Returns: 
     66     * {<OpenLayers.Filter.Spatial>} 
     67     */ 
     68    initialize: function(options) { 
     69        OpenLayers.Filter.prototype.initialize.apply(this, [options]); 
     70    }, 
     71 
     72    CLASS_NAME: "OpenLayers.Filter.Spatial" 
     73}); 
     74 
     75 
     76OpenLayers.Filter.Spatial.BBOX                 = "BBOX"; 
     77OpenLayers.Filter.Spatial.INTERSECTS             = "INTERSECTS"; 
     78OpenLayers.Filter.Spatial.DWITHIN                = "DWITHIN"; 
  • lib/OpenLayers/Format/SLD/v1.js

    old new  
    991991                var node = this.createElementNSPlus("ogc:UpperBoundary"); 
    992992                this.writeNode(node, "Literal", filter.upperBoundary); 
    993993                return node; 
     994            }, 
     995            "BBOX": function(filter) { 
     996                var node = this.createElementNSPlus("ogc:BBOX"); 
     997                this.writeNode(node, "PropertyName", filter); 
     998                var gml = new OpenLayers.Format.GML(); 
     999                node.appendChild(gml.buildGeometryNode(filter.value));  
     1000                return node; 
     1001            }, 
     1002            "DWITHIN": function(filter) { 
     1003                var node = this.createElementNSPlus("ogc:DWithin"); 
     1004                this.writeNode(node, "PropertyName", filter); 
     1005                var gml = new OpenLayers.Format.GML(); 
     1006                node.appendChild(gml.buildGeometryNode(filter.value)); 
     1007                this.writeNode(node, "Distance", filter); 
     1008                return node; 
     1009            }, 
     1010            "INTERSECTS": function(filter) { 
     1011                var node = this.createElementNSPlus("ogc:Intersects"); 
     1012                this.writeNode(node, "PropertyName", filter); 
     1013                var gml = new OpenLayers.Format.GML(); 
     1014                node.appendChild(gml.buildGeometryNode(filter.value)); 
     1015                return node; 
     1016            }, 
     1017            "Distance": function(filter) { 
     1018                return this.createElementNSPlus("ogc:Distance",  
     1019                    {attributes: {units: filter.distanceUnits},  
     1020                        value: filter.distance}); 
    9941021            } 
    9951022        } 
    9961023    }, 
     
    10221049        "<=": "PropertyIsLessThanOrEqualTo", 
    10231050        ">=": "PropertyIsGreaterThanOrEqualTo", 
    10241051        "..": "PropertyIsBetween", 
    1025         "~": "PropertyIsLike" 
     1052        "~": "PropertyIsLike", 
     1053        "BBOX": "BBOX", 
     1054        "DWITHIN": "DWITHIN", 
     1055        "INTERSECTS": "INTERSECTS" 
    10261056    }, 
    10271057     
    10281058